AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Semiclip + Autounstuck (https://forums.alliedmods.net/showthread.php?t=188467)

Larcyn 06-26-2012 17:40

Semiclip + Autounstuck
 
Hello, I'm having some trouble with an autounstuck and semiclip plugin. When a player has semiclip and he is standing in another player in his team he gets unstucked because the autounstuck plugin thinks that the players are stuck in each other.

I need help with adding a short code that checks if the player is standing in a teammate.

I've searched a lot, but I can't find a working one.

I am using this Autounstuck code:
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <fun>

new stuck[33]

new const 
Float:size[][3] = 
{
    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.0, -5.0}, {-5.0, -5.0, -5.0}
}

public 
plugin_init() 
{
    
register_plugin("AutoUnstuck""1.5""NL)Ramon(NL")
    
set_task(0.1"checkstuck"0""0"b")
}

public 
checkstuck() 
{
    static 
players[32], pnumplayer
    get_players
(playerspnum)
    static 
Float:origin[3]
    static 
Float:mins[3], hull
    
static Float:vec[3]
    static 
o,i
    
for(i=0i<pnumi++){
        
player players[i]
        if (
is_user_connected(player) && is_user_alive(player)) {
            
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)) {
                ++
stuck[player]
                if(
stuck[player] >= 3
                {
                    
pev(playerpev_minsmins)
                    
vec[2] = origin[2]
                    for (
o=0sizeof size; ++o) {
                        
vec[0] = origin[0] - mins[0] * size[o][0]
                        
vec[1] = origin[1] - mins[1] * size[o][1]
                        
vec[2] = origin[2] - mins[2] * size[o][2]
                        if (
is_hull_vacant(vechull,player)) {
                            
engfunc(EngFunc_SetOriginplayervec)
                            
set_pev(player,pev_velocity,{0.0,0.0,0.0})
                            
sizeof size
                        
}
                    }
                }
            }
            else 
stuck[player] = 0
        
}
    }
}

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))
        return 
true
    
    
return false



Xalus 06-28-2012 17:39

Re: Semiclip + Autounstuck
 
PHP Code:

!(pev(player,pev_solid) & SOLID_NOT

...

Xalus 06-29-2012 07:48

Re: Semiclip + Autounstuck
 
Here you go:
Block Unstuck

PHP Code:

/* Credits: Arkshine for unstuck code */
 
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
 
#define PLUGIN "Hns Block Unstuck"
#define VERSION "1.0"
#define AUTHOR "Xalus"
 
#define GetPlayerHullSize(%1)  ( ( pev ( %1, pev_flags ) & FL_DUCKING ) ? HULL_HEAD : HULL_HUMAN )
#define Classname_Block "iZeek_Block"
#define START_DISTANCE  32
#define MAX_ATTEMPTS    128
 
new Float:plDelay[33]
 
public 
plugin_init() 
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
// Register: Ham
 
RegisterHam(Ham_Touch"info_target""Ham_TouchBlock")
}
public 
Ham_TouchBlock(entid)
{
 if(
pev_valid(ent) && is_user_alive(id))
 {
  static 
szClass[32]
  
pev(entpev_classnameszClasscharsmax(szClass))
 
  new 
Float:get_gt get_gametime()
 
  if(
equal(szClassClassname_Block)
  && 
plDelay[id] < get_gt)
  {
   new 
Float:plOrigin[3]
   
pev(idpev_originplOrigin)
   if(!
is_hull_vacant(plOriginGetPlayerHullSize(id), id) && !get_user_noclip(id))
   {
    
UTIL_UnstickPlayer(idSTART_DISTANCEMAX_ATTEMPTS)
   }
   
plDelay[id] = get_gt 1.0
  
}
 }
}
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))
  return 
true
 
 
return false

/* Unstuck
 - By Arkshine
*/
UTIL_UnstickPlayer ( const id, const i_StartDistance, const i_MaxAttempts )
{
 
// --| Not alive, ignore.
 
if ( !is_user_alive id ) )  return -1
 
 
static Float:vf_OriginalOrigin], Float:vf_NewOrigin];
 static 
i_Attemptsi_Distance;
 
 
// --| Get the current player's origin.
 
pev idpev_originvf_OriginalOrigin );
 
 
i_Distance i_StartDistance;
 
 while ( 
i_Distance 1000 )
 {
  
i_Attempts i_MaxAttempts;
 
  while ( 
i_Attempts-- )
  {
   
vf_NewOrigin] = random_float vf_OriginalOrigin] - i_Distancevf_OriginalOrigin] + i_Distance );
   
vf_NewOrigin] = random_float vf_OriginalOrigin] - i_Distancevf_OriginalOrigin] + i_Distance );
   
vf_NewOrigin] = random_float vf_OriginalOrigin] - i_Distancevf_OriginalOrigin] + i_Distance );
 
   
engfunc EngFunc_TraceHullvf_NewOriginvf_NewOriginDONT_IGNORE_MONSTERSGetPlayerHullSize id ), id);
 
   
// --| Free space found.
   
if ( get_tr2 0TR_InOpen ) && !get_tr2 0TR_AllSolid ) && !get_tr2 0TR_StartSolid ) )
   {
    
// --| Set the new origin .
    
engfunc EngFunc_SetOriginidvf_NewOrigin );
    return 
1;
   }
  }
 
  
i_Distance += i_StartDistance;
 }
 
 
// --| Could not be found.
 
return 0;




All times are GMT -4. The time now is 06:08.

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