How can I add Player Levels forever? - 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)
+--- Thread: How can I add Player Levels forever? (
/showthread.php?tid=553053)
How can I add Player Levels forever? -
HighFlyer - 27.12.2014
I have this code, but I aim to avoid making this code long. At the moment, it's checking every single level that I coded. I'd like for the levels to be unlimited. Is there a way to shorten down this code, so it doesn't have to check for specific levels, but instead increments these levels in an if statement, while incrementing value of rand_level by a defined amount on each new level?
Код:
if(Player[playerid][Level] == 1)
{
new rand_level = 100 + random(100);
format(string, sizeof(string), "Level 1 pay: $%d", rand_level);
SendClientMessage(playerid, WHITE, string);
Player[playerid][Money] += rand_level;
}
if(Player[playerid][Level] == 2)
{
new rand_level = 200 + random(200);
format(string, sizeof(string), "Level 2 pay: $%d", rand_level);
SendClientMessage(playerid, WHITE, string);
Player[playerid][Money] += rand_level;
}
if(Player[playerid][Level] == 3)
{
new rand_level = 300 + random(300);
format(string, sizeof(string), "Level 3 pay: $%d", rand_level);
SendClientMessage(playerid, WHITE, string);
Player[playerid][Money] += rand_level;
}
...and so on.
How can I make this shorter and more dynamic rather than static?
Re: How can I add Player Levels forever? -
Ahmad45123 - 27.12.2014
Try these :
pawn Код:
new lvl = Player[playerid][Level]; //Just to shorten it abit...
new rand_level = (lvl * 100) + random(lvl * 100);
format(string, sizeof(string), "Level %d pay: $%d", lvl, rand_level);
SendClientMessage(playerid, WHITE, string);
Player[playerid][Money] += rand_level;
Re: How can I add Player Levels forever? -
HighFlyer - 27.12.2014
Thank you!