This Plugin allows for an admin with ADMIN_SLAY access to use the following commands
***Edit*** This supports all 4 team colors in TFC. It should work for other mods as well but i designed it with TFC in mind so the @Team color only supports Colors
This is my first plugin. I thank whoever made the original tutorial which can be found here
I looked up all the information worked out tons of errors and warnings but compile is smooth with none of either. I made this in order to learn the PAWN language so that I could modify any plugins to suit my server. Thanks for all the help
Code:
/* Plugin generated by AMXX-Studio */
//This is my first plugin!//
//Thanks to whomever made the original tutorial :D
//Original tutorial http://wiki.alliedmods.net/Intro_to_AMX_Mod_X_Scripting
#include <amxmodx>
#include <amxmisc>
#include <fun>
#define PLUGIN "Set Health and Armor"
#define VERSION "1.0"
#define AUTHOR "Alakayonk"
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_concmd("amx_hp","cmd_hp",ADMIN_SLAY,"<Target: @All @Team Username|id> <Ammount> Gives health to target")
register_concmd("amx_armor","cmd_ar",ADMIN_SLAY,"<Target: @All @Team Username|id> <Ammount> Gives armor to target")
register_cvar("hp_ar_immune","0")
register_cvar("hp_ar_on","1")
}
public cmd_hp(id, level, cid)
{
if(!get_cvar_num("hp_ar_on"))
{
return PLUGIN_HANDLED
}
else if(!cmd_access(id,level,cid,3))
{
set_hudmessage(255, 0, 0, -1.0, 0.01)
show_hudmessage(id, "[AMXX] You do not have access for this command!")
return PLUGIN_HANDLED
}
else
{
new Arg1[24]
new Arg2[4]
read_argv(1, Arg1, 23)
read_argv(2, Arg2, 3)
new Health = str_to_num(Arg2)
if (Arg1[0]=='@')
{
new Team = 0
new iPlayers[32], iNum,i
get_players (iPlayers,iNum)
for(i=0;i<iNum;i++)
if (equali(Arg1[1],"All"))
{
set_user_health (iPlayers[i],Health)
}
else if(equali(Arg1[1],"Blue"))
{
Team = 1
}
else if(equali(Arg1[1],"Red"))
{
Team = 2
}
else if(equali(Arg1[1],"Yellow"))
{
Team = 3
}
else if(equali(Arg1[1],"Green"))
{
Team = 4
}
if(get_user_team (iPlayers[i]) == Team)
{
set_user_health (iPlayers[i],Health)
}
}
else
{
new iPlayer=0
if (get_cvar_num("hp_ar_immune")==0)
{
iPlayer = cmd_target(id, Arg1)
if(!iPlayer)
{
console_print(id,"[AMXX]. %s cannot be found",Arg1)
}
else
{
set_user_health(iPlayer,Health)
}
}
else
{
iPlayer = cmd_target(id,Arg1,1)
if(!iPlayer)
{
console_print(id,"[AMXX}. %s cannot be found or has immunity",Arg1)
}
else
{
set_user_health(iPlayer,Health)
}
}
}
}
return PLUGIN_HANDLED
}
public cmd_ar(id, level, cid)
{
if (!get_cvar_num ("hp_ar_on"))
{
return PLUGIN_HANDLED
}
else if(!cmd_access(id,level,cid,3))
{
set_hudmessage(255, 0, 0, -1.0, 0.01)
show_hudmessage(id, "[AMXX] You do not have access for this command!")
return PLUGIN_HANDLED
}
else
{
new Arg1[24]
new Arg2[4]
read_argv(1, Arg1, 23)
read_argv(2, Arg2, 3)
new Armor = str_to_num(Arg2)
if (Arg1[0]=='@')
{
new Team = 0
new iPlayers[32], iNum,i
get_players (iPlayers,iNum)
for(i=0;i<iNum;i++)
if (equali(Arg1[1],"All"))
{
set_user_armor (iPlayers[i],Armor)
}
else if(equali(Arg1[1],"Blue"))
{
Team = 1
}
else if(equali(Arg1[1],"Red"))
{
Team = 2
}
else if(equali(Arg1[1],"Yellow"))
{
Team = 3
}
else if(equali(Arg1[1],"Green"))
{
Team = 4
}
if(get_user_team (iPlayers[i]) == Team)
{
set_user_armor (iPlayers[i],Armor)
}
}
else
{
new iPlayer=0
if (get_cvar_num("hp_ar_immune")==0)
{
iPlayer = cmd_target(id, Arg1)
if(!iPlayer)
{
console_print(id,"[AMXX}. %s cannot be found",Arg1)
}
else
{
set_user_armor(iPlayer,Armor)
}
}
else
{
iPlayer = cmd_target(id,Arg1,1)
if(!iPlayer)
{
console_print(id,"[AMXX}]. %s cannot be found or has immunity",Arg1)
}
else
{
set_user_armor(iPlayer,Armor)
}
}
}
}
return PLUGIN_HANDLED
}