Raised This Month: $ Target: $400
 0% 

adding keys to an entity if a key is found, overwriting keys if they exist.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 07-06-2010 , 17:46   adding keys to an entity if a key is found, overwriting keys if they exist.
Reply With Quote #1

I have an entity, several entities actually.. all named "info_tfgoal" and certain entities have keynames "no_grenades_1" and "no_grenades_2" these keys tell how many of each type of grenade that entity will give a player, what I want to do is make a plugin that will find one of these entities and modify it by adding and updating several keys to it, so it will completely replenish health and armor and it will have a more unique sound..

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_SUPERCEDE;
}

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);

okay, my code works pretty well, it can find the packs, and it can update SOME of the keys, but not all of them, some all of them were missing the wait time, some were missing the noise..

edit: if its possible, id be okay with re-creating the entity, but I need to get the origin and angles of the entity before removing it
__________________
+|- KARMA Respectively


Last edited by HLM; 07-06-2010 at 18:05.
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 07:08.


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