AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Call command under if of other command (https://forums.alliedmods.net/showthread.php?t=214104)

dady000 04-23-2013 05:43

Call command under if of other command
 
Hi, I dont know if I can somehow execute the command like this
PHP Code:

public func_money(idmoney1money2command)
{
    if(
cs_get_user_money(id) >= money1)
    {
        
cs_set_user_money(idcs_get_user_money(id) + money20)
                
command //execute command here    
    
}
    else
    {
        
NoMoney(id)
    }
    


And then func_money(id, 10, -10, SetGlow(id, 1))?
Thanks.

hornet 04-23-2013 06:30

Re: Call command under if of other command
 
Make command a string and use set_task().

dady000 04-23-2013 06:46

Re: Call command under if of other command
 
Quote:

Originally Posted by hornet (Post 1938121)
Make command a string and use set_task().

Eh, how?

Blizzard_87 04-23-2013 06:59

Re: Call command under if of other command
 
Quote:

Originally Posted by dady000 (Post 1938126)
Eh, how?

another way of doing it is to make a stock...

Code:
stock func_money( id, cost, const command[] ) {     new money = cs_get_user_money(id);         if( money < cost )     {         NoMoney(id)         return PLUGIN_HANDLED;     }         if( equal(command, "SetGod" ) // example: func_money( id, 200, "SetGod" )     {         set_user_godmode( id, 1 ) // execute command here           }         cs_set_user_money( id, money - cost )         return PLUGIN_HANDLED; }

not 100% sure ive done it right as I'm only going off what you showed in your code.

dady000 04-23-2013 07:17

Re: Call command under if of other command
 
Quote:

Originally Posted by Blizzard_87 (Post 1938130)
another way of doing it is to make a stock...

Code:
stock func_money( id, cost, const command[] ) {     new money = cs_get_user_money(id);         if( money < cost )     {         NoMoney(id)         return PLUGIN_HANDLED;     }         if( equal(command, "SetGod" ) // example: func_money( id, 200, "SetGod" )     {         set_user_godmode( id, 1 ) // execute command here           }         cs_set_user_money( id, money - cost )         return PLUGIN_HANDLED; }

not 100% sure ive done it right as I'm only going off what you showed in your code.

Actually, it isnt code that I need. The command that I meant is already coded. So SetGlow(id, 1) is used to set glow of player to 1 (coded color). So I need to add coded command to this command and execute it at the if(). Like: func_money(id, 10 (if user have 10 money), -10 (set user money -10), SetGlow(id, 1) or other command - this is the command to execute at specified place in code) So that.

Blizzard_87 04-23-2013 07:25

Re: Call command under if of other command
 
Code:
stock func_money( id, cost, const command[] ) {     new money = cs_get_user_money(id);         if( money < cost )     {         NoMoney(id)         return PLUGIN_HANDLED;     }         if( equal(command, "SetGod" ) // example: func_money( id, 200, "SetGod" )     {         set_user_godmode( id, 1 ) // execute command here           }     if( equal(command, "SetGlow" ) // example: func_money( id, 250, "SetGlow" )     {         SetGlow( id, 1 ) // Execute Set Glow Here.     }         cs_set_user_money( id, money - cost )         return PLUGIN_HANDLED; }

you can add as many commands in this stock how ever many commands or items you require.

and the command is getting executed in a if().

i dont understand what your last post was trying to say...

dady000 04-23-2013 07:31

Re: Call command under if of other command
 
Ahh, sorry I dont understood you but now I understand. Thank you :D

hornet 04-23-2013 07:36

Re: Call command under if of other command
 
I believe this is what he's asking for:
Code:
public func_money(id, money1, money2, const command[], paramsnum ) {     if(cs_get_user_money(id) >= money1)     {         cs_set_user_money(id, cs_get_user_money(id) + money2, 0)                 /*  paramsnum is how many parameters your function will have take player index             **  For example SetGlow .. paramsnum would be 1 ..             **  To set enabled or disabled         */                 new Data[ sizeof paramsnum ];         Data[ 0 ] = 1; //this is the value you want glow to be in this example                 set_task( 0.01, command, id, Data, sizeof Data );     }     else     {         NoMoney(id)     }     }   public SetGlow( enabled[], id ) {     if( enabled[ 0 ] )     {         //set glow     }     else        {           //remove glow     } }

Blizzard_87 04-23-2013 07:54

Re: Call command under if of other command
 
Quote:

Originally Posted by hornet (Post 1938145)
I believe this is what he's asking for:
Code:
public func_money(id, money1, money2, const command[], paramsnum ) {     if(cs_get_user_money(id) >= money1)     {         cs_set_user_money(id, cs_get_user_money(id) + money2, 0)                 /*  paramsnum is how many parameters your function will have take player index             **  For example SetGlow .. paramsnum would be 1 ..             **  To set enabled or disabled         */                 new Data[ sizeof paramsnum ];         Data[ 0 ] = 1; //this is the value you want glow to be in this example                 set_task( 0.01, command, id, Data, sizeof Data );     }     else     {         NoMoney(id)     }     }   public SetGlow( enabled[], id ) {     if( enabled[ 0 ] )     {         //set glow     }     else        {           //remove glow     } }

thanks that also helps me too :P


All times are GMT -4. The time now is 10:45.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.