AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   bool ??? (https://forums.alliedmods.net/showthread.php?t=249027)

InsanityKARAI 09-28-2014 18:52

bool ???
 
What is the function I use to be able to change states of such a function?
For example:

Noclip (Enabled) - Noclip (Disabled)

http://i.imgur.com/1VrAVxU.png

and how can I make a function like below: (not my work, do not understand scripter: P)
PHP Code:

if(get_user_noclip(id) == 1)
{
    
set_user_noclip(id 0)
    
Noclip Desactivated
}
else if (
get_user_noclip(id) == 0)
{
    
set_user_noclip(id 1)
    
Noclip Activated


ajuar thank me if you can :P

Note: Tell me what function should I use to create the two functions mentioned above.


mottzi 09-29-2014 05:22

Re: bool ???
 
Have a look at the !-operator. You can also search, there have been shown the best ways to do that already.

bat 09-30-2014 05:23

Re: bool ???
 
PHP Code:

#include amxmodx
#include fun

public plugin_init(){
    
register_clcmd("say test""tset")

}

public 
tset(id)
{
     
client_print(idprint_chat"Event: %s"get_user_noclip(id) ? "on" "off")



Kuma77 10-02-2014 10:13

Re: bool ???
 
You can try this

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

public plugin_init()
{    
    
register_plugin("Noclip ON / OFF""1.0""Kuma");
    
register_clcmd("say /nocON""NoclipON")
    
register_clcmd("say /nocOFF""NoclipOFF")
}

public 
NoclipON(id)
{

        if (
get_user_noclip(id))
         
set_user_noclip(id)
        else
        
set_user_noclip(id1)
    return 
PLUGIN_HANDLED 
}

public 
NoclipOFF(id)
{

        
set_user_noclip(id0)



Decak 10-03-2014 08:37

Re: bool ???
 
Why is the title 'bool' ? If you want bool(This is just an example not make anything if you are not finishing):

Code:

#include <amxmodx>

new bool:imbool[33];

public plugin_init() {
  register_clcmd("say /bool", "OnOffBool")
}

public OnOffBool(id) {
  imbool[id] = !imbool[id]
}

What plugin do? Plugin is set 'imbool' to true if bool false.If bool false, plugin sets bool true.Ofc, you can do someone like this:

Code:

#include <amxmodx>
#include <fun>

new bool:imbool[33];

public plugin_init() {
  register_clcmd("say /bool", "OnOffBool")
  register_clcmd("say /mynoclip", "Noclip")
}

public OnOffBool(id) {
  imbool[id] = !imbool[id]
}

public Noclip(id) {
  if(imbool[id]) {
  set_user_noclip(id, 1)
}
  if(!imbool[id]) { // this isn't necessarily, if you want to set user noclip 0, it's necessarily!
  set_user_noclip(id, 0)
}
}


Strick3n 10-03-2014 16:40

Re: bool ???
 
You can use bool variable to do it.

here example:
PHP Code:

#include < amxmodx >

new bool:g_bDisabled33 ];

public 
menu_example() 
{
    
// menu code goes here.. 
    
    
new szItem64 ];
    
    
formatexszItemcharsmaxszItem ), "My Option [ %sabled ]"g_bDisabledid ] ? "Dis" "En" );
    
    
menu_additemmenuidszItem );
    
    
// crap ..
}

public 
sub_menuidmenuitem )
{
    if( 
item == /*item id*/ )
        
g_bDisabledid ] = !g_bDisabledid ];




All times are GMT -4. The time now is 06:56.

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