To change #define with one command.
#1

hello,

It's possible to change, example #define Debug false ==> #define Debug true with one command.

Код:
#define Debug false

if(strcmp(cmd,"/debug",true)==0)
	{
    if(IsPlayerConnected(playerid))
	  {
	    #if Debug == false
	    #define Debug true
        #endif
    }
    return 1;
  }
dont work but its just a example.

thank.
Reply
#2

Top of script:

pawn Код:
#define Debug // On

or

// #define Debug // Off

#ifdef Debug
 if(strcmp("cmd, "/debug", true) == )
 {
 // Command in here :D
 }
#else
 return 0;
Reply
#3

Quote:
Originally Posted by JaYmE
Top of script:

pawn Код:
#define Debug // On

or

// #define Debug // Off

#ifdef Debug
 if(strcmp(cmd, "/debug", true) ==0)
 {
 // Command in here :D
 }
#else
 return 0;
you added a " before cmd and you putt == instead of ==0.

I'm not sure that'll work.
Reply
#4

pawn Код:
if(strcmp(cmd, "/debug", true) == 0)
{
  #if Debug == true
  #undef Debug
  #define Debug false
  #else
  #undef Debug
  #define Debug true
  #endif
}
Reply
#5

or you could just use a bool
Reply
#6

Quote:
Originally Posted by -The_Badger-
Quote:
Originally Posted by JaYmE
Top of script:

pawn Код:
#define Debug // On

or

// #define Debug // Off

#ifdef Debug
 if(strcmp(cmd, "/debug", true) ==0)
 {
 // Command in here :D
 }
#else
 return 0;
you added a " before cmd and you putt == instead of ==0.

I'm not sure that'll work.
ooops so i did soz i was in a rush, but if you fix the errors it should work

EDIT: #ifdef should be #if defined soz i was thinking about C++
Reply
#7

dont work, #define Debug false is never changed.

if i made

#if Debug == false
#undef Debug
#define Debug true
SendClientMessage(playerid, COLOR_WHITE, "open");
#else
#undef Debug
#define Debug false
SendClientMessage(playerid, COLOR_WHITE, "close");
#endif

it's always "open" and nothing.

for test in gm if i puts directly #define Debug true. it work
Reply
#8

why do you need to define it anyway? Couldn't you just do:
Код:
New debug=0;
if(strcmp(cmd,"/Debug",true)==0)
{
if(debug==0)return debug=1;
return 1;
}
Reply
#9

Quote:
Originally Posted by -The_Badger-
why do you need to define it anyway? Couldn't you just do:
Код:
New debug=0;
if(strcmp(cmd,"/Debug",true)==0)
{
if(debug==0)return debug=1;
return 1;
}
Actually you couldnt do that,
1) Variables are at 0 by default in Pawn so theres no need for the =0,
2) Its new not New,

You could do this if you really wanted to lol
pawn Код:
new _DEBUG;
#define Debug _DEBUG

// Then you could just do
Debug = true;
Debug = false;
Reply
#10

pawn Код:
new debug;
pawn Код:
if(strcmp(cmd,"/Debug",true)==0)
{
  if(debug==0)return debug=1;
  return 1;
}
ok then. How about now?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)