OnPlayerDisconnect(unsure why)
#1

Not sure if this is a bug or more a player latency/ping issue..

OnPlayerDisconnect seems to get called for some players and the player is still connected?
They are still walking around and talking in chat?

Recently i created a vehicle dealership at otto's in sf, which allows players to buy most vehicles with in-game cash an that then saves on their account along with mods an colour ofc.

So i have a variable in OnPlayerDisconnect called "gPlayerDisconnect" which is set to 1 when a player disconnects, after that the variable is then checked by the vehicle saving function.
The vehicle saving function then sees this an destroys the leaving players vehicleid so that id is free for the next connecting player.

Having said all this.. there has been some cases where a players car gets randomly deleted.. but the player is still connected.. (complaining lots ofc) but talking in chat an doing things that you can normally do...

The vehicle can only be deleted if gPlayerDisconnect = 1.. so it must of been called for that player, no?
Reply
#2

Does this happen regularly (all of the time), or only with player's with high ping (latency) ? And what is the ping of the player that this happens to him ?
Reply
#3

I seriously doubt this is a problem with SA-MP itself. Nearly every gamemode relies very heavily on this callback. If there was a problem with it I'm sure most gamemodes would be broke.
Reply
#4

Quote:
Originally Posted by Jay_
Посмотреть сообщение
I seriously doubt this is a problem with SA-MP itself. Nearly every gamemode relies very heavily on this callback. If there was a problem with it I'm sure most gamemodes would be broke.
Completely agree with you, if that was a bug every gamemode would of been bugged right now.
Reply
#5

I really have no idea about the pings at the time this occurred, but yeah i also think its a client sided connection issue (their poo internet)

The player partially loses connection.. still playing but "OnPlayerDisconnect" has been called.


small example.. very poor but an example..
pawn Код:
}

public OnPlayerDisconnect(playerid, reason)
{
    gPlayerDisconnect[playerid] = 1;
    UpdatePlayerAccount(playerid); // within this function (UpdatePlayerVehicle) is called
    return 1;
}

pawn Код:
//this is at the end of the vehicle saving function "UpdatePlayerVehicle"..after all mods have been saved.
if(gPlayerDisconnect[playerid] != 0)//apparently leaving
{
    if(gPlayerPurchasedCar[playerid] != 0)//their vehicleid
    {
        DestroyVehicle(gPlayerPurchasedCar[playerid]);//delete that vehicleid
    }
}

So basically the car can only be destroyed when gPlayerDisconnect doesn't equal 0.. but that doesn't explain to me how sometimes the car gets destroyed and the player is still connected, then the next joining player obtains that players vehicleid.. an now both players can /lock, /telecar an so on.. and it screws everything up...

gPlayerDisconnect is set to 0 in OnPlayerConnect an to 1 in OnPlayerDisconnect, these are the only two times this variable changes. So for now i have made a little function on a non looping 3 second timer.. which is called just after the players vehicle is deleted.. so now if gPlayerDisconnect equals 1 (the vehicle was deleted) and the player is still connected... kick!

Its my only option atm.


PS:could a moderator move this thread to scripting discussion please..
thank you and sorry for posting in the wrong section mb
Reply
#6

Maybe this helps forum.sa-mp.com/showthread.php?t=184118&highlight=understanding+SA %3AMP+sync
Reply
#7

Ahh yeah, after reading that.. its pretty safe to say it would be some kind of client connection (internet latency) issue.

But hopefully my little fix will sort that out


Thanks..
Reply
#8

It's probably your connection, or the script itself
Reply
#9

Honestly mate lmao... it hasn't happened to me at all!

How can it be the script when the script has no control over when "OnPlayerDisconnect" gets called?
The problem imo seems to be poor connection (internet) for some players.

Know something about what you're talking about before talking about it...
Reply
#10

It could be an include you're using that hooks OnPlayerDisconnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)