Raised This Month: $ Target: $400
 0% 

block player touch (distance)


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

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
 



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