21.12.2009, 17:21
I have no idea how to make this code so that the player who writes the sentence can also sell to him himself
could anybody help me?
could anybody help me?
Код:
if(strcmp(cmd, "/sellweapon", true) == 0 || strcmp(cmd, "/sw", true) == 0) { if(IsPlayerConnected(playerid)) { if(PlayerInfo[playerid][pJob] != 1) { SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not an arms dealer"); return 1; } new x_weapon[256],weapon[MAX_PLAYERS],ammo[MAX_PLAYERS],price[MAX_PLAYERS]; tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /sellweapon [playerid/partofname] [weapon]"); SendClientMessage(playerid, COLOR_WHITE, "[Weapons:] baseballbat(50) | sdpistol(150) | eagle(250) | mp5(385)"); SendClientMessage(playerid, COLOR_WHITE, "[Weapons:] shotgun(300) | ak47(700) | m4(750) | rifle(800)"); return 1; } giveplayerid = ReturnUser(tmp); if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "[Error:] You can not sell weapons to yourself"); return 1; } x_weapon = strtok(cmdtext, idx); if(!strlen(x_weapon)) { SendClientMessage(playerid, COLOR_WHITE, "[Usage:] /sellweapon [playerid/partofname] [weapon]"); SendClientMessage(playerid, COLOR_WHITE, "[Weapons:] baseballbat(50) | sdpistol(150) | eagle(250) | mp5(385)"); SendClientMessage(playerid, COLOR_WHITE, "[Weapons:] shotgun(300) | ak47(700) | m4(750) | rifle(800)"); return 1; } } if(strcmp(x_weapon,"baseballbat",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 49) { weapon[playerid] = 5; price[playerid] = 50; ammo[playerid] = 1; PlayerInfo[giveplayerid][pGun1] = 14; PlayerInfo[giveplayerid][pAmmo1] = 1; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"sdpistol",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 149) { weapon[playerid] = 23; price[playerid] = 150; ammo[playerid] = 50; PlayerInfo[giveplayerid][pGun2] = 23; PlayerInfo[giveplayerid][pAmmo2] = 50; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"deagle",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 249) { weapon[playerid] = 24; price[playerid] = 250; ammo[playerid] = 50; PlayerInfo[giveplayerid][pGun2] = 24; PlayerInfo[giveplayerid][pAmmo2] = 50; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"mp5",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 384) { weapon[playerid] = 29; price[playerid] = 385; ammo[playerid] = 200; PlayerInfo[giveplayerid][pGun3] = 29; PlayerInfo[giveplayerid][pAmmo3] = 200; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"shotgun",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 299) { weapon[playerid] = 25; price[playerid] = 300; ammo[playerid] = 50; PlayerInfo[giveplayerid][pGun4] = 25; PlayerInfo[giveplayerid][pAmmo4] = 50; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"ak47",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 699) { weapon[playerid] = 30; price[playerid] = 699; ammo[playerid] = 250; PlayerInfo[giveplayerid][pGun4] = 30; PlayerInfo[giveplayerid][pAmmo4] = 250; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"m4",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 749) { weapon[playerid] = 31; price[playerid] = 750; ammo[playerid] = 250; PlayerInfo[giveplayerid][pGun4] = 31; PlayerInfo[giveplayerid][pAmmo4] = 250; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else if(strcmp(x_weapon,"rifle",true) == 0) { if(PlayerInfo[playerid][pMaterials] > 799) { weapon[playerid] = 33; price[playerid] = 800; ammo[playerid] = 50; PlayerInfo[giveplayerid][pGun4] = 33; PlayerInfo[giveplayerid][pAmmo4] = 50; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] You do not have enough materials"); return 1; } } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid weapon name"); return 1; } if(ProxDetectorS(5.0, playerid, giveplayerid)) { format(string, sizeof(string), "[Info:] You gave %s, a %s with %d ammo, for %d materials", GetPlayerNameEx(giveplayerid),x_weapon, ammo[playerid], price[playerid]); SendClientMessage(playerid, COLOR_WHITE, string); format(string, sizeof(string), "[Info:] %s received - Ammo: %d - From %s", x_weapon, ammo[playerid], GetPlayerNameEx(playerid)); SendClientMessage(giveplayerid, COLOR_WHITE, string); PlayerPlayerActionMessage(playerid,giveplayerid,15.0,"takes out a weapon and hands it to"); SafeGivePlayerWeapon(giveplayerid,weapon[playerid],ammo[playerid]); PlayerInfo[playerid][pMaterials] -= price[playerid]; } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] That player is not in range"); return 1; } } else { SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid ID/Name"); } } return 1; }