Raised This Month: $ Target: $400
 0% 

Pushing someone away


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Speed!
BANNED
Join Date: Jan 2009
Old 02-13-2009 , 12:33   Pushing someone away
Reply With Quote #1

Ok i got cords of somewhere, i wanna make that when someone is near that cords, to be pushed away
how should i do?
i have some idea, but its not right at all
Speed! is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-13-2009 , 12:40   Re: Pushing someone away
Reply With Quote #2

Code:
// minimum radius for player to be pushed away #define PUSH_RADIUS 200.0 // maximum speed for player to be pushed away // (maximum speed will be used if player is closest to the origin, otherwise it is proportional to the player's distance) #define PUSH_SPEED 500.0 PushPlayer(client, const Float:center[3]) {     new Float:origin[3];     pev(client, pev_origin, origin);         new Float:dist = get_distance_f(origin, center);     if( dist > PUSH_RADIUS ) return;         new Float:speed = (1.0 - (dist / PUSH_RADIUS)) * PUSH_SPEED;         new Float:velocity[3];     velocity[0] = origin[0] - center[0];     velocity[1] = origin[1] - center[1];     velocity[2] = origin[2] - center[2];         new Float:length = vector_length(velocity);         velocity[0] = velocity[0] / length * speed;     velocity[1] = velocity[1] / length * speed;     velocity[2] = velocity[2] / length * speed;         new Float:current[3];     pev(client, pev_velocity, current);         current[0] += velocity[0];     current[1] += velocity[1];     current[2] += velocity[2];         set_pev(client, pev_velocity, current); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Speed!
BANNED
Join Date: Jan 2009
Old 02-13-2009 , 12:53   Re: Pushing someone away
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Code:
// minimum radius for player to be pushed away #define PUSH_RADIUS 200.0 // maximum speed for player to be pushed away // (maximum speed will be used if player is closest to the origin, otherwise it is proportional to the player's distance) #define PUSH_SPEED 500.0 PushPlayer(client, const Float:center[3]) {     new Float:origin[3];     pev(client, pev_origin, origin);         new Float:dist = get_distance_f(origin, center);     if( dist > PUSH_RADIUS ) return;         new Float:speed = (1.0 - (dist / PUSH_RADIUS)) * PUSH_SPEED;         new Float:velocity[3];     velocity[0] = origin[0] - center[0];     velocity[1] = origin[1] - center[1];     velocity[2] = origin[2] - center[2];         new Float:length = vector_length(velocity);         velocity[0] = velocity[0] / length * speed;     velocity[1] = velocity[1] / length * speed;     velocity[2] = velocity[2] / length * speed;         new Float:current[3];     pev(client, pev_velocity, current);         current[0] += velocity[0];     current[1] += velocity[1];     current[2] += velocity[2];         set_pev(client, pev_velocity, current); }
Speed! is offline
Speed!
BANNED
Join Date: Jan 2009
Old 02-13-2009 , 13:10   Re: Pushing someone away
Reply With Quote #4

doesent work for me :S
im using this
PHP Code:
public PushPlayer(const Float:center[3])
{    
    static 
client
    
for (client 1client <= g_maxplayersclient++)
    {
        new 
Float:origin[3];
        
pev(clientpev_originorigin);
        
        new 
Float:dist get_distance_f(origincenter);
        if( 
dist PUSH_RADIUS ) return;
        
        new 
Float:speed = (1.0 - (dist PUSH_RADIUS)) * PUSH_SPEED;
        
        new 
Float:velocity[3];
        
velocity[0] = origin[0] - center[0];
        
velocity[1] = origin[1] - center[1];
        
velocity[2] = origin[2] - center[2];
            
        new 
Float:length vector_length(velocity);
        
        
velocity[0] = velocity[0] / length speed;
        
velocity[1] = velocity[1] / length speed;
        
velocity[2] = velocity[2] / length speed;
            
        new 
Float:current[3];
        
pev(clientpev_velocitycurrent);
        
        
current[0] += velocity[0];
        
current[1] += velocity[1];
        
current[2] += velocity[2];
        
        
set_pev(clientpev_velocitycurrent);
    }

Speed! is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 02-13-2009 , 14:06   Re: Pushing someone away
Reply With Quote #5

Look You can use this but you need to add the distance.
Attached Files
File Type: sma Get Plugin or Get Source (pruba_empujon.sma - 376 views - 1.2 KB)
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-13-2009 , 14:35   Re: Pushing someone away
Reply With Quote #6

Quote:
Originally Posted by Speed! View Post
doesent work for me :S
That is because you are doing a "return" instead of a "continue" when a player is too far away:
PHP Code:
        if( dist PUSH_RADIUS ) return; 
PHP Code:
public PushPlayer(const Float:center[3])
{    
    static 
client
    
for (client 1client <= g_maxplayersclient++)
    {
        new 
Float:origin[3];
        
pev(clientpev_originorigin);
        
        new 
Float:dist get_distance_f(origincenter);
        if( 
dist PUSH_RADIUS ) continue;
        
        new 
Float:speed = (1.0 - (dist PUSH_RADIUS)) * PUSH_SPEED;
        
        new 
Float:velocity[3];
        
velocity[0] = origin[0] - center[0];
        
velocity[1] = origin[1] - center[1];
        
velocity[2] = origin[2] - center[2];
            
        new 
Float:length vector_length(velocity);
        
        
velocity[0] = velocity[0] / length speed;
        
velocity[1] = velocity[1] / length speed;
        
velocity[2] = velocity[2] / length speed;
            
        new 
Float:current[3];
        
pev(clientpev_velocitycurrent);
        
        
current[0] += velocity[0];
        
current[1] += velocity[1];
        
current[2] += velocity[2];
        
        
set_pev(clientpev_velocitycurrent);
    }

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Speed!
BANNED
Join Date: Jan 2009
Old 02-13-2009 , 15:09   Re: Pushing someone away
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
That is because you are doing a "return" instead of a "continue" when a player is too far away:
PHP Code:
        if( dist PUSH_RADIUS ) return; 
PHP Code:
public PushPlayer(const Float:center[3])
{    
    static 
client
    
for (client 1client <= g_maxplayersclient++)
    {
        new 
Float:origin[3];
        
pev(clientpev_originorigin);
        
        new 
Float:dist get_distance_f(origincenter);
        if( 
dist PUSH_RADIUS ) continue;
        
        new 
Float:speed = (1.0 - (dist PUSH_RADIUS)) * PUSH_SPEED;
        
        new 
Float:velocity[3];
        
velocity[0] = origin[0] - center[0];
        
velocity[1] = origin[1] - center[1];
        
velocity[2] = origin[2] - center[2];
            
        new 
Float:length vector_length(velocity);
        
        
velocity[0] = velocity[0] / length speed;
        
velocity[1] = velocity[1] / length speed;
        
velocity[2] = velocity[2] / length speed;
            
        new 
Float:current[3];
        
pev(clientpev_velocitycurrent);
        
        
current[0] += velocity[0];
        
current[1] += velocity[1];
        
current[2] += velocity[2];
        
        
set_pev(clientpev_velocitycurrent);
    }

oh what a stupid i am
allthough i already solved it in a more fashin way (?)
im using engfunc(EngFunc_FindEntityInSphere
+k to all for helping
Speed! is offline
Speed!
BANNED
Join Date: Jan 2009
Old 02-13-2009 , 15:37   Re: Pushing someone away
Reply With Quote #8

I am getting tag mismatch on the set_task
PHP Code:
public PushPlayer(const Float:center[3])
{    
    
// Collisions
    
static victim
    victim 
= -1
    
new Floatconfigsforshield[4]
    
configsforshield[0] = center[0]
    
configsforshield[1] = center[1]
    
configsforshield[2] = center[2]
    while ((
victim engfunc(EngFunc_FindEntityInSpherevictimcenterNADE_EXPLOSION_RADIUS 100)) != 0)
    {
        if (!
g_zombie[victim])
            return
        new 
Float:origin[3];
        
pev(victimpev_originorigin);
        
        new 
Float:speed =  PUSH_SPEED;
        
        new 
Float:velocity[3];
        
velocity[0] = origin[0] - center[0];
        
velocity[1] = origin[1] - center[1];
        
velocity[2] = origin[2] - center[2];
            
        new 
Float:length vector_length(velocity);
        
        
velocity[0] = velocity[0] / length speed;
        
velocity[1] = velocity[1] / length speed;
        
velocity[2] = velocity[2] / length speed;
            
        new 
Float:current[3];
        
pev(victimpev_velocitycurrent);
        
        
current[0] += velocity[0];
        
current[1] += velocity[1];
        
current[2] += velocity[2];
        
        
set_pev(victimpev_velocitycurrent);
    }
    
set_task(0.2,"PushPlayer2"0,  configsforshield,3"a"25); 
}

public  
PushPlayer2(Floatconfigforshield[4])
{    
    
// Collisions
    
static victim
    victim 
= -1
    
static Floatcenter[4]
    
center[0] = configforshield[0]
    
center[1] = configforshield[1]
    
center[2] = configforshield[2]
    while ((
victim engfunc(EngFunc_FindEntityInSpherevictimcenterNADE_EXPLOSION_RADIUS 100)) != 0)
    {
        if (!
g_zombie[victim])
            return
        new 
Float:origin[3];
        
pev(victimpev_originorigin);
        
        new 
Float:speed =  PUSH_SPEED;
        
        new 
Float:velocity[3];
        
velocity[0] = origin[0] - center[0];
        
velocity[1] = origin[1] - center[1];
        
velocity[2] = origin[2] - center[2];
            
        new 
Float:length vector_length(velocity);
        
        
velocity[0] = velocity[0] / length speed;
        
velocity[1] = velocity[1] / length speed;
        
velocity[2] = velocity[2] / length speed;
            
        new 
Float:current[3];
        
pev(victimpev_velocitycurrent);
        
        
current[0] += velocity[0];
        
current[1] += velocity[1];
        
current[2] += velocity[2];
        
        
set_pev(victimpev_velocitycurrent);
    }

Speed! is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-13-2009 , 15:38   Re: Pushing someone away
Reply With Quote #9

Try this:

PHP Code:
set_task(0.2"PushPlayer2"0_:configsforshield3"a"25); 
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Speed!
BANNED
Join Date: Jan 2009
Old 02-13-2009 , 15:44   Re: Pushing someone away
Reply With Quote #10

Quote:
Originally Posted by Hawk552 View Post
Try this:

PHP Code:
set_task(0.2"PushPlayer2"0_:configsforshield3"a"25); 
Speed! 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:58.


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