Raised This Month: $18 Target: $400
 4% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
BAILOPAN
Join Date: Jan 2004
Old 08-22-2016 , 16:40   Re: New API and Syntax
Reply With Quote #751

Are you asking for a way to set a methodmap to 0 without view_as? That should be easy, but it'd help to see a minimal example of what you're trying to do.
__________________
egg
BAILOPAN is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 08-22-2016 , 19:16   Re: New API and Syntax
Reply With Quote #752

Quote:
Originally Posted by BAILOPAN View Post
Are you asking for a way to set a methodmap to 0 without view_as? That should be easy, but it'd help to see a minimal example of what you're trying to do.
not set a methodmap but rather set an instance of one methodmap, inside a different methodmap, to 0

for instance...

PHP Code:
BaseBoss preselected;        /* The next player chosen as boss */

methodmap VSHGameMode        /* all game mode oriented code should be handled HERE ONLY */
{
    public 
VSHGameMode()
    {
        
preselected view_as<BaseBoss>(0);
    }
    public 
BaseBoss GetRandomBoss(const bool balive)
    {
        
BaseBoss boss;
        for (
int i=MaxClients ; --i) {
            if (
not IsValidClient(i) )
                continue;
            if (
balive and not IsPlayerAlive(i))
                continue;
            
boss BaseBoss(i);
            if (
not boss.bIsBoss)
                continue;
            else return 
boss;
        }
        return 
view_as<BaseBoss>(0);
    }

__________________

Last edited by nergal; 08-22-2016 at 19:19.
nergal is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-23-2016 , 18:36   Re: New API and Syntax
Reply With Quote #753

Quote:
Originally Posted by nergal View Post
not set a methodmap but rather set an instance of one methodmap, inside a different methodmap, to 0

for instance...
?


PHP Code:
enum BaseBoss
{
    
Boss_Zero
}

BaseBoss preselected;        /* The next player chosen as boss */

methodmap VSHGameMode        /* all game mode oriented code should be handled HERE ONLY */
{
    public 
VSHGameMode()
    {
        
preselected Boss_Zero;
    }
    public 
BaseBoss GetRandomBoss(const bool balive)
    {
        
BaseBoss boss;
        for (
int i=MaxClients ; --i) {
            if (
not IsValidClient(i) )
                continue;
            if (
balive and not IsPlayerAlive(i))
                continue;
            
boss BaseBoss(i);
            if (
not boss.bIsBoss)
                continue;
            else return 
boss;
        }
        return 
Boss_Zero;
    }

Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
nergal
Veteran Member
Join Date: Apr 2012
Old 08-23-2016 , 18:43   Re: New API and Syntax
Reply With Quote #754

Quote:
Originally Posted by Emp` View Post
?


PHP Code:
enum BaseBoss
{
    
Boss_Zero
}

BaseBoss preselected;        /* The next player chosen as boss */

methodmap VSHGameMode        /* all game mode oriented code should be handled HERE ONLY */
{
    public 
VSHGameMode()
    {
        
preselected Boss_Zero;
    }
    public 
BaseBoss GetRandomBoss(const bool balive)
    {
        
BaseBoss boss;
        for (
int i=MaxClients ; --i) {
            if (
not IsValidClient(i) )
                continue;
            if (
balive and not IsPlayerAlive(i))
                continue;
            
boss BaseBoss(i);
            if (
not boss.bIsBoss)
                continue;
            else return 
boss;
        }
        return 
Boss_Zero;
    }

BaseBoss is not an enum, it's a methodmap. Are you saying I need to make an enum everytime I require a null, non-Handle-based methodmap instance? Especially for methodmaps that aren't inheriting from another methodmap but needs to use data from them (other methodmaps).
__________________

Last edited by nergal; 08-23-2016 at 18:45.
nergal is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-23-2016 , 21:04   Re: New API and Syntax
Reply With Quote #755

Quote:
Originally Posted by nergal View Post
BaseBoss is not an enum, it's a methodmap.
Why not both?
PHP Code:
enum BothTest Both_Zero }
methodmap BothTest
{
//...

Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-23-2016 , 21:15   Re: New API and Syntax
Reply With Quote #756

Those macros for && and !
__________________
Neuro Toxin is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 08-23-2016 , 22:37   Re: New API and Syntax
Reply With Quote #757

Quote:
Originally Posted by Neuro Toxin View Post
Those macros for && and !
pardon me, I have Python fever lol
__________________
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 08-23-2016 , 22:43   Re: New API and Syntax
Reply With Quote #758

Quote:
Originally Posted by Emp` View Post
Why not both?
PHP Code:
enum BothTest Both_Zero }
methodmap BothTest
{
//...

because then I'd have to make an enum, just for zero, for all methodmaps.
which is not as efficient as me making a define for "view_as<any>(0)"
__________________
nergal is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-24-2016 , 05:29   Re: New API and Syntax
Reply With Quote #759

Having an equivalent constant to null for your custom methodmap makes complete sense.
It's invalid state is not the same as everything else's, and it doesn't make sense for 0 to mean invalid for everyone.
__________________

Last edited by asherkin; 08-24-2016 at 07:33.
asherkin is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-24-2016 , 07:31   Re: New API and Syntax
Reply With Quote #760

Eg: Dynamic's invalid is -1 as 0 is valid and is the server settings object.
__________________
Neuro Toxin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:15.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode