how to redefine a define?
#1

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 ?
Reply
#2

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.
Reply
#3

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

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?
Reply
#5

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

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)
Reply
#7

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)