Quote:
Originally Posted by Vince
Either you or the forum software screwed up the indentation. But you should use variables to minimize duplicated code.
pawn Код:
new price, weaponid, ammo;
switch(listitem) { case 0: { price = 100, weaponid = 4, ammo = 1; } case 1: { price = 100, weaponid = 9, ammo = 1; } case 2: { price = 1500, weaponid = 16, ammo = 100; } // etc, etc } if(GetPlayerMoney(playerid) < price) return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this weapon.");
GivePlayerMoney(playerid, -price); GivePlayerWeapon(playerid, weaponid, ammo); SendClientMessage(playerid, 0x00FFFFAA, "You have succesfully bought your weapon.");
Much shorter, much more maintainable.
|
Thanks, Vince. Just so you know, i am not a PAWN legend like you, so i am like a intermediate scripter
I will also try to use your code, it looks short enough