Raised This Month: $ Target: $400
 0% 

DeathMsg and damage problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hip_hop_x
Senior Member
Join Date: Apr 2006
Old 02-07-2007 , 13:43   DeathMsg and damage problems
Reply With Quote #1

Hello!

I have some problems with my plugin, DeatMsg and the Damage events doesn't work on half-life. Anyone knows how to make this to work or maybe another method?

the code:
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta_util> #define PLUGIN "The Hidden: Not Source" #define VERSION "0.4" #define AUTHOR "Hip_hop_x" new is_hidden[33] new g_maxplayers public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_event("DeathMsg", "event_DeathMsg", "b") register_event("Damage", "event_Damage", "b") } public event_Damage(victim) { new victim get_user_attacker(victim) new damage = read_data(2) new Float:extra_damage = damage / 100 * get_cvar_num("hidden_damage") if(is_hidden[victim]) {     fm_fakedamage(victim, "", extra_damage, DMG_ACID) } public event_DeathMsg() { new killer = read_data(1) new victim = read_data(2) new name[32] if ( is_hidden[victim] == 1 ) {     set_hudmessage(50, 205, 50, -1.0, 0.40, 2, 0.02, 4.0, 0.01, 0.1, 7)     show_hudmessage(0, "Hidden died! The new hidden is %s!", name)     is_hidden[killer] = 1 //killer is now the new hidden     is_hidden[victim] = 0 //victim is not hidden     get_user_name(killer, name, 31)     if ( ! victim )         return PLUGIN_HANDLED     } return PLUGIN_CONTINUE } //... the rest of code works.

Last edited by hip_hop_x; 02-07-2007 at 13:45.
hip_hop_x is offline
Send a message via MSN to hip_hop_x Send a message via Yahoo to hip_hop_x
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-07-2007 , 15:39   Re: DeathMsg and damage problems
Reply With Quote #2

Both of the events should work. Maybe this is why:

Code:
public event_Damage(victim) { new victim get_user_attacker(victim) new damage = read_data(2) new Float:extra_damage = damage / 100 * get_cvar_num("hidden_damage") if(is_hidden[victim]) {     fm_fakedamage(victim, "", extra_damage, DMG_ACID) }

1. Don't declare a new "victim" variable, it already exists (it's passed in the function header).
2. Why do you call get_user_attacker, if you don't use it?
3. Since extra_damage is a float, all variables involved in its calculations need to be a float. So it would become:

Code:
new Float:extra_damage = float(damage) / 100.0 * get_cvar_float("hidden_damage")

As for DeathMsg, it needs to be registered with the "a" flag instead of the "b" flag.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
hip_hop_x
Senior Member
Join Date: Apr 2006
Old 02-07-2007 , 17:17   Re: DeathMsg and damage problems
Reply With Quote #3

thank you:
1. I belived cause it's better to declare the victim again(but you are right)
2. I wanted to declare the attacker, but I did that in the rest of code
3. This was the problem, thank you very much. -ps- something doesn't work good, I'll pm you on msn.
4. The flag a to deathmsg fixed the deathmsg event.

------------------edited----------------------

XxAvalanchexX fixed my plugin, topic can be closed. Thank you xxAvalanchexx +karma because you fixed.

Last edited by hip_hop_x; 02-07-2007 at 17:34.
hip_hop_x is offline
Send a message via MSN to hip_hop_x Send a message via Yahoo to hip_hop_x
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-07-2007 , 17:21   Re: DeathMsg and damage problems
Reply With Quote #4

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta_util>

#define PLUGIN "The Hidden: Not Source"
#define VERSION "0.4"
#define AUTHOR "Hip_hop_x"

new is_hidden[33]
new 
g_maxplayers


public plugin_init() {
register_plugin(PLUGINVERSIONAUTHOR)

register_event("DeathMsg""event_DeathMsg""a")
register_event("Damage""event_Damage""b")
}

public 
event_Damage(victim) {
new 
victim
get_user_attacker
(victim)
new 
damage read_data(2)
new 
Float:extra_damage float(damage) / 100.0 get_cvar_float("hidden_damage")
if(
is_hidden[victim]) {
    
fm_fakedamage(victim""extra_damageDMG_ACID)
}

public 
event_DeathMsg() {
new 
killer read_data(1)
new 
victim read_data(2)
new 
name[32]
if ( 
is_hidden[victim] == ) {
    
set_hudmessage(5020550, -1.00.4020.024.00.010.17)
    
show_hudmessage(0"Hidden player died! The new hidden player is %s!"name)
    
is_hidden[killer] = //killer is now the new hidden player.
    
is_hidden[victim] = //victim is not hidden player, sorry.
    
get_user_name(killername31)
    if ( ! 
victim )
        return 
PLUGIN_HANDLED
    
}
return 
PLUGIN_CONTINUE

Phantom Warrior is offline
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 20:34.


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