27.12.2014, 21:46
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?
...and so on.
How can I make this shorter and more dynamic rather than static?
Код:
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; }
How can I make this shorter and more dynamic rather than static?