This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Set Health and Armor TFC


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
Alakayonk
Junior Member
Join Date: Jun 2008
Location: Austin Texas
Old 06-12-2008 , 07:52   Set Health and Armor TFC
Reply With Quote #1

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
}
Attached Files
File Type: sma Get Plugin or Get Source (amx_hp_armor.sma - 1011 views - 3.9 KB)
__________________
There is no such thing as equivalent exchange.

Last edited by Alakayonk; 06-12-2008 at 08:26.
Alakayonk is offline
Send a message via ICQ to Alakayonk Send a message via AIM to Alakayonk Send a message via Yahoo to Alakayonk
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 06-13-2008 , 05:37   Re: Set Health and Armor TFC
Reply With Quote #2

LOL
__________________

anakin_cstrike is offline
Alakayonk
Junior Member
Join Date: Jun 2008
Location: Austin Texas
Old 06-13-2008 , 14:17   Re: Set Health and Armor TFC
Reply With Quote #3

I found a bug where when you do @all or @teamcolor it dosent check immnuity status

Todo:

Fix that bug
add Say / commands
__________________
There is no such thing as equivalent exchange.
Alakayonk is offline
Send a message via ICQ to Alakayonk Send a message via AIM to Alakayonk Send a message via Yahoo to Alakayonk
GHW_Chronic
SourceMod Donor
Join Date: Sep 2004
Location: Texas
Old 06-16-2008 , 19:00   Re: Set Health and Armor TFC
Reply With Quote #4

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.

Last edited by GHW_Chronic; 06-16-2008 at 19:05.
GHW_Chronic is offline
Send a message via AIM to GHW_Chronic
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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