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

[HL1] Hooking Keyvalue on entities not in gametype


Post New Thread Reply   
 
Thread Tools Display Modes
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
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2013 , 16:01   Re: [HL1] Hooking Keyvalue on entities not in gametype
Reply With Quote #2

Just don't filter key = "classname" and you gonna catch other properties.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 11-02-2013 , 20:32   Re: [HL1] Hooking Keyvalue on entities not in gametype
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Just don't filter key = "classname" and you gonna catch other properties.
Got it, thanks.

Solution:
PHP Code:
public pfn_keyvalue(entid)
{
    new class[
32], key[32], value[32]
    
copy_keyvalue(class, 31key31value31)
    
    
log_to_file("ents.log","ClassName : %s  KeyName : %s  KeyValue : %s",class, keyvalue)
    
    if(
containi(class, "weapon_")!=-1)
        
log_to_file("weapon.log","ClassName : %s  KeyName : %s  KeyValue : %s",class, keyvalue)
    if(
containi(class, "ammo_")!=-1)
        
log_to_file("ammo.log","ClassName : %s  KeyName : %s  KeyValue : %s",class, keyvalue)

__________________
+|- KARMA Respectively

HLM is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-02-2013 , 20:47   Re: [HL1] Hooking Keyvalue on entities not in gametype
Reply With Quote #4

You wanna change ground weapons ?
What do you want to do exactly ?
Sounds like x y problem.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 11-02-2013 , 22:36   Re: [HL1] Hooking Keyvalue on entities not in gametype
Reply With Quote #5

Yes, I am using hldm maps on my server, but my game doesnt have those weapons, I want to grab the info from the keyvalues and spawn the closest equivalent.. for example, weapon_shotgun -> tfc_wpn_supershotgun weapon_rpg -> tfc_wpn_rpg etc.

Please note: these entities are never created as the engine drops them because they do not exist in the game.

new question: I am using weapon_handgrenade to give users grenades, but only the first one they pick up disappears from the map, what controls them 'having' the grenade? I have tried many things but havent found anything yet. :/

PHP Code:
            if(equali(className"weapon_handgrenade"))
            {
                
//give nades or something
                
client_print(0print_chat"%d picked up a handgrenade"id);
                new 
nade1=tfc_getbammo(idTFC_AMMO_NADE1);
                new 
nade2=tfc_getbammo(idTFC_AMMO_NADE2);
                new class=
entity_get_int(idEV_INT_playerclass)
                if(
user_has_weapon(idHLW_HANDGRENADE))
                {
                    
client_print(0print_chat"User has grenade, removing.")
                    
user_has_weapon(idHLW_HANDGRENADE0)
                }
                
                if(class == 
2)
                    
nade2=9
                
if(nade1 nade2)
                {
                    
tfc_setbammo(idTFC_AMMO_NADE2nade2+1)
                    
client_print(0print_chat"nade1=%d NADE2=%d"tfc_getbammo(idTFC_AMMO_NADE1), tfc_getbammo(idTFC_AMMO_NADE2))
                }
                else
                {
                    
tfc_setbammo(idTFC_AMMO_NADE1nade1+1)
                    
client_print(0print_chat"NADE1=%d nade2=%d"tfc_getbammo(idTFC_AMMO_NADE1), tfc_getbammo(idTFC_AMMO_NADE2))
                }
            } 
__________________
+|- KARMA Respectively

HLM is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-03-2013 , 02:43   Re: [HL1] Hooking Keyvalue on entities not in gametype
Reply With Quote #6

So, you could use that : http://forums.alliedmods.net/showthread.php?p=1647630
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 02:23.


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