Raised This Month: $ Target: $400
 0% 

recreating an entity?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 07-09-2010 , 19:22   recreating an entity?
Reply With Quote #1

I need an easy way to 1) get the 'origin', 'team_no' and 'angles' keys from an entity, save them temporarily, delete the entity, then rebuild it with specific keys?

I have made an attempt of just editing the entity as-is but all of the keys are not applied, so it wont always work as intended

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

#define PLUGIN "Spam Packs"
#define VERSION "1.0"
#define AUTHOR "Master"

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)    
    
// Add your code here...
}

public 
plugin_precache()
{
    
register_forward(FM_KeyValue"hook_KeyValue"1)
}

public 
hook_KeyValue(entIdkvdid)
{
    if(!
pev_valid(entId))
        return 
FMRES_HANDLED;
    
    new 
classname[64];
    
get_kvd(kvdidKV_ClassNameclassname63)    
    if(
equali(classname"info_tfgoal"))
    {
        new 
keyname[128]   
        new 
keydata[128]
        
get_kvd(kvdidKV_KeyNamekeyname127)
        
get_kvd(kvdidKV_Valuekeydata127)
        if(
containi(keyname"no_grenades") != -1)
        {
            
set_keyvalue(entId"no_grenades_1""4")
            
set_keyvalue(entId"no_grenades_2""4")
            
set_keyvalue(entId"health""100")
            
set_keyvalue(entId"armorvalue""300")
            
set_keyvalue(entId"message""Restocking Explosives.")
            
set_keyvalue(entId"noise""items/r_item1.wav")
            
set_keyvalue(entId"ammo_nails""200")
            
set_keyvalue(entId"ammo_rockets""100")
            
set_keyvalue(entId"ammo_cells""200")
            
set_keyvalue(entId"ammo_shells""200")
            
set_keyvalue(entId"wait""1")
            
set_keyvalue(entId"g_e""1")
            
set_keyvalue(entId"g_a""1")
        }
    }
    return 
FMRES_OVERRIDE;
}

stock set_keyvalue(entkey[], value[])
{
    new 
classname[32];
    
    
pev(entpev_classnameclassname31);
    
set_kvd(0KV_ClassNameclassname);
    
set_kvd(0KV_KeyNamekey);
    
set_kvd(0KV_Valuevalue);
    
set_kvd(0KV_fHandled0);
    
    
dllfunc(DLLFunc_KeyValueent0);

this is the code it used, some maps all the keys are set, other times, only the top X are set, can someone tell me how id store those keys and "recreate" the entity?

heres an example of one of the entities im working with:
Code:
{
"origin" "-1960 -2864 72"
"armorvalue" "300"
"health" "100"
"message" "Restocking Explosives."
"no_grenades_2" "4"
"ammo_medikit" "20"
"noise" "items/r_item1.wav"
"team_no" "2"
"no_grenades_1" "4"
"ammo_nails" "200"
"ammo_rockets" "100"
"ammo_cells" "200"
"ammo_shells" "200"
"wait" "1"
"mdl" "models/en/grenpack.mdl"
"g_e" "1"
"g_a" "1"
"classname" "info_tfgoal"
}
__________________
+|- KARMA Respectively

HLM is offline
 


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 07:11.


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