AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how can I make a plugin (https://forums.alliedmods.net/showthread.php?t=51925)

Damir 02-26-2007 16:38

how can I make a plugin
 
how can I make a plugin how can I make a plugin when all players have 250 in heal ?

allenwr 02-26-2007 17:22

Re: how can I make a plugin
 
PHP Code:

#include <amxmodx>
#include <fun>
 
public plugin_ini() {
     
register_plugin("Allenwr","1.0","250 health")
     
register_event("ResetHUD","event_hud","b")
}
 
public 
event_hud(id) {
     if(!
is_user_alive(id))
         return 
PLUGIN_HANDEL;
     
     
set_user_health(id250)



stupok 02-26-2007 18:16

Re: how can I make a plugin
 
This may not be the right way to detect a player's spawn for your mod.

Fixed:

Code:
#include <amxmodx> #include <fun> public plugin_init() {     register_plugin("Plugin name", "1.0", "Author")     register_event("ResetHUD", "event_ResetHUD", "be") } public event_ResetHUD(id)     set_user_health(id, 250)

allenwr 02-26-2007 20:09

Re: how can I make a plugin
 
I am just doing a check on whether the user is alive or not, and what you did doesnt matter, it still works either way...

Hawk552 02-26-2007 21:40

Re: how can I make a plugin
 
Quote:

Originally Posted by allenwr (Post 446036)
I am just doing a check on whether the user is alive or not, and what you did doesnt matter, it still works either way...

It's actually quite important, you not only screwed up on plugin_init (called it plugin_ini, something the compiler wouldn't catch), but also on the return (where you not only screwed up on the typing, but the value itself too).

Don't return PLUGIN_HANDLED in ResetHUD. It blocks the event and probably crashes the server. At the very best, bad things can happen.

allenwr 02-26-2007 21:42

Re: how can I make a plugin
 
I learned something... and the plugin_ini, my bad... typing and not reading.

XxAvalanchexX 02-26-2007 21:42

Re: how can I make a plugin
 
The return value in a register_event hook is ignored.

Hawk552 02-26-2007 21:46

Re: how can I make a plugin
 
Quote:

Originally Posted by XxAvalanchexX (Post 446065)
The return value in a register_event hook is ignored.

I'm reasonably sure that the event can be blocked by returning PLUGIN_HANDLED. Either way, the plugin_ini typo was important.

XxAvalanchexX 02-26-2007 22:15

Re: how can I make a plugin
 
It's register_message that can be blocked.

Damir 02-27-2007 06:25

Re: how can I make a plugin
 
how can I so make a plugin when only admins have 250 in heal ??


All times are GMT -4. The time now is 00:45.

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