AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   remove_entity crash (https://forums.alliedmods.net/showthread.php?t=194502)

rak 08-28-2012 22:09

remove_entity crash
 
hi :3 i don't know why this crash my HLDS;

PHP Code:

#include <amxmodx>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /remove""cmdRemove")
}

public 
cmdRemove(id) {
    
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED
    
    
new Ent find_ent_by_owner(-1"weapon_knife"id)
        
    
remove_entity(Ent)
        
    return 
PLUGIN_HANDLED
    


any idea?

thanks for reading :3

meTaLiCroSS 08-28-2012 22:15

Re: remove_entity crash
 
Why you're doing that, lol, that's not the right way for removing a weapon from the world. remove_entity doesn't work at the same way for every entity.

What are you trying to do?

rak 08-28-2012 23:45

Re: remove_entity crash
 
i try remove only the knife xD

edit: done xD

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "[R]ak"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /remove""cmdRemove")
}

public 
cmdRemove(id) {
    
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED
    
    ham_strip_weapon
(id"weapon_knife")
    
    return 
PLUGIN_HANDLED
    
}

stock ham_strip_weapon(id,weapon[]) {
    
    if(!
equal(weapon,"weapon_",7))
        return 
0
    
    
new wId get_weaponid(weapon)
    
    if(!
wId)
        return 
0
    
    
new wEnt
    
    wEnt 
find_ent_by_owner(-1"weapon_knife"id)
    
    if(!
wEnt) return 0;
    
    if(
get_user_weapon(id) == wId)
        
ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt)
    
    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt))
        return 
0
    
    ExecuteHamB
(Ham_Item_Kill,wEnt)
    
    
entity_set_int(idEV_INT_weaponsentity_get_int(idEV_INT_weapons) & ~(1<<wId));
    
    return 
1
    




All times are GMT -4. The time now is 05:52.

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