Player Death bug related to vehicles
#1

So,I was trying to make my speedometer hide when a player leaves the vehicle he's driving,but I noticed it doesnt disappear when player dies.I was wondering what could be the problem,and was trying to fix it for days,when I noticed that what causes it is that when player dies and is sent to class selection,he actually remains in the vehicle he died in.I made a simple command to check player's vehicle ID at any moment,and the result was that when I died,and checked my vehicle ID in class selection,it was the same as the vehicle I died in.I guess this is similar to the kick/ban bug that doesnt send the reason message to the kicked/banned player,because player remains in the vehicle even when I add RemovePlayerFromVehicle(playerid); in my /kill,/reclass cmds,and in OnPlayerDeath.Below is a video I made to describe the bug.Also if this bug has already been reported,please forgive me.
[ame]http://www.youtube.com/watch?v=Hngw9eKitmA[/ame]

Here is the command in case someone else wanna test this bug
pawn Код:
COMMAND:vid(playerid,params[])
{
    new vehicleid,Msg[128];

    vehicleid = GetPlayerVehicleID(playerid);
    format(Msg,128,"Your vehicle id is %i",vehicleid);
    SendClientMessage(playerid,0xffffffff,Msg);

    return 1;
}
Reply
#2

Looks like an authentic bug, can you try putting this in OnPlayerDeath() - RemovePlayerFromVehicle(playerid);
Reply
#3

I already tried that,result is the same.Anyway I will try it again.But also just to let you know that I know some servers that somehow have fixed that,may be this bug is known for a long time but not reported.

EDIT:I checked my script and I already have RemovePlayerFromVehicle(playerid); in OnPlayerDeath(),so obviously it doesnt fix it.If someone has a fix please share.
Reply
#4

Just tested by using this code:
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendClientMessage(playerid, 0xFFFFFFFF, "You died");

    return 1;
}
The message was sent even when killing myself when inside a vehicle.
And using your command (vid) in class-selection after killing myself inside a vehicle kept saying I was still inside a vehicle.

This seems to be a samp bug.
See my topic of PPC Trucking V1 (http://forum.sa-mp.com/showpost.php?...postcount=3712).
Even after putting in a check in the UpdatePlayerTextDraws function and removing the player from his vehicle, the server still thinks you are inside a vehicle even when your character is standing at class-selection.
Reply
#5

As I said even putting RemovePlayerFromVehicle(playerid); in all possible places,SAMP still detects the player being in the vehicle.I wonder how some servers manage to fix it.
Reply
#6

You could always make a variable...

pawn Код:
#define IsPlayerDead(%0) PlayerIsDead[%0]
new bool:PlayerIsDead[MAX_PLAYERS];

OnPlayerDeath - PlayerIsDead[playerid] = true;
OnPlayerSpawn - PlayerIsDead[playerid] = false;
OnPlayerDisconnect - PlayerIsDead[playerid] = false;
If the player then they can't be in a vehicle pretty simple.
Reply
#7

I'm hiding my speedometer using OnPlayerStateChange callback.
For every state, the speedo is hidden or shown when needed.

Class-selection after entering the server is State 0 (PLAYER_STATE_NONE).
Class-selection after respawning and re-entering class selection = 7 (PLAYER_STATE_WASTED).
For both cases, the speedo is hidden.

PLAYER_STATE_ONFOOT also hides the speedo (to hide it when you exit the vehicle, either from the driver-seat as well from a passenger seat).
PLAYER_STATE_DRIVER and PLAYER_STATE_PASSENGER display the speedo.

That's how I fixed it.

Previously, I used the globalspeedotimer function to hide/show the speedo based on being a vehicle.
But displaying it twice every second when it's already displayed was a waste of resources and possibly bandwidth.
That's why I re-made it to use OnPlayerStateChange.
If you state doesn't change, there is no need to hide/show your textdraws twice every second when it's already hidden/shown respectively.

Now it doesn't matter if you're inside a vehicle or not, because the script isn't using your vehicleid anymore to determine if the speedo should be displayed or hidden solely based on that.
It's only checking your state.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)