AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bad Load on plugin (https://forums.alliedmods.net/showthread.php?t=12080)

Zidd 04-04-2005 18:05

Bad Load on plugin
 
im getting a bad load on my plugin and i dont know whats wrong
Code:
//Vampire Mod //By Zidd //A Version Half-life engine version of an unreal tournament mutator #include <amxmodx> #include <amxmisc> #include <fun> public plugin_init () {     register_plugin("Vampire Mode","0.01","Zidd")     register_clcmd("amx_vampire", "vampire",  ADMIN_LEVEL_A, " : Sets Vampire Mode")     register_event("deathmsg","deathmsge","a") } public vampire (id) {         new health=get_user_health( id ) // What Should Happen When You Reach 1 HP     if ( health == 1 ) {     client_print (1,print_center,"You Thirst For Blood Go Get Some Kills For More HP!")     return PLUGIN_HANDLED     } //What Should Happen When You Have More Than 1 HP     if (health < 1) {         set_user_health (id,(health -=1))         return PLUGIN_HANDLED       }     return PLUGIN_HANDLED } public deathmsge () {     new id = read_data( 1 ) ;     new health = get_user_health ( id )  ;     set_user_health ( id,(health += 10))     client_print(1,print_center,"Your Victims Blood Gets You 10 HP")     return PLUGIN_HANDLED }

knekter 04-04-2005 19:38

Code:
register_event("DeathMsg", "deathmsge", "a")

Zidd 04-04-2005 20:47

i dont get a bad load anymore but the plugin dosent work can someone see whats wrong with the code? ive got all the modules enabled on the test server
Code:
//Vampire Mod //By Zidd //A Version Half-life engine version of an unreal tournament mutator #include <amxmodx> #include <amxmisc> #include <fun> public plugin_init () {     register_plugin("Vampire Mode", "0.01", "Zidd")     register_clcmd("amx_vampire", "vampire",  ADMIN_LEVEL_A, " : Sets Vampire Mode")     register_event("deathmsg", "deathmsge", "a") } public vampire (id) {         new health=get_user_health( id ) // What Should Happen When You Reach 1 HP     if ( health == 1 ) {     client_print (1, print_center, "You Thirst For Blood Go Get Some Kills For More HP!")     return PLUGIN_HANDLED     } //What Should Happen When You Have More Than 1 HP     if (health < 1) {         set_user_health (id,(health -=1))         return PLUGIN_HANDLED       }     return PLUGIN_HANDLED } public deathmsge () {     new id = read_data( 1 ) ;     new health = get_user_health ( id )  ;     set_user_health ( id,(health += 10))     client_print (1, print_center, "Your Victims Blood Gets You 10 HP")     return PLUGIN_HANDLED }

xeroblood 04-04-2005 21:19

I always thought that the Event names were Case-Sensitive, but I could be wrong..

Either way, you should change:
Code:
register_event("deathmsg", "deathmsge", "a") //to register_event("DeathMsg", "deathmsge", "a")


Anyway, apart from that, in your DeathMsg function:
Code:
new id = read_data( 1 ) ; // should be: new id = read_data( 2 ) ;

And, you are trying to give health back to the dead player, which isn't going to happen.. he is already dead.. You want to give health to the attacker who killed him, so you could try:
Code:
new iAttackerID = get_user_attacker( id )

Oh, and you should make sure that the victim and attacker are valid players:
Code:
if( !is_user_connected(id) )     return PLUGIN_CONTINUE

So overall, your DeathMsg function should look like:
Code:
public deathmsge () {     new id = read_data( 2 );     if( !is_user_connected(id) )         return PLUGIN_CONTINUE     new iAttackerID = get_user_attacker( id )     if( !is_user_connected(iAttackerID) )         return PLUGIN_CONTINUE     new health = get_user_health ( iAttackerID );     set_user_health ( iAttackerID, health + 10 )     client_print ( iAttackerID, print_center, "Your Victims Blood Gets You 10 HP")     // DONT return PLUGIN_HANDLED from hooked events!     return PLUGIN_CONTINUE }

Oh, and your vampire() function is completely useless as it is, and I don't know what you wanted to do with it, but it is logically messed up!! No offense..

Anyway, I hope that helps!

Zidd 04-05-2005 18:29

the point of the vampire function was to make peoples health continuoulsly go down til they reach 1 hp then it would stop and say something that was the point of it i dont know if i did it right tho


All times are GMT -4. The time now is 09:56.

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