15.08.2018, 22:14
Can someone tell me why this command doesn't work?
Basically, i have 2 type of drugs: marijuana and cocaine. And i want the player choose which type of drugs (and its respective amount) to sell. Ex /selldrugs marijuana 50.
But doesn't work:
Basically, i have 2 type of drugs: marijuana and cocaine. And i want the player choose which type of drugs (and its respective amount) to sell. Ex /selldrugs marijuana 50.
But doesn't work:
pawn Code:
CMD:selldrugs(playerid, params[])
{
if (Player[playerid][Job] != JOB_DRUG_DEALER) return SendClientMessage(playerid, COLOR_RED, "* You must be a drug dealer to sell drugs.");
if(gTeam[playerid] == TEAM_COP) return SendClientMessage(playerid, COLOR_RED, "* Law Enforcement officers can't sell drugs.");
new amount, string[156];
if(sscanf(params, "u", amount)) return SendClientMessage(playerid, COLOR_RED, "* [USAGE]: /selldrugs [drug type (marijuana, cocaine)] [grams amount] | Ex: /selldrugs marijuana 50");
if(amount < 1 || amount > 50) return SendClientMessage(playerid, COLOR_RED, "* Min amount: 1 gram | Max amount: 50 grams.");
if (!strcmp(params, "marijuana", true))
{
if (Player[playerid][MarijuanaGrams] < 0) return SendClientMessage(playerid, COLOR_RED, "* You dont have marijuana to sell.");
Player[playerid][MarijuanaGrams] -= amount;
GivePlayerMoney(playerid, MARIJUANA_COST_PER_GRAM*amount);
SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
}
else if (!strcmp(params, "cocaine", true))
{
if (Player[playerid][CocaineGrams] < 0) return SendClientMessage(playerid, COLOR_RED, "* You dont have cocaine to sell.");
Player[playerid][CocaineGrams] -= amount;
GivePlayerMoney(playerid, COCAINE_COST_PER_GRAM*amount);
SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
}
return 1;
}