AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   double check source for starthp.sma (https://forums.alliedmods.net/showthread.php?t=28120)

oat 05-07-2006 14:58

double check source for starthp.sma
 
Starthp.amxx

This is my first plug-in. I’m not submitting it because it has already been made and a lot of the source is from the tutorial. So far I haven’t had any one on one help and nobody has double checked my source. I posted here because I would like suggestions before I continue scripting.


Thanks...

The AMXX Community for your...
Support of amateur scripters
Bailopen for your...
Amazing Tutorial & AMX Mod X Studio
Jonny Got His Gun for your...
Weapon Arena Plug-in & Inspiration
Team OAT for...
Letting me use their server to test
BDC (Blue Delusion Coders) for...
Inspiration and support
Bob Fincheimer for...
Inspiration
Everybody else I forgot! Sorry!

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "StartHP" #define VERSION "1.0" #define AUTHOR "OAT|BDC" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("amx_starthp", "100")     register_logevent("event_roundstart", 2, "0=World triggered", "1=Round_Start" )   } /* public client_disconnect(id) {    remove_task(id)    return PLUGIN_HANDLED } */ public event_roundstart() {     new players[32], num     get_players(players, num)     new i     for (i=0; i<num; i++)     {         if (get_cvar_num("amx_starthp") > 0)         {         set_user_health(players[i], get_cvar_num("amx_starthp"))         }     } }     //StartAP: cs_set_user_armor /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1033{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par } */

v3x 05-07-2006 15:31

Looks fine to me.

You should add the "a" flag to get_players so it doesn't return dead players:
Code:
get_players(players, num, "a")

FatalisDK 05-07-2006 21:47

This code will run a bit faster.

Code:
public event_roundstart() {     new starthp = get_cvar_num("amx_starthp")     if (starthp)     {         new players[32], num         get_players(players, num, "a")                 new i         for (i = 0; i < num; i++)         {             set_user_health(players[i], starthp)         }     } }


All times are GMT -4. The time now is 05:11.

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