OnPlayerExitVehicle(thevhicule, destroys no matter what) -
RiChArD_A - 31.01.2013
Hi, I have this on my server...
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
SetTimerEx("_DestroyVehicle", 10000, false, "i", vehicleid);
SendClientMessage(playerid,0xFFFFFFAA, "You have 10 to go back to the vehicule before it destroys.");
return 1;
}
//The end! XD | Please help meeeeee pleaaaaase... :sad meme:
What its suppose to do its delete the car if the player does not returns to it in 10 seconds, but it deletes any way even if the player gets back into it before the 10 seconds even if the player is in the vehicule. Please help me.
Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
Sime30 - 31.01.2013
lol sry about this message
Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
Riddick94 - 31.01.2013
Set this timer to the
player variable and kill it when player entered his vehicle again (OnPlayerStateChange)
Respuesta: Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
RiChArD_A - 31.01.2013
Quote:
Originally Posted by Riddick94
Set this timer to the player variable and kill it when player entered his vehicle again (OnPlayerStateChange)
|
How?
Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
u3ber - 31.01.2013
_DestroyVehicle code perhaps?
Re: Respuesta: Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
Riddick94 - 31.01.2013
Quote:
Originally Posted by Lauder
How?
|
Do you know how to create player array? Just create it and set it (=) to the SetTimerEx function. Then when player changed his state, you should use kill timer function to stop it.
Quote:
Originally Posted by arbit
_DestroyVehicle code perhaps?
|
Problem is obvious.
Respuesta: Re: Respuesta: Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
RiChArD_A - 31.01.2013
Quote:
Originally Posted by Riddick94
Do you know how to create player array? Just create it and set it (=) to the SetTimerEx function. Then when player changed his state, you should use kill timer function to stop it.
|
I don't know how to do it
Re: Respuesta: Re: Respuesta: Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
Riddick94 - 31.01.2013
Quote:
Originally Posted by Lauder
I don't know how to do it
|
This will help you:
https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays
https://sampwiki.blast.hk/wiki/KillTimer
Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
u3ber - 31.01.2013
Quote:
Originally Posted by Riddick94
Set this timer to the player variable and kill it when player entered his vehicle again (OnPlayerStateChange)
|
why?? he's doing it correctly!
@op, say ahh:
pawn Код:
new timer[MAX_PLAYERS];
forward _DestroyVehicle(vehicleid);
public _DestroyVehicle(vehicleid)
{
DestroyVehicle(vehicleid);
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
KillTimer(timer[playerid]);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
timer[playerid] = SetTimerEx("_DestroyVehicle", 5000, false, "i", vehicleid);
return 1;
}
Re: OnPlayerExitVehicle(thevhicule, destroys no matter what) -
Riddick94 - 31.01.2013
Quote:
Originally Posted by arbit
why?? he's doing it correctly!
|
No, he's not doing it correctly. Do you know how timers are working? Every time when you exit your vehicle this timer will be called. So that means, this timer will be called when player exit vehicle, and player enter vehicle again before ten seconds will be passed, and player exit again. There will be two timers started, first with smaller count and second one with higher count. Server will get confused and will stop first timer (even if player is in the vehicle) and destroy his vehicle. And then second timer will call _DestroyVehicle and server gonna destroy already destroyed vehicle, what may crash player/server.
edit://
Quote:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
KillTimer(timer[playerid]);
return 1;
}
|
You should not call KillTimer function in
OnPlayerEnterVehicle and also you should not give him a ready code, because we are here to help, not to give ready code. If he want to get a ready code then he should post it in Script request thread.