Disabling a command or function with a variable?
#1

I've tryed this before, but like say i had a command, and before i start the server, i want to disable it? so instead of going ALL THE WAY down the script to disable it, theres a simple variable at the top i can just change to 0 to disable it.

this probably has been done before, anyone know?

thanks in adavance.
Reply
#2

pawn Code:
COMMAND:shop( playerid, params [ ] )
{
    if ( ifCMDDisable == 0 ) return 0;
    else
    {
    //..
    }  
    return 1;
}
Reply
#3

Be sure to also put
pawn Code:
#define ifCMDDisable 1
at the top
Reply
#4

Not what i mean, Like at the top of your script.

Test = 1;


then on the command theres somthing. When i want to disable the command or function i change test to

Test = 0;


EDIT: angel knows what i mean. thanks,.
Reply
#5

Quote:
Originally Posted by Th3Angel
View Post
Be sure to also put
pawn Code:
#define ifCMDDisable 1
at the top
If you use that you're telling the compiler this.

pawn Code:
if ( 1 == 0 )
Use a variable not a definition.
Reply
#6

Well shit, then does anyone know how i would do this?

At the top i can disable or enable the command.
Reply
#7

Something like this?

pawn Code:
//at top
new eventstart;

//FilterscriptInIt
eventstart = 0;

//Command1

COMMAND:eventstart( playerid, params [ ] )
{
    if (eventstart == 0)
    {
        //Your stuff...
        eventstart = 1;
    } else return SendClientMessage(playerid,red,"Event already started!!!!");
    return 1;
}

//Command2
COMMAND:event( playerid, params [ ] )
{
    if (eventstart == 0 ) return SendClientMessage(playerid,red,"Sorry, no event started.");
    //Your stuff...
    return 1;
}
Reply
#8

Yeah man, kinda like that. basicly, i have a function and a command i want to disable from the top of the script near my defines and what not. kind of like junkbuster. just needing a way where i can just put 0 to disable it. ill give your way a try.
Reply
#9

pawn Code:
//at top
#define UseFunction

//Before your function
#if define UseFunction
//function stuff
//
//
//
#endif
Reply
#10

Quote:
Originally Posted by willsuckformoney
View Post
pawn Code:
//at top
#define UseFunction

//Before your function
#if define UseFunction
//function stuff
//
//
//
#endif
Do i put the top on #define Usefunction 1?
Reply
#11

-Rebel Son- you changed your signatures why? i get a laugh reading your signatures now i dont damn..
Reply
#12

Nope, just like it is... Also if you don't want to be able to use the function (at all in script usage) comment the #define UseFunction

EDIT: well you can try like #define UseFunction 1
Reply
#13

@Willsuckformoney: alright thanks bro. Also, off topic, but where did you get your Avatar made? i like it :P
-
@BuzzBomb: Because, it was to big. and i had to steal your signiture pictures for ESET and W7 >
Reply
#14

My baby The Toni made it for me.
Reply
#15

@WillSuckForCandy: ok, ive seen alot of people with avatars like yours, also, i get one error with that code, says unkown symbol define on the line

#if define UseFunction

Idea?
Reply
#16

#if defined UseFunction

EDIT: Left out the D may been my fault.
Reply
#17

Ahh, alright simple mistake, how would i return it with a message? like if its not defined, "this command is disabled"
Reply
#18

hmm.. Dunno just OnPlayerCommandText where it should return 0; just have it say Command not recognized and/or has been disabled.
Reply
#19

Yeah, i guess i can do that. thanks for the help, Also, have toni hit me up one of those boss avatars, I would ask him myself, but i use msn anymore to contact him. thanks again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)