Raised This Month: $ Target: $400
 0% 

Command Toggle(ON/OFF)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
suundz
Junior Member
Join Date: Oct 2012
Location: Sweden, Bollnäs
Old 07-14-2014 , 09:31   Command Toggle(ON/OFF)
Reply With Quote #1

Hello, I wan't to make a plugin with a command that toggle on/off

Code:
#include <amxmodx>

new bool:ReadyUsed[33];

public plugin_init() {
     register_clcmd("ready", "ready");
}
So I'm using this and I wan't to toggle the boolean ReadyUsed on or off, by using it first time it's on and by second time it's off

Please give me some help, if you don't understand try reading it again :S

Thanks in advance! =D
suundz is offline
Send a message via Skype™ to suundz
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 07-14-2014 , 10:16   Re: Command Toggle(ON/OFF)
Reply With Quote #2

ClanWar plugin @_@?
PHP Code:
new bool:g_user_ready[33]

register_clcmd("say /ready""clcmdReady"0)

public 
clcmdReady(id)
{    
    if(
g_user_ready[id])
    {
        
g_user_ready[id] = false
    
} else {
        
g_user_ready[id] = true
    
}

Phant is offline
Send a message via ICQ to Phant
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 07-14-2014 , 10:22   Re: Command Toggle(ON/OFF)
Reply With Quote #3

Ahh I hate this:
PHP Code:
public clcmdReady(id)
{    
    if(
g_user_ready[id])
    {
        
g_user_ready[id] = false
    
} else {
        
g_user_ready[id] = true
    
}

It's just:
PHP Code:
public clcmdReady(id)
{    
    
g_user_ready[id] = !g_user_ready[id]

__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Phant
Veteran Member
Join Date: Sep 2009
Location: New Jersey
Old 07-14-2014 , 10:52   Re: Command Toggle(ON/OFF)
Reply With Quote #4

If/Else condition in this case for further coding. For example, adding client_print() messages, like:
Quote:
"%s" Ready.
"%s" Not Ready.
Phant is offline
Send a message via ICQ to Phant
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 07-14-2014 , 11:06   Re: Command Toggle(ON/OFF)
Reply With Quote #5

PHP Code:
g_user_ready[id] = !g_user_ready[id]
client_print(0print_chat"Name %sReady", !g_user_ready[id] ? "Not " ""
Backstabnoob is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-14-2014 , 13:38   Re: Command Toggle(ON/OFF)
Reply With Quote #6

And if you have more to do after the value toggle then things get pretty silly. I guess Phants point is valid there.
mottzi is offline
Send a message via MSN to mottzi
suundz
Junior Member
Join Date: Oct 2012
Location: Sweden, Bollnäs
Old 07-14-2014 , 13:53   Re: Command Toggle(ON/OFF)
Reply With Quote #7

Thank you all for replying very kind of you all since I'm new
Appreciate a lot!
suundz is offline
Send a message via Skype™ to suundz
Reply



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 21:05.


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