Raised This Month: $ Target: $400
 0% 

[HL1] Hooking Keyvalue on entities not in gametype


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 11-02-2013 , 14:04   [HL1] Hooking Keyvalue on entities not in gametype
Reply With Quote #1

Hello, I am working on a plugin to add more support to my game for maps that were not originally meant for my game, HLDM maps are very popular in TFC as they are open world deathmatches, I am trying to hook all of the weapons that the engine drops (because no equivalent item is in the engine for this game) and implement the closest equivalent I can find.. the problem is, I cant seem to grab any entities other than those that are added to the game (weapon_grenade) and I do know for a fact that these entities are in the map (bsp file contains the entity info)

I am properly hooking the function in plugin_precache and can confirm that it is running, and it even sends my data to the logfile I specified, however it only works for entities that it would normally spawn.. is there any way to achieve what I am trying to do?

PHP Code:
public plugin_precache()
{
    
//
    
register_forward(FM_KeyValue"hook_KeyValue")
}

public 
hook_KeyValue(entIdkvd_id)
{
    
//
    
if(!pev_valid(entId))
        return 
FMRES_HANDLED;
    
    new 
className[64];
    
pev(entIdpev_classnameclassName63);
    
    if (
containi(className"weapon_") !=-1)
    {
        new 
model[64], Float:origin[3]
        
pev(entIdpev_modelmodelcharsmax(model));
        
pev(entIdpev_originorigin);
        
        
log_to_file("hldm.log""Found entity %s with model %s, location: {%f, %f, %f}"classNamemodelorigin[0], origin[1], origin[2])
    }
    return 
FMRES_IGNORED;

EDIT: I have achieved the value by using engine: http://forums.alliedmods.net/showthr...=205578&page=2

PHP Code:
public pfn_keyvalue(entid)
{
    new 
classname[32], key[32], value[32]
    
copy_keyvalue(classname31key31value31)

    if( (
equal(key"classname")) && (containi(value"weapon_") != -1) )
    {
        
log_to_file("hldm.log""Weapon_* Key: %s Value: %s"keyvalue);
        
//server_print("FOUND!")
        //DispatchKeyValue("classname", "func_wall")
    
}

how will I be able to use this to get ther other keyvalues on this entity? I am going to try and change the if to a while and hope for good results.
__________________
+|- KARMA Respectively


Last edited by HLM; 11-02-2013 at 14:39.
HLM is offline
 



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 23:15.


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