Raised This Month: $51 Target: $400
 12% 

Odd TeleportEntity Crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 06-20-2017 , 17:46   Odd TeleportEntity Crash
Reply With Quote #1

I am having a strange issue, when I try to teleport a player to a new location (and valid on map) on "player_spawn", the server will crash at random. I am certain it is teleport entity because as soon as I comment out the function "TeleportEntity" and leave everything else intact, no crashes whatsoever. No other plugins are using any such function either.

Would it be wiser maybe to use TeleportEntity with "OnGameFrame" instead of Event_PlayerSpawn?


Thanks for any insight

PHP Code:
public OnPluginStart() 

    
HookEvent("player_spawn"Event_PlayerSpawn); 


public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast

    
// TELEPORT ENTITY CRASH 
    
if(IsPlayerAlive(client))
    {
        
TeleportEntity(clientfSpawnLocationfSpawnLocationAngleNULL_VECTOR);
    }

EDIT:
- I have also thought of using a timer for TeleportEntity after Event_PlayerSpawn, but unfortunately this makes a very visible transition from spawn to the new location which I do not want.
- Updated code to current with "IsPlayerAlive"; crash still happening

.

Last edited by scorpius2k1; 06-20-2017 at 19:14.
scorpius2k1 is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 06-20-2017 , 18:51   Re: Odd TeleportEntity Crash
Reply With Quote #2

did you check if the player is alive?
The player_spawn event does not only get fired when a player physically spawns
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...
Totenfluch is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 06-20-2017 , 19:14   Re: Odd TeleportEntity Crash
Reply With Quote #3

Quote:
Originally Posted by Totenfluch View Post
did you check if the player is alive?
The player_spawn event does not only get fired when a player physically spawns
Yes, still happens. Apologies for not mentioning that, updated my initial post
scorpius2k1 is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 06-20-2017 , 19:29   Re: Odd TeleportEntity Crash
Reply With Quote #4

Try and teleport them a frame after.

PHP Code:
RequestFrame() 
or

PHP Code:
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post); 

Last edited by Weetabix; 06-20-2017 at 19:36.
Weetabix is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 06-22-2017 , 10:17   Re: Odd TeleportEntity Crash
Reply With Quote #5

Quote:
Originally Posted by Weetabix View Post
Try and teleport them a frame after.

PHP Code:
RequestFrame() 
or

PHP Code:
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post); 

This:
PHP Code:
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post); 
Thank you for your help, has seemed to do the trick nicely, so far uptime over 24 hours and no crash.


I will report back if I have any further issues, thanks again all!
scorpius2k1 is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-22-2017 , 11:30   Re: Odd TeleportEntity Crash
Reply With Quote #6

EventHookMode_Post is the default though, so you didn't change anything.
__________________
Peace-Maker is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 06-22-2017 , 12:52   Re: Odd TeleportEntity Crash
Reply With Quote #7

Quote:
Originally Posted by Peace-Maker View Post
EventHookMode_Post is the default though, so you didn't change anything.
Weird. Not sure how that makes sense with HL2DM, because as soon as I put it back to
PHP Code:
HookEvent("player_spawn"Event_PlayerSpawn); 
^^ The random crashes start again.

with this
PHP Code:
HookEvent("player_spawn"Event_PlayerSpawnEventHookMode_Post); 
I get no crashes. Hard to explain, but there is a difference somewhere. HL2DM is a quirky game at best, so who knows...but it's working with that code strangely enough.

Last edited by scorpius2k1; 06-22-2017 at 12:53.
scorpius2k1 is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 06-22-2017 , 16:36   Re: Odd TeleportEntity Crash
Reply With Quote #8

Well, there literally is no different between those two lines.
https://github.com/alliedmodders/sou...vents.inc#L174
__________________
Peace-Maker is offline
scorpius2k1
Senior Member
Join Date: Feb 2016
Old 06-22-2017 , 16:41   Re: Odd TeleportEntity Crash
Reply With Quote #9

Quote:
Originally Posted by Peace-Maker View Post
Well, there literally is no different between those two lines.
https://github.com/alliedmodders/sou...vents.inc#L174
Definitely not saying you are wrong, but for sure there is some difference somewhere because it seems to have worked, been up for over 24h now and zero issues. Previous, it would be up tops for maybe a few hours. Now, if it does however start crashing, and I jinx myself at this point--- what would be a proper way to teleport a player on spawn without having to use a timer? I know Weetabix had also recommended "RequestFrame()", but I have not used that before so not sure how to implement it exactly.

Again, thanks everyone for all the help in getting this weird issue sorted out!
scorpius2k1 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-23-2017 , 11:47   Re: Odd TeleportEntity Crash
Reply With Quote #10

Code:
#include <sourcemod>
#include <sdktools>

float gF_SpawnLocation[3];
float gF_SpawnAngle[3];

public void OnPluginStart() 
{ 
	HookEvent("player_spawn", Player_Spawn); 
} 

public Player_Spawn(Event event, const char[] name, bool dontBroadcast) 
{ 
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	RequestFrame(TeleportPlayer, GetClientSerial(client));
}

void TeleportPlayer(int data)
{
	int client = GetClientFromSerial(data);
	
	if(client == 0)
	{
		return;
	}
	
	TeleportEntity(client, gF_SpawnLocation, gF_SpawnAngle, NULL_VECTOR);
}
__________________
retired
shavit is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 10:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode