How to give a variable a value, that will also be read from a predefined value?
#1

Lets say I got

new license[1][128]
if (nolicense[playerid]) license[0] = "$1000";

This works, however how would I make it so I can predefine the $1000 in the top of the script? For example


#define LICENSE_PRICE 1000;

And use it like this

new license[1][128]
if (nolicense[playerid]) license[0] = "$%d", LICENSE_PRICE; (ofcourse this wont work) but is there aw ay for it to work?
Reply
#2

#define LICENSE_PRICE 1000
Reply
#3

Thats not what I mean, obviously I know how to do that.... I'm asking you guys what to do, to use it in this example down here:

new license[1][128]
if (nolicense[playerid]) license[0] = "$1000";
Reply
#4

Why are you storing it as a string anyway? You can just format it when it needs to be sent to the output.
Reply
#5

You cannot set the default value of any variable in an array. Since a string is basically an array, you cannot set its default value. The only way to do this would be to do something like this under OnGameModeInit() or something:

pawn Код:
license[0] = "$1000";
license[1] = "$1000";
However, Vince's solution is probably the least problematic.
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Why are you storing it as a string anyway? You can just format it when it needs to be sent to the output.
Because in the script its
if (nolicense[playerid]) license[0] = "{COLOR CODE}$1000";
else if (havelicense[playerid]) license[0] = "{COLOR CODE}$500";

Then its

format(gstring, sizeof(gstring), "The price is d", $license[0]);
SendClientMessage(playerid, COLOR_GREEN, gstring);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)