problem with playerid -
David_Omid - 13.04.2009
Hey guys, I am very new to scripting (only been scripting for about 1 month) and so I find some things hard...
Basically, I have a thing where someone goes to a pickup and does /buy - when they do this they are frozen, they take a phone, they get a message and after 5 seconds they are thawed, the phone goes away and then a tank is spawned
The person who does /buy is supposed to be effected after 5 seconds, nobody else
Code:
if(PlayerToPoint(1,playerid,2503.1392,-1776.8926,13.5469))
{
if(gTeam[playerid] == 1)
{
if(greenrhinobought == 0)
{
if(GetPlayerMoney(playerid) == 8000 || GetPlayerMoney(playerid) > 8000)
{
GivePlayerMoney(playerid,-8000);
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
TogglePlayerControllable(playerid,0);
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USECELLPHONE);
SetTimer("greenrhinoorder",5000,false);
greenrhinobought = 1;
DestroyPickup(greenrhinomarker);
SendClientMessage(playerid,COLOR_WHITE,"You have ordered a rhino tank");
}
else if (GetPlayerMoney(playerid) < 8000)
{
SendClientMessage(playerid,COLOR_WHITE,"You do not have enough money to buy this");
PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
}
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"Your team has already purchased this vehicle");
}
}
else
{
SendClientMessage(playerid,COLOR_WHITE,"Only team green members can buy team green vehicles");
PlayerPlaySound(playerid, 1053, 0.0, 0.0, 0.0);
}
return 1;
}
That's the first part, the next part is the after the 5 seconds:
Code:
public greenrhinoorder(playerid)
{
SendClientMessage(playerid,COLOR_GREY,"Team Green Vehicle Factory: your rhino tank has been made and delivered");
greenrhino = CreateVehicle(432,2502.8743,-1783.7015,13.5608,270.0590,43,0,60);
SendClientMessageToAll(COLOR_GREEN,"Team green have bought a rhino tank");
TogglePlayerControllable(playerid,1);
SetPlayerSpecialAction(playerid,SPECIAL_ACTION_STOPUSECELLPHONE);
return 1;
}
The problem I face is that instead of the person who used /buy getting effected when the timer ends (getting thawed, a message, phone being put away), but instead player with ID 0 is getting effected...can't figure out why...
Is there something I need to do? Any help would be greatly appreciated!
-Thanks
P.S sorry if this is a dumb question, but I am new to scripting
Re: problem with playerid -
ICECOLDKILLAK8 - 13.04.2009
Replace
pawn Code:
SetTimer("greenrhinoorder",5000,false);
with
pawn Code:
SetTimerEx("greenrhinoorder",5000,false,"d",playerid);
Re: problem with playerid -
David_Omid - 13.04.2009
Thank you very much my friend, but could you just explain to me what that actually does? Sorry, but I just find it easier to learn from the mistake if I know why it has to be done this way
Re: problem with playerid -
ICECOLDKILLAK8 - 13.04.2009
SetTimerEx(Function, Time, Repeat, FormatOfWhatToPass, WhatToPass);
So if you want the pass playerid (a number (Integer)) then you would put d or i as the FormatOfWhatToPass and playerid as WhatToPass
Re: problem with playerid -
David_Omid - 13.04.2009
Thanks man
, you're of great help to me