AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need help with error (array index out of bounds) (https://forums.alliedmods.net/showthread.php?t=12040)

Zidd 04-03-2005 17:28

need help with error (array index out of bounds)
 
im having a problem with my plugin im getting this error message when i compile that says array index out of bounds and function must return a value can someone help me correct these errors see code below
Code:
//------------Source 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_BAN, " : Sets Vampire Mode") } public vampire (id) {         new makekill [32]     get_user_frags( id )     new health [32]     get_user_health( id ) // What Should Happen When You Reach 1 HP     if ( health [32] = 1 ) {     client_print (1,print_center,"You Thirst For Blood Go Get Some Kills For More HP!")     set_task (0.5,"vampire",id)     return PLUGIN_HANDLED     } //What Should Happen When You Have More Than 1 HP     if (health[32] < 1) {         set_user_health (id,(health[32] -1))         set_task (0.5,"vampire",id)         return PLUGIN_HANDLED             } //What Should Happen When You Get A Kill     if (makekill[32] +1) {         set_user_health (id,(health[32]+10))         client_print (1,print_center,"You Get 10HP For The Kill You Just Made")         set_task (0.5,"vampire",id)         return PLUGIN_HANDLED             }       }

johnjg75 04-03-2005 17:38

Code:
//------------Source 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_BAN, " : Sets Vampire Mode")   } public vampire (id) {           new makekill=get_user_frags( 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!")     set_task (0.5,"vampire",id)     return PLUGIN_HANDLED     } //What Should Happen When You Have More Than 1 HP     if (health < 1) {         set_user_health (id,(health-1))         set_task (0.5,"vampire",id)         return PLUGIN_HANDLED               } //What Should Happen When You Get A Kill     if (makekill +1) {         set_user_health (id,(health+=10))         client_print (1,print_center,"You Get 10HP For The Kill You Just Made")         set_task (0.5,"vampire",id)         return PLUGIN_HANDLED               }       return PLUGIN_HANDLED         }
but i don't think that's how you get the kill, lemme post another post in a sec showing how you do it

johnjg75 04-03-2005 17:55

Code:
//------------Source 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_BAN, " : 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!")     set_task (0.5,"vampire",id)     return PLUGIN_HANDLED     } //What Should Happen When You Have More Than 1 HP     if (health < 1) {         set_user_health (id,(health-1))         set_task (0.5,"vampire",id)         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 (id,print_center,"You Get 10HP For The Kill You Just Made")         set_task (0.5,"vampire",id)         return PLUGIN_HANDLED }
I haven't tested it and i'm not really sure what you're trying to do with set_task() but if you explain to me what this should do, then i can help you :)

Zidd 04-03-2005 18:17

well what i was trying to do was to have the players hp go down by 1 every time the script ran til they have 1 hp and have a message go on screen telling them that they need to make kills to gain hp and i was gonna have the script run through every .5 seconds since im kinda new to scripting i really dont know the ropes so i was thinking thats how it was done with the set_task thing but then again i could be in over my head


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

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