AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Set Health and Armor TFC (https://forums.alliedmods.net/showthread.php?t=72636)

Alakayonk 06-12-2008 07:52

Set Health and Armor TFC
 
1 Attachment(s)
This Plugin allows for an admin with ADMIN_SLAY access to use the following commands

amx_hp <Target:@All/@Team color/Username/#Userid> <Amount>
amx_armor <Target:@All/@Team color/Username/#Userid> <Amount>

server cvars are
hp_ar_immune <0|1> (default 0) //Cant set on admins with immunity
hp_ar_on <0|1> (default 1) //Turns the plugin on or off

***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 Blue Red Yellow and Green.***End Edit***

This is my first plugin. I thank whoever made the original tutorial which can be found here
http://wiki.alliedmods.net/Intro_to_AMX_Mod_X_Scripting

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


Here is source code


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
}


anakin_cstrike 06-13-2008 05:37

Re: Set Health and Armor TFC
 
LOL:|

Alakayonk 06-13-2008 14:17

Re: Set Health and Armor TFC
 
I found a bug where when you do @all or @teamcolor it dosent check immnuity status

Todo:

Fix that bug
add Say / commands

GHW_Chronic 06-16-2008 19:00

Re: Set Health and Armor TFC
 
simple fix
Code:
set_user_armor (iPlayers[i],Armor)
to
Code:
if(get_cvar_num("hp_ar_immune") && !(get_user_flags(iPlayers[i]) & ADMIN_IMMUNITY))     set_user_armor (iPlayers[i],Armor)
(same with health)

as well please add punctuation to your for statements (add { and } and indent)

and this plugin would work for any mod not just TFC.

and lastly there really isn't a reason to paste the whole source code into your main post like that.


All times are GMT -4. The time now is 20:32.

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