How to give a variable a value, that will also be read from a predefined value? -
101 - 28.06.2013
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?
Re: How to give a variable a value, that will also be read from a predefined value? -
IstuntmanI - 28.06.2013
#define LICENSE_PRICE 1000
Re: How to give a variable a value, that will also be read from a predefined value? -
101 - 28.06.2013
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";
Re: How to give a variable a value, that will also be read from a predefined value? -
Vince - 28.06.2013
Why are you storing it as a string anyway? You can just format it when it needs to be sent to the output.
Re: How to give a variable a value, that will also be read from a predefined value? -
Scenario - 28.06.2013
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.
Re: How to give a variable a value, that will also be read from a predefined value? -
101 - 28.06.2013
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);