Can't Remove Building From Includes
#1

Help guys i have putted remove building for player in an include and put that include under Ongamemodint like this
Код:
#include <Include name here.inc>
and i have defined playerid too
And the GM Compiles Without Error.
but when i connect to the server the buildings are not removed plzz help me
Reply
#2

Can you show us the code in your include file?

You should place #include <your_include> at the top of your script below #include <a_samp>, not under OnGameModeInit.
Reply
#3

You would have to add RemoveBuildingForPlayer under OnPlayerConnect and then hook it. I suggest ALS Hooking method
https://sampforum.blast.hk/showthread.php?tid=392061
Reply
#4

All I have done is created three functions in my mapping include, see below:
Код:
stock RemoveBuildings(playerid)
{
	// Mapping here
	printf("[mapping.inc] Removed Buildings for playerid %d.", playerid);
	return 1;
}

stock LoadMapping()
{
	// Mapping here
	print("[mapping.inc] Loaded Mapping");
	return 1;
}

stock LoadDynamicMapping(playerid)
{
	// Mapping here
	printf("[mapping.inc] Loaded Dynamic Mapping for playerid %d.", playerid);
	return 1;
}
And then in the main gamemode script under OnGameModeInit I call LoadMapping(), and under OnPlayerConnect I call RemoveBuildings(playerid) and LoadDynamicMapping(playerid).
Reply
#5

Код:
//Area 51
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
RemoveBuildingForPlayer(playerid, 3366, 276.6563, 2023.7578, 16.6328, 0.25);
RemoveBuildingForPlayer(playerid, 3366, 276.6563, 1989.5469, 16.6328, 0.25);
RemoveBuildingForPlayer(playerid, 3366, 276.6563, 1955.7656, 16.6328, 0.25);
RemoveBuildingForPlayer(playerid, 16094, 191.1406, 1870.0391, 21.4766, 0.25);
RemoveBuildingForPlayer(playerid, 3268, 276.6563, 2023.7578, 16.6328, 0.25);
RemoveBuildingForPlayer(playerid, 3268, 276.6563, 1989.5469, 16.6328, 0.25);
RemoveBuildingForPlayer(playerid, 3268, 276.6563, 1955.7656, 16.6328, 0.25);
}
Reply
#6

When I Put RemoveBuildingForPlayer Under On Player Connect Game Crashes While Reconnecting After Server Restart.So i Thought Of Putting It Under On Gamemodinit
Reply
#7

Quote:
Originally Posted by Speaker
Посмотреть сообщение
When I Put RemoveBuildingForPlayer Under On Player Connect Game Crashes While Reconnecting After Server Restart.So i Thought Of Putting It Under On Gamemodinit
Yes the player will crash if you try to remove the same object twice, this happens when you restart the server and a player reconnects.

From wiki: 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.
https://sampwiki.blast.hk/wiki/RemoveBuildingForPlayer

As far as I know there is no clean way of remedying this, have a read of this thread, it may help you:
https://sampforum.blast.hk/showthread.php?tid=485132&page=2

The first parameter of RemoveBuildingForPlayer is the playerid, so you're probably best not to place it under OnGameModeInit.
Reply
#8

No lol you can't do that, it HAS to be under OnPlayerConnect, Also the reconnect crash is mentioned in the samp wiki when you remove a building twice for a player he crashes.
edit: ah mew said it all.
Reply
#9

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
No lol you can't do that, it HAS to be under OnPlayerConnect, Also the reconnect crash is mentioned in the samp wiki when you remove a building twice for a player he crashes.
It doesn't HAVE to be under OnPlayerConnect, while it may be best practice, it is perfectly fine to place it anywhere providing that you can provide a valid playerid, the problem being though that it is difficult to determine whether or not the specific playerid has already had the objects removed.

The only work-around that I can find is mentioned in the thread I linked above:
Quote:
Originally Posted by Spmn
Посмотреть сообщение
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.
Reply
#10

Quote:
Originally Posted by MEW273
Посмотреть сообщение
It doesn't HAVE to be under OnPlayerConnect, while it may be best practice, it is perfectly fine to place it anywhere providing that you can provide a valid playerid, the problem being though that it is difficult to determine whether or not the specific playerid has already had the objects removed.

The only work-around that I can find is mentioned in the thread I linked above:
that's simply logic saying that you can place it anywhere with a playerid provided i ain't retarded... placing it at OnPlayerConnect is the most reasonable act and safe... Doing what @Spmn suggested you can never predict what can happen to the player some players CAN and WILL fall through the object when they teleport and get counted as a false swimming player and you'll get someone back here saying: erm.. the object not removed...
WELL YES it isn't accurate so imho IT HAS TO BE AT OnPlayerConnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)