Raised This Month: $ Target: $400
 0% 

Can't make a eng2fm fakedamage function work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 07-15-2008 , 19:15   Can't make a eng2fm fakedamage function work
Reply With Quote #1

PHP Code:
stock DamagePlayer(iddamagedamageTypeorigin[3])
    {
    new 
entityengfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"trigger_hurt"))
    
    
//Damage
    
set_kvd(0KV_ClassName"trigger_hurt")
    
set_kvd(0KV_KeyName"dmg")
    
set_kvd(0KV_Valuedamage)
    
set_kvd(0KV_fHandled0)
    
dllfunc(DLLFunc_KeyValueentity0)
    
    
//Damage Type
    
set_kvd(1KV_ClassName"trigger_hurt")
    
set_kvd(1KV_KeyName"damagetype")
    
set_kvd(1KV_ValuedamageType)
    
set_kvd(1KV_fHandled0)
    
dllfunc(DLLFunc_KeyValueentity1)
    
    
//Origin
    
set_kvd(2KV_ClassName"trigger_hurt")
    
set_kvd(2KV_KeyName"origin")
    
set_kvd(2KV_Valueorigin)
    
set_kvd(2KV_fHandled0)
    
dllfunc(DLLFunc_KeyValueentity2)
    
    
//Spawn the entity
    
dllfunc(DLLFunc_Spawnentity)
    
    
//Touch entity and the player
    
dllfunc(DLLFunc_Touchentityid)
    
    
//Remove the entity
    
engfunc(EngFunc_RemoveEntityentity)
    } 
When I use it like this to make a player kill another (with gibs):
PHP Code:
DamagePlayer(targethealthDMG_ALWAYSGIB|DMG_ENERGYBEAMorigin
the game crashes, but I can't find which function makes it crash.
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 07-15-2008 , 22:12   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #2

When something crashes I put a server_print("passed whatever") beetween each suspect statements to figure out what is wrong.
danielkza is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 07-16-2008 , 16:45   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #3

PHP Code:
//From fakemeta_util.inc
stock fm_fakedamage(victim,const classname[],Float:takedmgdamage,damagetype)
{
    new 
classn[] = "trigger_hurt"
    
new entity engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,classn))
    if(!
entity) return 0
    
    
static value[16]
    
float_to_str((takedmgdamage 2),value,sizeof value 1)
    
fm_set_kvd(entity,"dmg",value,classn)

    
num_to_str(damagetype,value,sizeof value 1)
    
fm_set_kvd(entity,"damagetype",value,classn)

    
fm_set_kvd(entity,"origin","8192 8192 8192",classn)
    
dllfunc(DLLFunc_Spawn,entity)

    
set_pev(entity,pev_classname,classname)
    
    
dllfunc(DLLFunc_Touch,entity,victim)
    
    
engfunc(EngFunc_RemoveEntity,entity)

    return 
1
}


stock fm_set_kvd(entity,const key[],const value[],const classname[]="")
{
    if(
classname[0]) set_kvd(0,KV_ClassName,classname)
    else
    {
        new class[
32]
        
pev(entity,pev_classname,class,sizeof class - 1)
        
set_kvd(0,KV_ClassName,class)
    }

    
set_kvd(0,KV_KeyName,key)
    
set_kvd(0,KV_Value,value)
    
set_kvd(0,KV_fHandled,0)

    return 
dllfunc(DLLFunc_KeyValue,entity,0)

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-16-2008 , 18:00   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #4

fakemeta_util
__________________
Arkshine is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 07-17-2008 , 04:53   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #5

That doesn't cover everything I need. Maybe I should add a new parameter and build the origin string myself.
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-17-2008 , 04:56   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #6

What are you talking about ?! Oo
__________________
Arkshine is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 07-17-2008 , 06:24   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #7

This:
http://wiki.amxmodx.org/Half-Life_1_Game_Events#Damage

I want players to see where the shot came from.
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 07-17-2008 , 06:36   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #8

no but this does ->

This if you use fakedamage
PHP Code:
        fm_fakedamage(player,"classname",damage,3)
        
        
set_pev(player,pev_dmg_inflictor,ent)
        
set_pev(player,pev_dmg_save,0.0)
        
set_pev(player,pev_dmg_take,damage)
        
set_pev(player,pev_dmg,3)
            
        
emessage_begin(MSG_ONE,get_user_msgid("Damage"),{0,0,0},player)
        
ewrite_byte(0)
        
ewrite_byte(floatround(damage))
        
ewrite_long(3)
        
ewrite_coord(floatround(origin[0]))
        
ewrite_coord(floatround(origin[1]))
        
ewrite_coord(floatround(origin[2]))
        
emessage_end() 
I've tried to do the thing you said but it isn't possible to add origin since you fake touch the entity to the player ... so the damage comes from the inside.

But if you want to use hamsandwich (which is better)
This is the function that you need to use ->
PHP Code:
ExecuteHamB(Ham_TakeDamage,player,ent,pev(ent,pev_owner),damage,damagetype
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 07-17-2008 at 06:48.
ot_207 is offline
Shaman
Senior Member
Join Date: Dec 2006
Location: Istanbul, Turkey
Old 07-17-2008 , 11:29   Re: Can't make a eng2fm fakedamage function work
Reply With Quote #9

Thanks ot_207. This solved my problem:
PHP Code:
new entityengfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"trigger_hurt"))

ExecuteHamB(Ham_TakeDamagetargetentityid10000.0DMG_ENERGYBEAM|DMG_ALWAYSGIB)

engfunc(EngFunc_RemoveEntityentity
__________________
Shaman is offline
Send a message via ICQ to Shaman Send a message via AIM to Shaman Send a message via MSN to Shaman Send a message via Yahoo to Shaman
Reply



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 05:35.


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