05.10.2017, 19:38
I've started making the Drug System just now, it compiled without errors. But now i don't know how exactly to make the /acceptdrugs command. Here's the code:
The /selldrugs command.
The /declinedrugs command.
And i have no clue how to make the /acceptdrugs one, any help?
ALSO, is this code written good? I dont want the player to sell the amount of drugs he doesen't have.
The /selldrugs command.
Код:
CMD:selldrugs(playerid,params[]) { if(OfferedDrugs[playerid] == 1) return SendClientMessage(playerid,COLOR_RED,"You've already offered someone drugs."); { new id, amount, price, Pname[MAX_PLAYER_NAME], Pname1[MAX_PLAYER_NAME], drugs, str[100], str1[100]; if(PlayerInfo[playerid][pDrugs] == 0) return SendClientMessage(playerid,COLOR_RED,"You dont have any drugs left on you."); if(PlayerInfo[playerid][pDrugs] < drugs) return SendClientMessage(playerid,COLOR_RED,"You dont have that much drugs."); if(sscanf(params,"uii",id,amount,price)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /selldrugs [ID] [Amount] [Price]"); GetPlayerName(playerid, Pname, sizeof(Pname)); GetPlayerName(id, Pname1, sizeof(Pname1)); format(str,sizeof(str)," %s has offered you %d grams of drugs for %d $, you can either /acceptdrugs or /declinedrugs",Pname,amount,price); format(str1,sizeof(str1)," You've offered the drugs to %s",Pname1); SendClientMessage(playerid,COLOR_ORANGE,str1); SendClientMessage(id,COLOR_ORANGE,str); OfferedDrugs[id] = 1; OfferedDrugs[playerid] = 1; } return 1; }
Код:
CMD:declinedrugs(playerid,params[]) { if(OfferedDrugs[playerid] == 0) return SendClientMessage(playerid,COLOR_RED,"No one has offered drugs to you."); { new id, Pname[MAX_PLAYER_NAME], Pname1[MAX_PLAYER_NAME], str[100], str1[100]; if(sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /declinedrugs [ID]"); if(OfferedDrugs[id] == 0) return SendClientMessage(playerid,COLOR_RED,"That player havent made you the drug offer."); GetPlayerName(playerid, Pname, sizeof(Pname)); GetPlayerName(id, Pname1, sizeof(Pname1)); format(str,sizeof(str),"You've declined the drug offer from %s", Pname1); format(str1,sizeof(str1)," %s has declined your drug offer", Pname); SendClientMessage(playerid,COLOR_ORANGE,str); SendClientMessage(id,COLOR_RED,str1); OfferedDrugs[id] = 0; OfferedDrugs[playerid] = 0; } return 1; }
ALSO, is this code written good? I dont want the player to sell the amount of drugs he doesen't have.
Код:
if(PlayerInfo[playerid][pDrugs] < drugs) return SendClientMessage(playerid,COLOR_RED,"You dont have that much drugs.");