Raised This Month: $ Target: $400
 0% 

block player touch (distance)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 06-11-2011 , 22:44   Re: block player touch (distance)
Reply With Quote #1

i used something like this
PHP Code:
public FwdTouch(ptrptd
{
    if(
pev_valid(ptr) && pev_valid(ptd))
    {
        static 
classname1[32], classname2[32];
        
pev(ptrpev_classnameclassname1sizeof(classname1) - 1);
        
pev(ptdpev_classnameclassname2sizeof(classname2) - 1);
        
        if( 
equali(classname1"player") && equali(classname2"player") )
        {
            new 
CsTeams:ptrTeam cs_get_user_team(ptr)
            new 
CsTeams:ptdTeam cs_get_user_team(ptd)
            if (
ptrTeam == ptdTeam)
            {
                new 
Float:y[2][3]
                
pevptrpev_originy[0] )
                
pevptdpev_originy[1] )
                new 
xg_playerpush get_cvar_num("amx_playerpush"
                for ( 
0;<= 2;x++ ) 
                {
                    
y[1][x] -= y[0][x]
                    
y[1][x] *= g_playerpush
                
}
                
set_pev(ptrpev_velocityy[1])
            }
        }
    }    

Exolent, can i make SOLID entity, like in walkgurad plugin, around player, and block team player touch?
but still i need to allow enemy player walk thru that entity?
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-12-2011 , 11:21   Re: block player touch (distance)
Reply With Quote #2

So you want to limit players from getting close to eachother ?

If you like it to be more awesome and feel like something that magnetically/magiacally rejects you, you should set velocity on the player, in the opposite direction.
You'll need to get direction from player to protected player (NOT player's moving direction), and multiply it by the negative direction, clamp it so it doesn't shoot players like bullets nor be too weak.
__________________
Hunter-Digital is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 06-12-2011 , 19:50   Re: block player touch (distance)
Reply With Quote #3

Quote:
Originally Posted by Hunter-Digital View Post
So you want to limit players from getting close to eachother ?

If you like it to be more awesome and feel like something that magnetically/magiacally rejects you, you should set velocity on the player, in the opposite direction.
You'll need to get direction from player to protected player (NOT player's moving direction), and multiply it by the negative direction, clamp it so it doesn't shoot players like bullets nor be too weak.
hm, i'm not so great in coding, but i still think, that they will need to touch, if i understand you, you are talking about register touch?
can you give me some example?
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-12-2011 , 20:24   Re: block player touch (distance)
Reply With Quote #4

Try something like this:

Code:
#include < amxmodx > #include < xs > #include < engine > public client_PreThink( iPlayer ) {     if( is_user_alive( iPlayer ) )     {         static iPlayers[ 32 ], iNum;         get_players( iPlayers, iNum, "ae", ( get_user_team( iPlayer ) == 1 ) ? "TERRORIST" : "CT" );                 new Float:vecPlayerOrigin[ 3 ];         entity_get_vector( iPlayer, EV_VEC_origin, vecPlayerOrigin );                 new Float:vecTeammateOrigin[ 3 ];                 static const MINIMUM_DISTANCE = 100.0;         new Float:flDistance;                 for( new i, iTeammate; i < iNum; i++ )         {             iTeammate = iPlayers[ i ];                         entity_get_vector( iTeammate, EV_VEC_origin, vecTeammateOrigin );                         if( ( flDistance = get_distance_f( vecPlayerOrigin, vecTeammateOrigin ) ) < MINIMUM_DISTANCE )             {                 xs_vec_sub( vecTeammateOrigin, vecPlayerOrigin, vecTeammateOrigin );                 xs_vec_normalize( vecTeammateOrigin, vecTeammateOrigin );                 xs_vec_mul_scalar( vecTeammateOrigin, ( MINIMUM_DISTANCE - flDistance ) * 5.0, vecTeammateOrigin );                                 entity_set_vector( iTeammate, EV_VEC_velocity, vecTeammateOrigin );             }         }     } }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 06-12-2011 , 20:40   Re: block player touch (distance)
Reply With Quote #5

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

const Float:AURA_RANGE = 100.0
const Float:AURA_STRENGTH = 10.0

new g_iMaxPlayers

public plugin_init()
    g_iMaxPlayers = get_maxplayers()

public client_putinserver(id)
    set_task(0.1, "player_aura", id)

public client_disconnect(id)
    remove_task(id)

public player_aura(id)
{
    new Float:fPlayerOrigin[3]

    entity_get_vector(id, EV_VEC_origin, fPlayerOrigin)

    for(new i = 1, Float:fDistance, Float:fOrigin[3]; i <= g_iMaxPlayers; i++)
    {
        if(is_user_alive(i))
        {
            entity_get_vector(id, EV_VEC_origin, fOrigin)

            fDistance = get_distance_f(fPlayerOrigin, fOrigin)

            if(fDistance >= AURA_RANGE)
                continue

            /* exolent's math from above post */

            xs_vec_sub(fOrigin, fPlayerOrigin, fOrigin)
            xs_vec_normalize(fOrigin, fOrigin)
            xs_vec_mul_scalar(fOrigin, (fDistance - AURA_RANGE) * -AURA_STRENGTH, fOrigin)

            entity_set_vector(i, EV_VEC_velocity, fOrigin)
        }
    }
}
Untested, math could be wrong xD
__________________

Last edited by Hunter-Digital; 06-15-2011 at 09:53. Reason: copied velocity math from exolent & fixed.
Hunter-Digital 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 23:33.


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