AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player Out Of Range (https://forums.alliedmods.net/showthread.php?t=55864)

Jenger 05-31-2007 20:06

Player Out Of Range
 
I edited the original topic, because I fixed the first, but here's the current problem.

In this code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

public SyphonHealth(Victim)
{
new Attacker = get_user_attacker(Victim);
new Health = get_user_health(Attacker);
new Damage = read_data(2);
if (Attacker) {
set_user_health(Attacker, (Health+Damage));
set_hudmessage(200, 0, 0, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, 7);
show_hudmessage(Attacker,"%i+ (%i)", Damage, Health+Damage);
}
return PLUGIN_CONTINUE;
}

public plugin_init() {
register_plugin("Syphon Health", "1.0", "Jengerer");
register_event("Damage", "SyphonHealth", "b", "2!0", "4!0", "2!1");
return PLUGIN_CONTINUE;
}


When I run the map, if I kill someone with a grenade, the plugin crashes.

regalis 05-31-2007 22:32

Re: Player Out Of Range
 
Why don't you use [C O D E]-tags to format your code?
Its pain in the eyes to read that..0o

and i think you should keep an eye on this
Code:

    register_event("Damage", "SyphonHealth", "b", "2!0", "4!0", "2!1");
Why 4!0 ?
Why two times parameter 2?


Quote:

1: Damage Save (armor), 2: Damage Take (health), 3: Damage Type, 4: X, 5: Y, 6: Z
greetz regalis

Sylwester 06-01-2007 08:18

Re: Player Out Of Range
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

new g_max_players

public plugin_init() {
    
register_plugin("Syphon Health""1.0""Jengerer")
    
register_event("Damage""SyphonHealth""b""2!0")
    
g_max_players get_maxplayers()
}

public 
SyphonHealth(Victim) {
    if( 
Victim || Victim g_max_players)  //check if Victim is a valid player id
        
return PLUGIN_CONTINUE

    
new Attacker get_user_attacker(Victim)
    if( 
Attacker || Attacker g_max_players//check if Attacker is a valid player id
        
return PLUGIN_CONTINUE

    
new Health get_user_health(Attacker)
    new 
Damage read_data(2)

    if (
Attacker) {
        
set_user_health(Attacker, (Health+Damage));
        
set_hudmessage(20000, -1.00.5520.14.00.020.027);
        
show_hudmessage(Attacker,"%i+ (%i)"DamageHealth+Damage);
    }
    return 
PLUGIN_CONTINUE




All times are GMT -4. The time now is 10:41.

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