05.06.2011, 16:56
Here is code that you will put after #include
and this in OnPlayerCommandText
pawn Код:
enum _weapons{
Weapon_Name[64],
Model,
Level,
Price
}
new Weapons[][_weapons] = {
{'colt45',22,1,500},
{'mp5',29,2,1500},
{'shotgun',25,2,2000},
{'deagle',24,3,10000},
{'rifle',33,3,12000},
{'m4',31,3,20000},
{'ak47',30,3,30000},
{'spas12',26,3,65000},
{'sniper',34,3,200000},
{'rpg',35,15,20000000}
};
pawn Код:
if(!strcmp(cmd, "/buygun", true)){
new tmp[128], BG_String[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, COLOR_GREY, "USAGE: /buygun [GunName]");
return 1;
}
for(new i=0;i<sizeof(Weapons);i++){
if(!strcmp(Weapons[i][Weapon_Name], tmp, true)){
if(PlayerInfos[playerid][pLevel] >= Weapons[i][Level]){
if(PlayerInfos[playerid][pMoney] >= Weapons[i][Price]){
GivePlayerWeapon(playerid, Weapons[i][Model], 500);
PlayerInfos[playerid][pMoney] = PlayerInfos[playerid][pMoney] - Weapons[i][Price];
GivePlayerMoney(playerid, -Weapons[i][Price]);
return 1;
}else{
SendClientMessage(playerid, COLOR_RED, "You don't have enough money.");
return 1;
}
}else{
format(BG_String, sizeof(BG_String), "You have to be at least level %d to buy this weapon.", Weapons[i][Level]);
SendClientMessage(playerid, COLOR_REd, BG_String);
return 1;
}
}
}
return 1;
}