Raised This Month: $7 Target: $400
 1% 

Properly emulate weapon drop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
gabuch2
AlliedModders Donor
Join Date: Mar 2011
Location: Chile
Old 03-31-2020 , 00:05   Properly emulate weapon drop
Reply With Quote #1

Hello, I want to emulate a "weaponbox" drop, (like when you press the G key when holding a weapon) using a particular item.

I tried to emulate the drop function in HLSDK but I'm not good with vectors.

This is the code I tried so far.

Code:
public drop_jp(id) {     if(g_bHasJP[id])     {         if(pev_valid(g_iWClientJP[id]))             engfunc(EngFunc_RemoveEntity, g_iWClientJP[id]);         new Float:fOrigin[3], Float:fNewOrigin[3];         new jp = create_entity("item_security");         pev(id, pev_origin, fOrigin);         global_get(glb_v_forward, fNewOrigin);         xs_vec_mul_scalar(fNewOrigin, 300.0, fNewOrigin);         xs_vec_add(fOrigin, fNewOrigin, fOrigin);         set_pev(jp, pev_origin, fOrigin);         set_pev(jp, pev_velocity, fNewOrigin)         convertToJetpack(jp)         //DispatchKeyValue(jp, "spawnflags", "384");         DispatchSpawn(jp);     }         g_bHasJP[id] = false;     return PLUGIN_HANDLED; }

It works, but the item just pops out near player instead of dropping it like a normal weapon.

How can I achieve this?
__________________

Last edited by gabuch2; 03-31-2020 at 00:05.
gabuch2 is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 03-31-2020 , 08:56   Re: Properly emulate weapon drop
Reply With Quote #2

PHP Code:
    set_pev(g_iJetPackEntityID[id], pev_solidSOLID_TRIGGER)
    
set_pev(g_iJetPackEntityID[id], pev_movetypeMOVETYPE_TOSS)
    new 
Float:fOrigin[3], Float:fVelocity[3];
    
    
pev(idpev_originfOrigin)
    
set_pev(g_iJetPackEntityID[id], pev_originfOrigin)
    
    
pev(idpev_anglesfOrigin)
    
fOrigin[0] = 0.0;
    
set_pev(g_iJetPackEntityID[id], pev_anglesfOrigin)
    
    
velocity_by_aim(id250fOrigin)
    
pev(idpev_velocityfVelocity)
    
    
fVelocity[0] += fOrigin[0];
    
fVelocity[1] += fOrigin[1];
    
fVelocity[2] += fOrigin[2];
    
    
set_pev(g_iJetPackEntityID[id], pev_velocityfVelocity
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
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 00:08.


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