drug dealer -
thefatshizms - 22.07.2012
Hello, i have this cmd to sell some drugs to another player
only problem is that someone could go around selling drugs to people and effectively "rob them of their money" so i was thinking to make a cmd "offerdrugs" and it will set a variable to the other player that he has been offerd drugs now he needs to /acceptdugs which will put him in another variable basivly saying he is ready to accept deals of the other person now i made it and got some errors ill place code underneath with the warnings
pawn Код:
CMD:giveheroin(playerid, params[])
{
if(gTeam[playerid] == DRUG)
{
new id, ammount, money, string[128], string2[128];
if(sscanf(params,"uii",id,ammount,money)) return SendClientMessage(playerid, -1, "USAGE: /giveheroin <id/name> <grams> <moneywanted> ");
if(GetPlayerHeroin(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
if(GetPlayerMoney(id) < money) return SendClientMessage(playerid, COLOR_RED, "This player does not have those funds");
GivePlayerMoney(id, -money);
GivePlayerMoney(playerid, money);
GivePlayerHeroin(id, ammount);
format(string, sizeof(string), "You have given %s %d grams of heroin Dont forget to get payed!", PlayerName(id), ammount);
format(string2, sizeof(string2), "You have recived %d grams of heroin dont forget to pay him!", ammount, PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
personoffer[playerid] = false;
readydeal[id] = false;
return 1;
}
else if(gTeam[playerid] != DRUG)
{
SendClientMessage(playerid, -1, "You are not a drug dealer");
return 1;
}
return 1;
}
CMD:offerdrugs(playerid, params[])
{
new id;
if(sscanf(params,"u",id))
offerddrugs[id] = true;
personoffer[playerid] = true;
return 1;
}
CMD:acceptdeal(playerid, params[])
{
new id ,string[128];
if(sscanf(params,"u",id))
if(personoffer[id] = false) return SendClientMessage(playerid, -1, "This person hasnt offerd drugs");
format(string, sizeof(string), "%s is accepting deals");
if(id == gTeam[id] != DRUG) return SendClientMessage(playerid, -1, "This player isnt a dealer");
SendClientMessage(id, -1, string);
readydeal[playerid] = true;
return 1;
}
Код:
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(1340) : warning 211: possibly unintended assignment
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(1342) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Warnings.
sorry for the cmds small and not completely finished i was rushing it
p.s if u see any flaws in this method can you please tell me and suggest a better way
Re: drug dealer -
Kindred - 22.07.2012
Show us the lines.
Plus, (I could be wrong, haven't slept) you are simply setting it to true/false to the variable seeing if he was offered. Instead, you should set it to the players id, so that if the value is above 0 (meaning he was offered) it would then get that value and take there money and shit.
EDIT: Just read over it, I think it's retarded to do /acceptdrugs [id] or whatever. a simple /acceptdrugs command with my method is advised.
Re: drug dealer -
thefatshizms - 22.07.2012
ok thanks for the advice its appreciated
ive decided just to do the cmd without the <id> like you said (thanks) and now no errors
Re: drug dealer -
thefatshizms - 22.07.2012
ok no point in making another thread i got some warnings :
Код:
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(1308) : warning 211: possibly unintended assignment
C:\Users\iphone\Desktop\Pawn Scripting\gamemodes\Sfcnr.pwn(1331) : warning 211: possibly unintended assignment
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Warnings.
pawn Код:
CMD:giveheroin(playerid, params[])
{
new id;
if(gTeam[playerid] == DRUG)
{
if(readydeal[id] = true)
{
new ammount, money, string[128], string2[128];
if(sscanf(params,"uii",id,ammount,money)) return SendClientMessage(playerid, -1, "USAGE: /giveheroin <id/name> <grams> <moneywanted> ");
if(GetPlayerHeroin(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
if(GetPlayerMoney(id) < money) return SendClientMessage(playerid, COLOR_RED, "This player does not have those funds");
GivePlayerMoney(id, -money);
GivePlayerMoney(playerid, money);
GivePlayerHeroin(id, ammount);
format(string, sizeof(string), "You have given %s %d grams of heroin Dont forget to get payed!", PlayerName(id), ammount);
format(string2, sizeof(string2), "You have recived %d grams of heroin dont forget to pay him!", ammount, PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
personoffer[playerid] = false;
readydeal[id] = false;
return 1;
}
}
else if(gTeam[playerid] != DRUG)
{
SendClientMessage(playerid, -1, "You are not a drug dealer");
return 1;
}
else if(readydeal[id] = false)
{
SendClientMessage(playerid, -1, "This player is has not accepted any deal");
}
return 1;
}
Re: drug dealer -
ReneG - 22.07.2012
== checks if the left is equal to right
= sets left equal to right
https://sampwiki.blast.hk/wiki/Control_Structures
pawn Код:
CMD:giveheroin(playerid, params[])
{
new id;
if(gTeam[playerid] == DRUG)
{
if(readydeal[id] == true)
{
new ammount, money, string[128], string2[128];
if(sscanf(params,"uii",id,ammount,money)) return SendClientMessage(playerid, -1, "USAGE: /giveheroin <id/name> <grams> <moneywanted> ");
if(GetPlayerHeroin(playerid) < ammount) return SendClientMessage(playerid, -1, "You do not have that much grams!");
if(GetPlayerMoney(id) < money) return SendClientMessage(playerid, COLOR_RED, "This player does not have those funds");
GivePlayerMoney(id, -money);
GivePlayerMoney(playerid, money);
GivePlayerHeroin(id, ammount);
format(string, sizeof(string), "You have given %s %d grams of heroin Dont forget to get payed!", PlayerName(id), ammount);
format(string2, sizeof(string2), "You have recived %d grams of heroin dont forget to pay him!", ammount, PlayerName(playerid));
SendClientMessage(playerid, -1, string);
SendClientMessage(id, -1, string2);
personoffer[playerid] = false;
readydeal[id] = false;
return 1;
}
}
else if(gTeam[playerid] != DRUG)
{
SendClientMessage(playerid, -1, "You are not a drug dealer");
return 1;
}
else if(readydeal[id] == false)
{
SendClientMessage(playerid, -1, "This player is has not accepted any deal");
}
return 1;
}
Re: drug dealer -
thefatshizms - 22.07.2012
i fixed it myself but thanks for the link that will come in handy and it didnt know about == checks if the left is equal to right
= sets left equal to right so thanks

+2 rep
Re: drug dealer -
Youice - 22.07.2012
Add this so the dealer can't sell it to him self ;)
Код:
if(playerid == id) SendClientMessage(playerid, -1, "You can't sell drugs to yourself!");