Materials don't decrease. -
Everything works fine except that part. Let's have a look at my code.
This is my acceptgun command.
/getmats command.
Код:
dcmd_getmats(playerid, params[])
{
#pragma unused params
if(PlayerInfo[playerid][pJob] != 9) return SendClientMessage(playerid, COLOR_GRAD2, "You're not a weapon dealer.");
if(CP[playerid] != 0) return SendClientMessage(playerid, COLOR_GRAD2, "You already have an existing material package or checkpoint.");
if(IsPlayerInRangeOfPoint(playerid, 5, 2099.64, -105.84, 0.68))
{
SetPlayerCheckpoint(playerid, -331.24, -466.16, -0.54, 5.0); // sets a checkpoint.
SendClientMessage(playerid, COLOR_YELLOW, "You have loaded the materials, and a marker have been set on your map to the destination.");
CP[playerid] = 5011;
return 1;
}
if(!IsPlayerInRangeOfPoint(playerid, 5, 1423.70, -1319, 13.55)) return SendClientMessage(playerid, COLOR_GRAD2, "You are not near enough the material pickup.");
new rand = random(sizeof(MDestinations));
SetPlayerCheckpoint(playerid, MDestinations[rand][0], MDestinations[rand][1], MDestinations[rand][2], 3.0); // sets a checkpoint.
SendClientMessage(playerid, COLOR_YELLOW, "You have loaded the materials, and a marker have been set on your map to the destination.");
CP[playerid] = 5011;
return 1;
}
Код:
dcmd_sellgun(playerid, params[])
{
if(PlayerInfo[playerid][pJob] != 9)
{
SendClientMessage(playerid, COLOR_GRAD2, "You're not a weapon dealer.");
return 1;
}
new choice[32], str[156];
new price;
new giveplayerid;
if(sscanf(params, "us[32]d", giveplayerid, choice, price))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellgun [ID / name or part of name] [weapon] [price]");
SendClientMessage(playerid, COLOR_GREY, "Weapon Dealer: sdpistol(100 mats) 9mm(150 mats) shotgun(200 mats) ");
SendClientMessage(playerid, COLOR_GREY, "Weapon Dealer: mp5(400 mats) bat(25 mats) rifle(1500 mats)");
SendClientMessage(playerid, COLOR_GREY, "Weapon Dealer: katana(50 mats) ak47(2000 mats) deagle(1000 mats)");
SendClientMessage(playerid, COLOR_GREY, "Weapon Dealer: spas(6000 mats) m4(3000 mats)");
SendClientMessage(playerid, COLOR_GREY, "Weapon Dealer: sniper(7000 mats) knuckles(50 mats)");
return 1;
}
if(strcmp(choice, "sdpistol", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 100) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 23;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a silenced pistol for $%d /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "9mm", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 150) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 22;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a 9mm pistol for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "shotgun", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 200) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 25;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a shotgun for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "mp5", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 400) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 29;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a mp5 for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "bat", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 25) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 5;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a bat for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "ak47", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 1500) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 30;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you an ak47 for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "m4", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 3000) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 31;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a m4 for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "rifle", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] >= 2000) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 33;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a rifle for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "deagle", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 1000) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 24;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a desert eagle for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "spas", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 6000) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 27;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a spas for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "katana", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 50) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 8;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a katana for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "sniper", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 7000) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 34;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you a sniper for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
if(strcmp(choice, "knuckles", true) == 0)
{
if(PlayerInfo[playerid][pMaterials] < 50) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough materials.");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "You can't sell your gun under 0$!");
GunPrice[giveplayerid] = price;
GunOffer[giveplayerid] = playerid;
weaponbeingoffered[giveplayerid] = 1;
beingofferedby[giveplayerid] = playerid;
format(str, sizeof(str), "%s has offered you some knuckles for $%d. /acceptgun to accept it.", GetName(playerid), price);
SendClientMessage(giveplayerid, COLOR_CYAN, str);
return 1;
}
return 1;
}