SA-MP Forums

Go Back   SA-MP Forums > SA-MP > Bug Reports

Reply
 
Thread Tools Display Modes
Old 15/05/2017, 04:39 PM   #11
Spmn
Gangsta
 
Join Date: Jun 2015
Location: Romania
Posts: 528
Reputation: 113
Default Re: RemoveBuildingForPlayer - crash if player reconnects

Quote:
Originally Posted by rt-2 View Post
Still the main problem is that if a player loose connection for a second, it will crash him on reconnect, because if you remove the same building twice for a player he crashes, I'm trying to find a fix to it...
Not really... Crashes happen only when a certain amount of removed buildings is reached. So, your players get crashed only because you remove a lot of objects, and when they reconnect, that amount is doubled and most likely that limit is reached
Spmn is offline   Reply With Quote
Old 16/05/2017, 01:24 PM   #12
rt-2
Huge Clucker
 
rt-2's Avatar
 
Join Date: Jun 2011
Location: Montréal, Québec, Canada
Posts: 268
Reputation: 24
Default Re: RemoveBuildingForPlayer - crash if player reconnects

Quote:
Originally Posted by Spmn View Post
Not really... Crashes happen only when a certain amount of removed buildings is reached. So, your players get crashed only because you remove a lot of objects, and when they reconnect, that amount is doubled and most likely that limit is reached
So you mean that "When removing the same object for a player, they will crash. Commonly, players crash when reconnecting to the server because the server removes buildings on OnPlayerConnect." from http://wiki.sa-mp.com/wiki/RemoveBuildingForPlayer is wrong?

Anyway does anyone found a way to avoid re-removing buildings for players?
Thank you,
rt-2
__________________
rt-2
My hardcore first person 1994 simulation in development:
SA Advance Roleplay
rt-2 is offline   Reply With Quote
Old 16/05/2017, 08:07 PM   #13
Spmn
Gangsta
 
Join Date: Jun 2015
Location: Romania
Posts: 528
Reputation: 113
Default Re: RemoveBuildingForPlayer - crash if player reconnects

Had around 100 buildings removed on my server. Players barely crashed when they reconnected after connection loss.
Spmn is offline   Reply With Quote
Old 17/05/2017, 05:11 PM   #14
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: Germany
Posts: 1,136
Reputation: 331
Default Re: RemoveBuildingForPlayer - crash if player reconnects

Quote:
Originally Posted by rt-2 View Post
So you mean that "When removing the same object for a player, they will crash. Commonly, players crash when reconnecting to the server because the server removes buildings on OnPlayerConnect." from http://wiki.sa-mp.com/wiki/RemoveBuildingForPlayer is wrong?

Anyway does anyone found a way to avoid re-removing buildings for players?
Thank you,
rt-2
You can "test" whether or not objects were removed.
Remove a building that has a collision for players joining the server that did NOT have a timeout the last time he left (just like usual).
If someone joins who timed out the last time he left, teleport him onto that building. After a second or two, check the player's position. If the player is still on the object, call your RemoveBuildingForPlayer code. If he falls through, the buildings were already removed (the player didn't crash, but loose connection).


It's ugly, not 100% reliable but technically the only way to find out whether or not a building exists client side.
Make sure the player doesn't pause and there is enough time for syncing before checking, then it should all work well.
I do this on my server and did not have any issues with this (local as well as real server), except players can use hacks/mods to teleport/freeze them.
I run this test during the very first spawn, if the camera is placed/pointed somewhere else it won't even be visible - it just takes 3 seconds. You can show the Rules or similar during this time period.
NaS is offline   Reply With Quote
Old 17/05/2017, 08:09 PM   #15
Spmn
Gangsta
 
Join Date: Jun 2015
Location: Romania
Posts: 528
Reputation: 113
Default Re: RemoveBuildingForPlayer - crash if player reconnects

I used a similar approach on a stunt server and it worked flawless:
1) teleport the player on this object, right above the sea level
2) wait 1-2 seconds (IIRC, I made use of player's ping and/or fps for more accurate results)
3) use GetPlayerAnimationIndex() to detect if player was swimming or not
-> if player isn't swimming -> call remove building code, INCLUDING that object
-> else -> skip

I also had a library based on this, but I can't find it right now.
Spmn is offline   Reply With Quote
Old 18/05/2017, 01:54 AM   #16
rt-2
Huge Clucker
 
rt-2's Avatar
 
Join Date: Jun 2011
Location: Montréal, Québec, Canada
Posts: 268
Reputation: 24
Default Re: RemoveBuildingForPlayer - crash if player reconnects

Thats very nice ideas guys.
Thank you,
__________________
rt-2
My hardcore first person 1994 simulation in development:
SA Advance Roleplay
rt-2 is offline   Reply With Quote
Old 06/10/2017, 03:19 AM   #17
Romz
Gangsta
 
Join Date: Jun 2013
Posts: 883
Reputation: 49
Default Re: RemoveBuildingForPlayer - crash if player reconnects

This bug is still present. It is necessary that Kalcor made after reconnect so that the remote objects returned to their places. Players complain, I do not know how to solve this problem.

It would also be cool to add a function that checks if the objects are removed from the player or not. In this case, it would be possible to simply check and, if necessary, delete objects on the connection.
Romz is offline   Reply With Quote
Old 06/10/2017, 02:31 PM   #18
SPAWN_METAL
Gangsta
 
SPAWN_METAL's Avatar
 
Join Date: Dec 2010
Posts: 549
Reputation: 54
Wink Re: RemoveBuildingForPlayer - crash if player reconnects

Code:
int RemovedBuilduing[1000];
int CountRemove;

void Remove(int objectid)
{
	RemovedBuilduing[CountRemove]=objectid;
	CountRemove++;
}
When CountRemove reach 1000 there is memory leak
it's how Kalcor did this function
__________________
][Noname][ Owner of Absolute Play and SAMP Addon
SPAWN_METAL is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] :: Anti-Reconnect Script. Avoid Auto Reconnects made by * tools! iPLEOMAX Includes 18 27/12/2013 02:53 PM
zGaming - reconnects. JizZy00 Scripting Help 1 25/05/2013 06:19 PM
Weapons after player reconnects ajwar Scripting Help 0 24/02/2013 06:34 PM
Player Crash DonWade Server Support 0 26/04/2012 12:19 AM
[Client Crash] RemoveBuildingForPlayer BigETI Bug Reports 0 09/04/2012 12:19 AM


All times are GMT. The time now is 10:01 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.