PDA

View Full Version : Requesting help with OnPlayerEnterVehicle


Magic_Time
05/02/2013, 03:59 PM
Hi, I want, when a player enters in vehicle "574"(Sweeper). He'll start the job.

The problem is that no message is sent. Also the money is not sent to the player here is the code:

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
switch(vehicleid)
{
case 574:
{
SendClientMessage(playerid, -1, "You are now street sweeping to earn money. Drive around to get your money");
SetTimer("Sweeping", 10000, false);
}
}
return 1;
}
forward Sweeping(playerid);
public Sweeping(playerid)
{
new string[128];
new rand = 200 + random(500);
GivePlayerMoney(playerid, rand);
format(string, sizeof(string), "You have received $%d for your street sweeping job", rand);
SendClientMessage(playerid, -1, string);
return 1;
}

Pangea
05/02/2013, 04:01 PM
SetTimer does not support parameters.
Change the SetTimer line with this:

SetTimerEx("Sweeping", 10000, false, "i", playerid);
SetTimerEx is the same, but SetTimerEx does support parameters.

Magic_Time
05/02/2013, 04:05 PM
Still the same problem.. No messages sent, No money too.

Pangea
05/02/2013, 04:13 PM
Do you teleport inside the vehicle instead of entering with F or enter?
Otherwise you should use OnPlayerStateChange

Magic_Time
05/02/2013, 04:19 PM
I'm using [0.3x]..
I tried this command to check if the server is checking the vehicle 574.

And unfortunately it's not checking... This is the command I used.
CMD:mycar(playerid, params[])
{
if(IsPlayerInVehicle(playerid, 574))
{
SendClientMessage(playerid, -1, "You are in a sweeper");
}
return 1;
}