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

[SOLVED]remove (weapon) entity from player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 11-04-2013 , 07:11   [SOLVED]remove (weapon) entity from player
Reply With Quote #1

Hello! I am trying to remove an entity from a player so that they can pick up another of the same type.

The entity is weapon_handgrenade, and it is an aiment assigned to PlayerENT after they touch it (if it is drawn)

Here is what I tried to do:
PHP Code:
public Get_Weaponbits(id)
{
    
//
    
new weapons[32], num=0;
    
get_user_weapons(idweaponsnum)
    new 
weaps entity_get_int(idEV_INT_weapons);
    
client_print(0print_chat"%d weapons (EV = %d)"/* Where is %d?"*/numweaps//, get_weaponid("weapon_handgrenade"));    //returns 0, pointless
    
    
new Float:origin[3];
    
entity_get_vector(idEV_VEC_originorigin);
    
    new 
iEnt = -1;
    while( (
iEnt find_ent_in_sphere(iEntorigin0.0)) != 0)
    {
        
//
        
new classname[33], ownerFloat:location[3]
        
entity_get_string(iEntEV_SZ_classnameclassnamecharsmax(classname))
        
entity_get_vector(iEntEV_VEC_originlocation)
        
owner entity_get_edict(iEntEV_ENT_owner)
        
client_print(idprint_chat"%s %d"classnameowner);
        
        if(
equal(classname"weapon_handgrenade"))
        {
            
client_print(idprint_chat"TITS!");
            new 
flags entity_get_int(iEntEV_INT_flags)
            
entity_set_int(iEntEV_INT_flags, (flags FL_KILLME));
            
call_think(iEnt);
            
user_has_weapon(idHLW_HANDGRENADE0);
            
//remove_entity(iEnt);    //CRASH
        
}
        
//iEnt = find_ent_in_sphere(iEnt, origin, 0.0)
        
    
}

This is a test command I call to make sure my code works as expected, unfortunately, I have not found a way to actually REMOVE the entity from player, I can get it to not show up in the weaponbits, however the player still has weapon_handgrenade attached to them, and trying to remove_entity on it will simply crash the server. Help?

EDIT: I have made a workaround by adding a global float to keep track of when the entity is touched, setting EF_DRAW on it when its touched, and removing it after it is meant to respawn and using this method to achieve what I want (and superceding the call to prevent the player from gaining the entity)
__________________
+|- KARMA Respectively


Last edited by HLM; 11-04-2013 at 14:40. Reason: Found a solution
HLM 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 06:50.


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