Raised This Month: $ Target: $400
 0% 

How to move an entity?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FakeNick
Senior Member
Join Date: Feb 2008
Location: Poland
Old 08-22-2008 , 10:02   How to move an entity?
Reply With Quote #1

Hi!
I have another problem .
My friend request plugin, that it create's an weapon (on the ground) on maps, but i have a problem.
How i can move entity for example to CT's spawn or to hard to reach place?
I've used search but i can't find .
__________________


[||||||||||] Snowball war v3.05

Pol
ish translations here ;) (PM me if you want one).


FakeNick is offline
Howdy!
Senior Member
Join Date: Feb 2007
Old 08-22-2008 , 10:21   Re: How to move an entity?
Reply With Quote #2

There is already plugin that removes guns created by the map. ;)
__________________
[IMG]http://img221.**************/img221/5608/howdyfinnishhq2.jpg[/IMG]
Howdy! is offline
FakeNick
Senior Member
Join Date: Feb 2008
Location: Poland
Old 08-22-2008 , 10:40   Re: How to move an entity?
Reply With Quote #3

Yep, i know it, but i want to know how to move entity ;>.
__________________


[||||||||||] Snowball war v3.05

Pol
ish translations here ;) (PM me if you want one).


FakeNick is offline
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 08-22-2008 , 12:40   Re: How to move an entity?
Reply With Quote #4

I would also like to know this.

This is my failed attempt, everything that happens when you aim at
a entity and press '+ent_grab' it only comes up the message, nothing more.

I would be very pleased if someone would create/edit a script so it works with entity. I haven't spent so much time tried fixing this though.
And yes I'm aware of the 'resetHud' event, so don't mention anything about it.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define MIN_DIST    70.0
#define THROW_POWER    1500

#define MAX_PLAYERS    32
#define MAX_LENGTH    32

new grab[MAX_PLAYERS 1];
new 
Float:grabdistance[MAX_PLAYERS 1];
new 
bool:grabsearch[MAX_PLAYERS 1];

public 
plugin_init()
{
    
register_plugin("Entity Grab""1.0""[A]tomen");
    
    
register_clcmd("+grab_ent""ent_grab_on"ADMIN_KICK);
    
register_clcmd("-grab_ent""ent_grab_off"ADMIN_KICK);
    
    
register_event("DeathMsg""deathmsg""a");
    
register_event("ResetHUD""resethud""be");
}

public 
ent_grab_on(idlevelcid)
{
    if(!
cmd_access(idlevelcid1)) 
        return 
1;
    
    
grabsearch[id] = true;
    return 
1;
}

public 
ent_grab_off(idlevelcid)
{
    if(!
cmd_access(idlevelcid1)) 
        return 
1;
    
    
grabsearch[id] = false;
    
grab[id] = false;
    
    return 
1;
}

public 
grab_ent(ident)
{
    
grab[id] = ent;
    
grabsearch[id] = false;

    static 
Float:origin[2][3];

    
pev(idpev_originorigin[0]);
    
pev(entpev_originorigin[1]);

    
grabdistance[id] = get_distance_f(origin[0], origin[1]);

    
client_print(idprint_chat"[AMXX] You grabbed a func_breakable");
}

public 
is_ent_grabbed(ent)
{
    for(new 
i<= MAX_PLAYERSi++)
    {
        if(
grab[i] == ent)
            return (
i+1);
    }

    return -
1;
}

public 
client_PreThink(id)
{
    new 
buttons pev(idpev_button);
    
    if(
grabsearch[id])
    {
        new 
aimidaimbody;

        if(
get_user_aiming(idaimidaimbody) && aimid)
        {
            static 
classname[MAX_LENGTH 1];
            
pev(aimidpev_classnameclassnameMAX_LENGTH);

            if(
equal(classname"func_breakable"))
            {
                if(
is_ent_grabbed(aimid) == -1)
                    
grab_ent(idaimid);

                else
                {
                    
client_print(idprint_chat"[AMXX] The Entity is already Grabbed")
                    
grabsearch[id] = false;
                }
            }
        }
    }
    
    if(
grab[id])
    {
        static 
Float:origin[2][3], ilook[3], Float:look[3];
        static 
Float:direction[3], Float:moveto[3], Float:grabbedorigin[3];

        static 
Float:velocity[3], Float:length;

        
get_user_origin(idilook3);
        
IVecFVec(ilooklook);

        
pev(grab[id], pev_origingrabbedorigin);

        
pev(idpev_originorigin[0]);
        
pev(grab[id], pev_origin,origin[1]);

        
direction[0] = look[0] - origin[0][0];
        
direction[1] = look[1] - origin[0][1];
        
direction[2] = look[2] - origin[0][2];

        
length get_distance_f(lookorigin[0]);

        if(!
length)
            
length 1.0;

        
moveto[0] = origin[0][0] + direction[0] * grabdistance[id];
        
moveto[1] = origin[0][1] + direction[1] * grabdistance[id];
        
moveto[2] = origin[0][2] + direction[2] * grabdistance[id];

        
velocity[0] = (moveto[0] - origin[1][0]) * 8;
        
velocity[1] = (moveto[1] - origin[1][1]) * 8;
        
velocity[2] = (moveto[2] - origin[1][2]) * 8;

        
set_pev(grab[id], pev_velocityvelocity);

        if(
buttons IN_ATTACK)
        {
            
set_pev(idpev_buttonbuttons & ~IN_ATTACK);
            
grabdistance[id] += 7;
        }

        else if(
buttons IN_ATTACK2)
        {
            
set_pev(idpev_buttonbuttons & ~IN_ATTACK2);
            
grabdistance[id] -= 7;

            if(
grabdistance[id] < MIN_DIST)
                
grabdistance[id] = MIN_DIST;
        }

        else if(
buttons IN_JUMP)
        {
            
set_pev(idpev_buttonbuttons & ~IN_JUMP);
            
            
velocity_by_aim(idTHROW_POWERvelocity);
            
set_pev(grab[id], pev_velocityvelocity);
            
            
grab[id] = 0;
        }
    }
    
    if(
is_ent_grabbed(id) != -1)
        
set_pev(idpev_buttonbuttons & ~IN_MOVELEFT & ~IN_MOVERIGHT & ~IN_FORWARD & ~IN_BACK & ~IN_JUMP);
}

public 
deathmsg()
{
    new 
attacker    read_data(1);

    
grab[attacker] = false;
    
grabsearch[attacker] = false;
}

public 
resethud(id)
{
    
grab[id] = false;
    
grabsearch[id] = false;
}

public 
client_disconnect(id)
{
    
grabsearch[id] = false;
    
grab[id] = false;
}

public 
client_putinserver(id)
{
    
grabsearch[id]    = false;
    
grab[id]    = false;

Here's one of my older attempts: http://forums.alliedmods.net/showthread.php?t=71893

NOTE:
My script isn't supposed to teleport the entity by origin, if you meant that.
__________________
atomen is offline
Send a message via MSN to atomen
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-22-2008 , 13:25   Re: How to move an entity?
Reply With Quote #5

Partial code from my KZ plugin:
PHP Code:
new bool:iPlayerGrab_On[33]

new 
iPlayerGrab_Target[33]
new 
iPlayerGrab_Grabber[33]

new 
Float:fPlayerGrab_ChokeTime[33]
new 
Float:fPlayerGrab_Distance[33]

public 
fwGrabPlayerPreThink(id,iButtons)
{
    new 
entTarget iPlayerGrab_Target[id]

    if( !
entTarget || !is_user_alive(id) )
        return 
FMRES_IGNORED

    
if( iButtons IN_GRAB_CHOKE)
    {
        new 
Float:fNow get_gametime()
        
        if( 
fNow fPlayerGrab_ChokeTime[id] >= GRAB_CHOKE_INTERVAL)
        {
            
ExecuteHamB(Ham_TakeDamageentTarget00GRAB_CHOKE_DMGDMG_ALWAYSGIB)
            
fPlayerGrab_ChokeTime[id] = fNow

            
return
        }
    }
    
    static 
Float:vVelocity[3]
    if( 
iButtons IN_GRAB_THROW)
    {
        
velocity_by_aim(id1000vVelocity)
        
set_pev(entTargetpev_velocityvVelocity)

        
GrabEndCommand(id)

        return
    }

    if( 
iButtons IN_GRAB_PUSH)
        
fPlayerGrab_Distance[id] = floatmax(fPlayerGrab_Distance[id] - 7.0GRAB_MIN_DISTANCE)
    if( 
iButtons IN_GRAB_PULL)
        
fPlayerGrab_Distance[id] += 7.0

    
static Float:vPlayerOrigin[3], Float:vGrabbedOrigin[3]
    
pev(idpev_originvPlayerOrigin)
    
pev(entTargetpev_originvGrabbedOrigin)

    static 
Float:vAimVector[3]
    
pev(idpev_view_ofsvAimVector)
    
xs_vec_add(vPlayerOriginvAimVectorvPlayerOrigin)

    
pev(idpev_v_anglevAimVector)
    
angle_vector(vAimVector,1,vAimVector)
    
    
xs_vec_mul_scalar(vAimVectorfPlayerGrab_Distance[id], vAimVector);
    
xs_vec_add(vPlayerOriginvAimVectorvPlayerOrigin)

    
vVelocity[0] = (vPlayerOrigin[0] - vGrabbedOrigin[0]) * 8
    vVelocity
[1] = (vPlayerOrigin[1] - vGrabbedOrigin[1]) * 8
    vVelocity
[2] = (vPlayerOrigin[2] - vGrabbedOrigin[2]) * 8
    set_pev
(entTargetpev_velocityvVelocity)
}


public 
GrabStartCommand(id,level)
{
    if( (!
iPlayerGrab_On[id] && !access(idlevel) ) || !is_user_alive(id) )
    {
        return 
PLUGIN_HANDLED
    
}

    new 
Float:vAimOrigin[3]
    
fm_get_aim_origin(idvAimOrigin)

    new 
entTarget
    
if( !(entTarget engfunc(EngFunc_FindEntityInSphere0vAimOrigin32.0) )
        || 
entTarget == id
        
|| !is_user_alive(entTarget)
        || 
access(entTargetADMIN_IMMUNITY) && !access(id,ADMIN_IMMUNITY)
    )
    {
        return 
PLUGIN_HANDLED
    
}

    new 
Float:vPlayerOrigin[3], Float:vViewOfs[3]
    
pev(idpev_originvPlayerOrigin)
    
pev(idpev_view_ofsvViewOfs)
    
xs_vec_add(vPlayerOriginvViewOfsvPlayerOrigin)

    new 
Float:vTargetOrigin[3]
    
pev(entTargetpev_originvTargetOrigin)

    
fPlayerGrab_Distance[id] = vector_distance(vPlayerOriginvTargetOrigin)

    
iPlayerGrab_Target[id] = entTarget
    iPlayerGrab_Grabber
[entTarget] = id
    
    BeamEnts
(id 0x1000entTargetiBeamSprite)

    return 
PLUGIN_HANDLED
}


public 
GrabEndCommand(id)
{
    new 
entTarget iPlayerGrab_Target[id]
    if(
entTarget)
    {
        
iPlayerGrab_Grabber[entTarget] = 0
        iPlayerGrab_Target
[id] = 0
        fPlayerGrab_ChokeTime
[id] = 0.0

        BeamKill
(id 0x1000)
    }

danielkza is offline
Reply


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 03:10.


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