SA-MP Forums Archive
how to redefine a define? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: how to redefine a define? (/showthread.php?tid=259900)



how to redefine a define? - fissekarl - 06.06.2011

if you can say that, but I want to know how to like switch something in the define ingame.

#define Name "Anynamehere"

Then under on dialogresponse i have something like this but getting errors all the time

#define Name "inputtext"

tried all kinds of way, but how ?


Re: how to redefine a define? - KoczkaHUN - 06.06.2011

defines are just for the preprocessor. it cannot redefine macros after compiling.
Y-Less' tutorial
altough you can use #undefine Name before the new define line.


Re: how to redefine a define? - [DM]Kane - 06.06.2011

In my knowledge, you can't #define something from in-game. Its a pre-processor directive.


Re: how to redefine a define? - fissekarl - 06.06.2011

Quote:
Originally Posted by [DM]Kane
Посмотреть сообщение
In my knowledge, you can't #define something from in-game. Its a pre-processor directive.
sucks, no other way or something?


Re: how to redefine a define? - KoczkaHUN - 06.06.2011

https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables


Re: how to redefine a define? - Tee - 06.06.2011

I don't know what you mean but this is what I gather from it: You would like to undefine something that is already defined and then defined it with your own.

Here is an example: You want to change the value of 'MAX_PLAYERS'

pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS (whatever is the MAX_PLAYERS in your server)



Re: how to redefine a define? - fissekarl - 06.06.2011

Tee, but the other said it cannot be done while ingame


Re: how to redefine a define? - Tee - 06.06.2011

Oh, that's true, it is preprocessed so I don't think there is a way to do it.


Re: how to redefine a define? - sim_sima - 06.06.2011

just du like this:
pawn Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 60
Now is MAX_PLAYERS defined to 60 in stead of 500.


Re: how to redefine a define? - Kwarde - 06.06.2011

Its impossible indeed (as far as I know) to change it ingame. If you wanna change such thing, make a global variable. eg. the COLOR_CUSTOM:

pawn Код:
#include <a_samp>
#include <zcmd>

new COLOR_CUSTOM = 0xFF0000AA; //Red

CMD:current_color(playerid, params[])
    return SendClientMessage(playerid, COLOR_CUSTOM, "This is the current custom color!");

CMD:set_color(playerid, params[])
    return isnull(params) ? SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /set_color [color]") : CUSTOM_COLOR = params[0]; //Not sure if that'll work :P
Something similar to that.
The only way to change a DEFINE is, as said above with #undef and again #define
pawn Код:
#define COLOR_CUSTOM 0xFF0000AA //Red
#undef COLOR_CUSTOM
#define COLOR_CUSTOM 0x00FF00AA //Green