AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   7errors (https://forums.alliedmods.net/showthread.php?t=25132)

wouter 03-08-2006 13:08

7errors
 
i got 7 errors in this VERRY litle plugin
Code:
* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <fun> #define PLUGIN "recover_hp" #define VERSION "1.0" #define AUTHOR "wouter" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("Damage", "recover_hp", "be")     register_cvar("amxx_recoverhp", "1")     register_cvar("amxx_recoverhp_amount", "Float:fvalue = 0.5")         if ( ! get_cvar_num("amxx_recoverhp") )           return PLUGIN_HANDLED         new recover_amount = Float: get_cvar_float("amxx_recoverhp_amount")     new damage = read_data(2) // tag mismatch     new health = get_user_health(id) // undivined symbol "id"         public recover_hp(id) { // invalide expresion, asumed zero ; undifined symbol "recover_hp"         if ( health <= 100) {             set_user_health(id, health + damage*recover_amount); // undefined symbol "id" ; expresion has no effext ; expected token: ; but found } ; invalid expresion, asumed zero         }         else if (health >= 100) {             return PLUGIN_HANDLED         }     } }



http://forums.alliedmods.net/showthread.php?t=25082

Rixorster 03-08-2006 14:00

First of all, you cant put any other stuff expect register_ commands in plugin_init >_<
Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("Damage", "recover_hp", "be")     register_cvar("amxx_recoverhp", "1")     register_cvar("amxx_recoverhp_amount", "Float:fvalue = 0.5")   }
and then you gotta make some stuff which i cant remember or im just too tired to write now, i got fever >_>

VEN 03-08-2006 14:02

Quote:

Originally Posted by Rixorster
First of all, you cant put any other stuff expect register_ commands in plugin_init

That's incorrect.

1. missed "/" at the top.

2. register_cvar("amxx_recoverhp_amount", "Float:fvalue = 0.5") - what? just put "0.5"

3. new Float:recover_amount = get_cvar_float("amxx_recoverhp_amount")

4. new damage = read_data(2) - you can read data arguments only inside event-handlers

5. new health = get_user_health(id) - id isn't defined

6. recover_hp - declare that public function outside plugin_init

7. health < 100 and health >= 100

8. set_user_health(id, health + damage*recover_amount) - 2nd parameter must be integer, not a float value

9. plugin_init must return a value in your case, for example return PLUGIN_CONTINUE

Probably a bit more errors than you expected. ;)

wouter 03-08-2006 14:31

Quote:

Originally Posted by VEN
Quote:

Originally Posted by Rixorster
First of all, you cant put any other stuff expect register_ commands in plugin_init

That's incorrect.

1. missed "/" at the top.

==> copy/paste mistace :wink:

[ --<-@ ] Black Rose 03-08-2006 14:35

no copy/paste misstakes?:
ctrl+a (select all)
ctrl+c (copy)
ctrl+v (paste)

wouter 03-08-2006 14:54

i always select with the mouse then ctrl+c and ctrl+v :)

wouter 03-08-2006 14:58

Quote:

Originally Posted by VEN
4. new damage = read_data(2) - you can read data arguments only inside event-handlers

but wish is the correct way to get the dammage? because i was searching on this forum but i found like 100 differant ways(all not working) my latest try
Code:
public dmg(id){   new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)   if(attacker==id)   new damage = read_data(2) }

Zenith77 03-08-2006 15:55

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <fun> #define PLUGIN "recover_hp" #define VERSION "1.0" #define AUTHOR "wouter" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("Damage", "recover_hp", "be")       register_cvar("amxx_recoverhp", "1")     register_cvar("amxx_recoverhp_amount", "0.5")                   }   public recover_hp(id) {         new health = get_user_health(id);         new damage = read_data(2);         new recover_amount = get_cvar_num("amxx_recoverhp_amount");                  if ( health < 100) {             set_user_health(id, health + (damage*recover_amount)); // you need () for order of operations         } }

zenified :)

wouter 03-08-2006 15:56

Quote:

Originally Posted by Zenith77
zenified :)

:D will try this out soon

wouter 03-08-2006 16:13

it comiles and gives no errors in debug mode, gonne test it online in the weekend :), first some school :lol:


All times are GMT -4. The time now is 20:19.

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