Small help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Small help (
/showthread.php?tid=201338)
Small help -
Tee - 21.12.2010
I have a /selldrugs command for all the gang orgs on my server. It a checkpoint at their position and when another player walks into it, it shows them the menu to buy drugs.
The problem is that the person who is buying the drugs should loose cash and the person who is selling the drugs should get the cash. But i dont know what is the problem, only id 0 it will work for.
This is the Command. It is ok.
pawn Code:
COMMAND:selldrugs(playerid, params[])
{
new Float:dx,Float:dy,Float:dz;
if(IsGang[playerid] !=1 )return 1;
{
GetPlayerPos(playerid,dx,dy,dz);
DrugCP = CreateDynamicCP(dx,dy,dz, 2.0,-1,-1,-1,100.0);
SendClientMessage(playerid,orange,"You are now dealing drugs. Dont get caught");
ApplyAnimation(playerid, "DEALER", "DEALER_DEAL", 4.0, 1, 0, 0, 0, 0,1);
}
return 1;
}
Now here is the place where i want the seller to the get the cash but id 0 gets it.
pawn Code:
{
new cash = GetPlayerMoney(playerid),sellerid;
if(cash < 200)return SendClientMessage(playerid, red, "You need $200 to buy 1 gram of cocine");
if(Drugs[playerid] == 10)return SendClientMessage(playerid,red,"You already have the maximum ammout of drugs (10)");
GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
format(String,sizeof(String),"%s has just bought 1 gram of drugs",Name);
SendClientMessage(sellerid,green,String);
SendClientMessage(playerid, green, "You just bought 1 gram of cocaine. Type /usedrugs");
GivePlayerMoney(playerid, -200);
GivePlayerMoney(sellerid,200);
GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
format(file,sizeof(file),USER_FILES, Name);
if(dini_Exists(file))
{
dini_IntSet(file, "Drugs",Drugs[playerid] = 1);
}
Drugs[playerid] = 1;
}
Thanks in advance.
Respuesta: Small help -
admantis - 21.12.2010
I heard if a script works only with id 0 you need to make a loop (or either use Foreach, whatever your using), try it.
Re: Small help -
Tee - 21.12.2010
I tryed that but i get all the messages and All the players on the server gets it + the cash.