Raised This Month: $ Target: $400
 0% 

simple way to detect player stuck on spawn?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


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

Forum Jump


All times are GMT -4. The time now is 20:05.


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