AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_event("ResetHUD", ....... -resolved again (https://forums.alliedmods.net/showthread.php?t=45308)

stupok 09-28-2006 18:28

register_event("ResetHUD", ....... -resolved again
 
I get the following error when compiling this code:
Code:

(41) : error 035: argument type mismatch (argument 1)
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "ZombieAdder" #define VERSION "1.0" #define AUTHOR "Kamil" new g_pcvarzombies new g_pcvarzombiehp public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     g_pcvarzombies = register_cvar("addzombies", "25")     g_pcvarzombiehp = register_cvar("zombiehp", "300")     register_event("ResetHUD", "zombie_health", "e")         if(get_pcvar_num(g_pcvarzombies))         set_addzombies() } public set_addzombies() {     for (new i = 1; i <= get_pcvar_num(g_pcvarzombies); i++)     {         set_task(float(i) * 0.5, "addzombies")     } } public addzombies() {     server_cmd("addcustombot Zombie Domo 9.9") } public zombie_health(id) {     if(is_user_bot(id))     {         set_user_health(id, get_cvar_num(g_pcvarzombiehp))     }             return PLUGIN_CONTINUE }

XxAvalanchexX 09-28-2006 18:34

Re: register_event("ResetHUD", .......
 
The mismatch is coming from get_cvar_num. That is "old" way of getting a cvar's value, it expects a string argument that is the cvar's name, ie: get_cvar_num("zombiehp"). Since you are using cvar ids, use get_pcvar_num instead.

stupok 09-28-2006 18:44

Re: register_event("ResetHUD", .......
 
Thank you very much for the extremely fast and to the point reply.

It compiled with no errors. :up: :up:

stupok 09-28-2006 19:54

Re: register_event("ResetHUD", ....... -new issue
 
Bah, compiled with no errors but it doesn't do its job...

I'm trying to set all bots health to 300 or whatever the zombiehp cvar says. Is health supposed to be a float or an integer?

What am I doing wrong?

Emp` 09-28-2006 20:05

Re: register_event("ResetHUD", ....... -new issue
 
try
Code:

        register_event("ResetHUD", "zombie_health", "b")
:wink:

stupok 09-28-2006 21:52

Re: register_event("ResetHUD", ....... -new issue
 
Thank you so much for the quick reply Emp` I just finished having lots of fun in my server with this plugin now working :D :D :D

TheNewt 09-30-2006 00:28

Re: register_event("ResetHUD", ....... -resolved again
 
Code:
register_event("ResetHUD", "zombie_health", "e")
Code:
public zombie_health(id) {     if(is_user_bot(id)) {         set_user_health(id, get_cvar_num(g_pcvarzombiehp))     }     return PLUGIN_CONTINUE }

Won't this cuase it so that every time the Hud is reset, the npc will get his HP restored? O.o
Read this before using ResetHUD to make sure your using the correct event.
http://forums.alliedmods.net/showthread.php?t=42159
If I'm not mistaken, doesn't ResetHUD also activate even in the middle of the round? So wouldn't the 'zombies' heal in the middle of the round?
O.o

stupok 09-30-2006 14:12

Re: register_event("ResetHUD", ....... -resolved again
 
RestHUD is also called when using sv_restart <#> and when starting a demo recording, I don't know what you mean by "in the middle of a round." Anyway, this plugin is meant for TS (The Specialists) where there aren't any rounds to speak of, so that drops out. Also, I don't plan on recording a demo, but even if I would, I wouldn't mind having the bots' health be reset to the given value.

Just in case you were wondering, the purpose of the plugin is so that all of the bots or 'zombies' will spawn with a different amount of hp than 100 every time they spawn.

As far as I know, the plugin works flawlessly, except for the inconvenience that when you change the zombiehp cvar, the zombie won't receive the given amount of hp until it dies.


All times are GMT -4. The time now is 04:49.

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