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

simple way to detect player stuck on spawn?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
loki_himself
Member
Join Date: Nov 2021
Old 10-19-2022 , 15:34   simple way to detect player stuck on spawn?
Reply With Quote #1

...

Last edited by loki_himself; 11-23-2022 at 12:12.
loki_himself is offline
zXCaptainXz
Member
Join Date: May 2017
Old 10-19-2022 , 18:40   Re: simple way to detect player stuck on spawn?
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
public plugin_init() {
        
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
}
 
public 
fwHamPlayerSpawnPost(player) {
        if (
is_user_alive(player)) {
            new 
Float:origin[3], hull        
            pev
(playerpev_originorigin)
            
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
            
if (!is_hull_vacant(originhull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT))
            {
                
//Player is stuck
            
}
        }
}  

stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
    static 
tr
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr)
    if (!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_AllSolid)) //get_tr2(tr, TR_InOpen))
        
return true
    
    
return false

Replace //Player is stuck with whatever action you want to do, also what do you mean you don't want to call any hooks? You at least have to hook Ham_Spawn to run the code on player spawn... You can also skip checking for noclip and non-solid players if you're sure that will never happen in your server. It might be also possible to skip checking if the player is ducking because it doesn't matter the moment the player spawns, he may not be able to duck immediately.
I took the code from this plugin https://forums.alliedmods.net/showthread.php?p=441576

Last edited by zXCaptainXz; 10-19-2022 at 18:50.
zXCaptainXz is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-20-2022 , 07:33   Re: simple way to detect player stuck on spawn?
Reply With Quote #3

!(pev(player,pev_solid) & SOLID_NOT)

(pev(player, pev_solid) != SOLID_NOT)

pev_solid is not a bit value.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
loki_himself
Member
Join Date: Nov 2021
Old 10-20-2022 , 11:23   Re: simple way to detect player stuck on spawn?
Reply With Quote #4

...

Last edited by loki_himself; 11-23-2022 at 13:27.
loki_himself is offline
zXCaptainXz
Member
Join Date: May 2017
Old 10-20-2022 , 13:12   Re: simple way to detect player stuck on spawn?
Reply With Quote #5

Quote:
Originally Posted by loki_himself View Post
yes i saw that code of course. i hook postSpawn from csdm of course but i dont want to hook some touch function. this plugin you mentioned is complicated and i have used many plugins that cause crashes on the long run. natsheh already posted a correction for this approved plugin...

is there a known bug in csdm that causes the players to not spawn in preset places? for example in the map aim_map4ever there is 1 original map spawnpoint corrupted. and even though i set preset spawns, sometimes a player spawns stuck in the ground on that spawnpoint
The part which I borrowed from that plugin is not complicated at all, it's simply calling TraceHull once and checking for collisions, no loops involved or anything. It is called only once on spawn. The whole plugin on the other hand calls it on loop because it's checking all the time if the player is stuck, which you don't need.

You also didn't mention that you want to "prevent" that bug from happening in the first place, only that you want to "detect" if he's stuck on spawn. There's no simpler way than the one I mentioned as far as I'm aware. Maybe you could loop that function on map start on all spawns and somehow disable/delete faulty spawns.. I don't have much experience in CSDM so I don't know how how to deal with CSDM spawns, only normal ones.

Tl;dr let me know if you want code that deletes original map's faulty spawns
zXCaptainXz is offline
loki_himself
Member
Join Date: Nov 2021
Old 10-20-2022 , 13:23   Re: simple way to detect player stuck on spawn?
Reply With Quote #6

...

Last edited by loki_himself; 11-23-2022 at 13:27.
loki_himself is offline
zXCaptainXz
Member
Join Date: May 2017
Old 10-20-2022 , 17:14   Re: simple way to detect player stuck on spawn?
Reply With Quote #7

Quote:
Originally Posted by loki_himself View Post
i tired that hull code from above and removed "&& !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)". i use resemiclip and when a player spawns on a teammate, he is considered stuck although he is not due to the semiclip. is that part above relevant for that?

It's because of the error Natsheh pointed out, it should be &&(pev(player,pev_solid)!=SOLID_NOT)

Anyway, I tried this code and it removed a faulty spawn successfully, give it a shot

PHP Code:
#include <amxmodx>
#include <engine>

public plugin_init()
{
    
register_plugin("Bad Spawn Remover""1.0""zXCaptainXz")
    new 
ent = -1
    
new Float:origin[3]
    while((
ent find_ent_by_class(ent"info_player_start")))
    {
        
entity_get_vector(entEV_VEC_originorigin)
        if(
trace_hull(originHULL_HUMAN)&3)
        {
            
remove_entity(ent);
        }
    }
    
ent = -1
    
while((ent find_ent_by_class(ent"info_player_deathmatch")))
    {
        
entity_get_vector(entEV_VEC_originorigin)
        if(
trace_hull(originHULL_HUMAN)&3)
        {
            
remove_entity(ent);
        }
    }

zXCaptainXz is offline
loki_himself
Member
Join Date: Nov 2021
Old 10-21-2022 , 06:52   Re: simple way to detect player stuck on spawn?
Reply With Quote #8

...

Last edited by loki_himself; 11-23-2022 at 13:28.
loki_himself is offline
loki_himself
Member
Join Date: Nov 2021
Old 10-24-2022 , 15:59   Re: simple way to detect player stuck on spawn?
Reply With Quote #9

...

Last edited by loki_himself; 11-23-2022 at 13:28.
loki_himself 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 16:20.


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