Raised This Month: $ Target: $400
 0% 

Call command under if of other command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dady000
Junior Member
Join Date: May 2012
Old 04-23-2013 , 05:43   Call command under if of other command
Reply With Quote #1

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.
dady000 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-23-2013 , 06:30   Re: Call command under if of other command
Reply With Quote #2

Make command a string and use set_task().
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
dady000
Junior Member
Join Date: May 2012
Old 04-23-2013 , 06:46   Re: Call command under if of other command
Reply With Quote #3

Quote:
Originally Posted by hornet View Post
Make command a string and use set_task().
Eh, how?
dady000 is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-23-2013 , 06:59   Re: Call command under if of other command
Reply With Quote #4

Quote:
Originally Posted by dady000 View Post
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.
__________________

Last edited by Blizzard_87; 04-23-2013 at 07:01.
Blizzard_87 is offline
dady000
Junior Member
Join Date: May 2012
Old 04-23-2013 , 07:17   Re: Call command under if of other command
Reply With Quote #5

Quote:
Originally Posted by Blizzard_87 View Post
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.
dady000 is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-23-2013 , 07:25   Re: Call command under if of other command
Reply With Quote #6

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...
__________________
Blizzard_87 is offline
dady000
Junior Member
Join Date: May 2012
Old 04-23-2013 , 07:31   Re: Call command under if of other command
Reply With Quote #7

Ahh, sorry I dont understood you but now I understand. Thank you
dady000 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-23-2013 , 07:36   Re: Call command under if of other command
Reply With Quote #8

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     } }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 04-23-2013 , 07:54   Re: Call command under if of other command
Reply With Quote #9

Quote:
Originally Posted by hornet View Post
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
__________________
Blizzard_87 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 10:45.


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