21.03.2019, 00:07
Good night everyone, I have been working on this code for some time, I thought it was finally ready, but now nothing happens when I try to sell a weapon to another player.
Thank you very much if anyone can help me!
Thank you very much if anyone can help me!
PHP код:
CMD:sellgun(playerid, params[])
{
new f = GetPlayerOrg(playerid), sstring[128], weaponid, value, mats, w;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
w = weaponid;
mats = GetWeaponValue(w);
if(PlayerInfo[playerid][pJob] == 7 || OrgMafia(f))
{
if(sscanf(params, "us[45]d", giveplayerid, weaponid, value))
{
new g = 0;
g = 23; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 24; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*45)/100))); SCM(playerid, -1, sstring);
g = 25; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 27; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 29; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 30; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*45)/100))); SCM(playerid, -1, sstring);
g = 31; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 33; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 34; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
g = 39; FORMAT_SSTR "[%d] %s - minimum value: R$%d (R$%d Client VIP/DIAMANTE)",g,WeaponsName[g],GetWeaponValue(g)+350,350+(GetWeaponValue(g)-((GetWeaponValue(g)*35)/100))); SCM(playerid, -1, sstring);
SCM(playerid, -1, "Use: /sellgun [playerid] [number] [value]'");
return 1;
}
if(playerid == targetid) return SCM(playerid, -1, "Use '/armaments' in the organization safe.");
else if(w!=23&&w!=24&&w!=25&&w!=27&&w!=29&&w!=30&&w!=31&&w!=33&&w!=34&&w!=39) return SCM(playerid, -1, "You do not have this weapon to sell..");
if(weaponid == 23) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else if(weaponid == 24) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*45)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else if(weaponid == 25) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else if(weaponid == 27) { if(PlayerInfo[playerid][pGunSkill] >= 0300) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 03 of arms dealer."); }
else if(weaponid == 29) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else if(weaponid == 30) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*45)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else if(weaponid == 31) { if(PlayerInfo[playerid][pGunSkill] >= 0300) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 03 of arms dealer."); }
else if(weaponid == 33) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else if(weaponid == 34) { if(PlayerInfo[playerid][pGunSkill] >= 1000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 05 of arms dealer."); }
else if(weaponid == 39) { if(PlayerInfo[playerid][pGunSkill] >= 0000) { if(IsPlayerVIP(giveplayerid)) { mats -= ((mats*35)/100); } } else return SCM(playerid, -1, "You are not level 01 of arms dealer."); }
else return 1;
////////////////////////////////////////////////////////////////////
if(value < (mats+350) || value > 20000) { FORMAT_SSTR "Minimum price for the sale of this weapon is R$%d.", (mats+350)); return SCM(playerid, -1, sstring); }
if(PlayerInfo[playerid][psMats] < mats) { FORMAT_SSTR "You need to get %d materials in the HQ."); return SCM(playerid, -1, sstring); }
if(PlayerInfo[playerid][pMats] < mats) { FORMAT_SSTR "You need to buy %d materials with some mafia."); return SCM(playerid, -1, sstring); }
if(!IsPlayerConnected(giveplayerid)) return SCM(playerid, -1, "Player is not connect.");
if(PlayerInfo[giveplayerid][pLevel] < 3) return SCM(playerid, -1, "Player still can not receive weapons.");
if(weaponid == 34) return SCM(playerid, -1, "ERROR: A sniper has already been mounted, wait a few minutes until another is ready.");
if(weaponid == 34 && !OrgMafia(f) || GetPlayerOrg(playerid)!= 15) return SCM(playerid, -1, "Only the Mafia and Al'Qaeda can sell snipers.");
if(weaponid == 34) { if(ORG_SNIPERDELAY[f] > 0) { FORMAT_SSTR "ERROR: A sniper has already been mounted, wait %d minutes until another is ready.",ORG_SNIPERDELAY[f]); return SCM(playerid, -1, sstring); } }
////////////////////////////////////////////////////////////////////
if(ProxDetectorS(5.0, playerid, giveplayerid))
{
FORMAT_SSTR "%s is offering %s to %s for R$%d.",Nome(playerid),WeaponsName[w],Nome(giveplayerid),value);
SendClientMessageInRange(15.0, playerid, sstring, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
FORMAT_SSTR "You agree to buy %s weapon from %s for R$%d?",WeaponsName[w],Name(playerid),value);
ShowPlayerDialog(giveplayerid,DIALOG_SELLING_WEAPON,DIALOG_STYLE_MSGBOX,"Buying weapon",sstring,"accept","refuse");
BuyingWeaponPlayer[giveplayerid] = playerid; BuyingWeapon[giveplayerid] = weaponid; BuyingWeaponValue[giveplayerid] = value;
}
else SCM(playerid, -1, "ERROR: Player is too far away.");
}
return 1;
}