08.12.2012, 13:13
Hey, i'm making this command and everything's working fine, but the You don't have enough drug grams ain't working properly, i tried using both && and || and only the cocaine works fine, but the acid can sell any gram no matter how much the dealer has
pawn Код:
CMD:givedrugs(playerid, params[])
{
new name[MAX_PLAYER_NAME], message[128], drugname[50], gramammount, targetid, othername[MAX_PLAYER_NAME];
if(sscanf(params, "us[100]i", targetid, drugname, gramammount)) return SendClientMessage(playerid, GRAY, "Function : /givedrugs [ id ] [ Cocaine / Weed / Acid ] [ Grams ]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, GRAY, "This player is not connected !");
if(GetDistanceBetweenPlayers(playerid, targetid) > 3) return SendClientMessage(playerid, GRAY, "You're too far away from this player !");
if(gramammount > pCocaine[playerid] && gramammount > pAcid[playerid]) return SendClientMessage(playerid, GRAY, " You don't have enough drug grams !");
if(gramammount <= 0) return SendClientMessage(playerid, GRAY, " Invalid grams ammount.");
if(!strcmp(drugname, "cocaine", true && pCocaine[playerid] >= gramammount && GetDistanceBetweenPlayers(playerid, targetid) < 3))
{
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, othername, sizeof(othername));
format(message, sizeof(message), "%s hands out a bag of cocaine to %s.", name, othername);
ProxDetector(40.0, playerid, message, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
pCocaine[playerid]-=gramammount;
pCocaine[targetid]+=gramammount;
return 1;
}
if(!strcmp(drugname, "acid", true && pAcid[playerid] >= gramammount && GetDistanceBetweenPlayers(playerid, targetid) < 3))
{
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, othername, sizeof(othername));
format(message, sizeof(message), "%s hands out few grams of acid to %s.", name, othername);
ProxDetector(40.0, playerid, message, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
pCocaine[playerid]-=gramammount;
pCocaine[targetid]+=gramammount;
return 1;
}
if(!strcmp(drugname, "weed", true && pWeed[playerid] >= gramammount && GetDistanceBetweenPlayers(playerid, targetid) < 3))
{
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, othername, sizeof(othername));
format(message, sizeof(message), "%s gives a bag filled with weed to %s.", name, othername);
ProxDetector(40.0, playerid, message, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
pWeed[playerid]-=gramammount;
pWeed[targetid]+=gramammount;
return 1;
}
return 1;
}