AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   DeathMsg and damage problems (https://forums.alliedmods.net/showthread.php?t=50944)

hip_hop_x 02-07-2007 13:43

DeathMsg and damage problems
 
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.

XxAvalanchexX 02-07-2007 15:39

Re: DeathMsg and damage problems
 
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.

hip_hop_x 02-07-2007 17:17

Re: DeathMsg and damage problems
 
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.

Phantom Warrior 02-07-2007 17:21

Re: DeathMsg and damage problems
 
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




All times are GMT -4. The time now is 00:42.

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