OnPlayerExitVehicle(thevhicule, destroys no matter what)
#1

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.
Reply
#2

lol sry about this message
Reply
#3

Set this timer to the player variable and kill it when player entered his vehicle again (OnPlayerStateChange)
Reply
#4

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
Set this timer to the player variable and kill it when player entered his vehicle again (OnPlayerStateChange)
How?
Reply
#5

_DestroyVehicle code perhaps?
Reply
#6

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.
Reply
#7

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
Reply
#8

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
Reply
#9

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;
}
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)