Quote:
Originally Posted by vres
it has a flaw: when an admin types /35hp, 1hp, or acer, only their HP changes, and others remain unaffected.
|
you may applied the function while other players were dead .
this is general , u can edit the cmd as u like :
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>
new MaxP,hp;
new bool:gBotsReg;
public plugin_init()
{
MaxP = get_maxplayers()+1;
hp = 100;
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost",1);
register_clcmd("say","cmdhp");
}
public cmdhp(id)
{
new Args[16];
read_args(Args,16);
if (contain(Args,"/mod")!=-1)
{
if ( get_user_flags(id)&ADMIN_RCON )
{
new index = strfind(Args,"d",false,4)+1; // start from 4 , bring what is after "d" letter (in case admin was drunk)
new value = str_to_num(Args[index]);
if (! value)
{
client_print(id, print_chat,"Usage /mod%d",random(99)+1);
}
else
{
hp=value;
Start_Mod(); // You Can do <Restart Round> instead of the loop below : server_cmd("sv_restart 1");
}
}
else client_print(id, print_chat,"You don't have access to this command");
}
return PLUGIN_CONTINUE;
}
Start_Mod()
{
new P_Team;
for (new i=1; i< MaxP ; i++)
{
P_Team = get_user_team(i);
if (P_Team==1 || P_Team==2)
ExecuteHamB(Ham_CS_RoundRespawn,i);
}
}
public hudgoster()
{
set_hudmessage(200, 100, 0, -0.98, -0.73, .effects= 1 , .holdtime= 0.8)
if (!show_hudmessage(0, "%dHP mode active",hp))
remove_task(100);
}
public client_authorized(id)
{
if(!task_exists(100))
set_task(1.0,"hudgoster",100,_,_,"b");
if(!gBotsReg && get_cvar_pointer("bot_quota") && is_user_bot(id))
set_task(0.1,"register_Ham_for_bots",id);
}
public register_Ham_for_bots(id)
{
if(!gBotsReg)
{
gBotsReg = true;
RegisterHamFromEntity(Ham_Spawn,id,"fwHamPlayerSpawnPost",1);
}
}
public fwHamPlayerSpawnPost(id)
{
set_user_health(id,hp);
}