AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About zombie icon (https://forums.alliedmods.net/showthread.php?t=163526)

Osker Lee 07-31-2011 10:42

About zombie icon
 
3 Attachment(s)
Hey guys,I want to display a icon (dmg_bio) when human become a zombie,and I try to add it to the sma,it is work.But the problem is: when I become a human,the icon still will exists and never disappears,please help!
PHP Code:

#include <amxmodx>
#include <xs>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define SUPPORT_BOT_TO_USE
new const zclass_name[] = { "Zombie Class: Healer" }
new const 
zclass_info[] = { "=Press 'R' to heal=" }
new const 
zclass_model[] = { "zombie_healer" }
new const 
zclass_clawmodel[] = { "v_knife_healer.mdl" }
const 
zclass_health 5000
const zclass_speed 240
const Float:zclass_gravity 1.0
const Float:zclass_knockback 1.0
new const HealSound[] = { "zombie_plague/td_debuff.wav" }
new 
g_zclass_kuca
new kuca_skill_cooldownkuca_skill_rangekuca_skill_heal_point
new Float:eyes_skill[33]
new 
heal_spr
public plugin_init()
{
 
register_plugin("[ZP] Class: Healer""1.0""I don't know")
 
 
kuca_skill_cooldown register_cvar("zp_kuca_cooldown""20.0")
 
kuca_skill_range register_cvar("zp_kuca_heal_range""300")
 
kuca_skill_heal_point register_cvar("zp_kuca_heal_hp_percentage""10")
 
 
register_forward(FM_CmdStart"fw_CmdStart")
 
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
 
 
register_event("ResetHUD","NewRound","be")
 
register_event("DeathMsg""Death""a")
}
public 
plugin_precache()
{
 
precache_sound(HealSound)
 
heal_spr precache_model("sprites/zombie_plague/zombie_healer.spr")
 
g_zclass_kuca zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}
stock ChatColor(const id, const input[], any:...)
{
 new 
count 1players[32]
 static 
msg[191]
 
vformat(msg190input3)
 
 
replace_all(msg190"!g""^4"// Green Color
 
replace_all(msg190"!y""^1"// Default Color
 
replace_all(msg190"!team""^3"// Team Color
 
replace_all(msg190"!team2""^0"// Team2 Color
 
 
if (idplayers[0] = id; else get_players(playerscount"ch")
        {
 for (new 
0counti++)
 {
  if (
is_user_connected(players[i]))
  {
   
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
   
write_byte(players[i]);
   
write_string(msg);
   
message_end();
  }
 }
}
}
public 
zp_user_infected_post(idinfector)
{
 if (
zp_get_user_zombie_class(id) == g_zclass_kuca)
 {
 
set_hud_spr(id,1)
        
ChatColor(id"!g[Zombie Healer]!yPress 'R' to heal yourself and teamates!Healing Range: %.1f,Restore HP: %d%,Cooldowng Time: %.1f."get_pcvar_float(kuca_skill_range), get_pcvar_num(kuca_skill_heal_point), get_pcvar_float(kuca_skill_cooldown))
 }
}
set_hud_spr(id,status)
{
 
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("StatusIcon"),{0,0,0},id);
 
write_byte(status); // status (0=hide, 1=show, 2=flash)
        
write_string("dmg_bio"); // sprite name
 
write_byte(0); // red
 
write_byte(255); // green
 
write_byte(0); // blue
 
message_end();
}
public 
zp_user_humanized_post(id)
{
 
clear(id)
}
public 
Death()
{
 new 
id read_data(2)
 
clear(id)
}
public 
NewRound(id)
{
 
clear(id)
}
public 
client_connect(id)
{
 
clear(id)
}
public 
client_disconnect(id)
{
 
clear(id)
}
public 
clear(id)
{
 
eyes_skill[id] = 0.0
}
public 
fw_CmdStart(iduc_handleseed)
{
 if (!
is_user_alive(id))
  return 
FMRES_IGNORED;
 
 if (!
zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_kuca)
  return 
FMRES_IGNORED;
 
 if (
zp_get_user_nemesis(id))
  return 
FMRES_IGNORED;
 
 static 
buttonoldbuttoni
 button 
get_uc(uc_handleUC_Buttons)
 
oldbutton pev(idpev_oldbuttons)
 
 if ((
button IN_RELOAD) && !(oldbutton IN_RELOAD))
 {
  if (
get_gametime() - eyes_skill[id] < get_pcvar_float(kuca_skill_cooldown))
  {
   
ChatColor(id"!g[Zpmbie Healer]!yDuring the cooldown...")
   return 
FMRES_IGNORED;
  }
 
  for(
1<= get_playersnum(); i++)
   if(
id != && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
    if (
is_in_view(idi) && get_range(idi) <= get_pcvar_float(kuca_skill_range))
     
heal_zombie(i)
  
heal_zombie(id)
  
eyes_skill[id] = get_gametime()
 }
 
 
#if defined SUPPORT_BOT_TO_USE
 
if (is_user_bot(id))
 {
  if (
get_gametime() - eyes_skill[id] < get_pcvar_float(kuca_skill_cooldown))
   return 
FMRES_IGNORED;
 
  static 
bool:need_heal_in_view[33]
  for(
1<= get_playersnum(); i++)
  if(
id != && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i)) 
                if (
pev(ipev_health) <= float(zp_get_zombie_maxhealth(i))*(100-get_pcvar_float(kuca_skill_heal_point))/100)
  if (
is_in_view(idi) && get_range(idi) <= get_pcvar_float(kuca_skill_range))
  
need_heal_in_view[id] = true
 
  
if (need_heal_in_view[id] || pev(idpev_health) <= float(zp_get_zombie_maxhealth(id))*(100-get_pcvar_float(kuca_skill_heal_point))/100)
  {
   for(
1<= get_playersnum(); i++)
    if(
id != && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
     if (
is_in_view(idi) && get_range(idi) <= get_pcvar_float(kuca_skill_range))
      
heal_zombie(i)
   
heal_zombie(id)
   
need_heal_in_view[id] = false
   eyes_skill
[id] = get_gametime()
  }
 }
 
#endif
 
 
return FMRES_HANDLED;
}
public 
heal_zombie(id)
{
 
show_spr(id)
 
engfunc(EngFunc_EmitSoundidCHAN_AUTOHealSound1.0ATTN_NORM0PITCH_NORM)
 if (
pev(idpev_health) < float(zp_get_zombie_maxhealth(id)))
  
set_pev(idpev_healthfloatmin(pev(idpev_health) + float(zp_get_zombie_maxhealth(id))*get_pcvar_float(kuca_skill_heal_point)/100float(zp_get_zombie_maxhealth(id))))
}
public 
fw_PlayerPreThink(id)
{
 if (!
is_user_alive(id)) return FMRES_IGNORED;
 
 if (
zp_get_user_nemesis(id)) return FMRES_IGNORED;
 
 if (!
zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_kuca) return FMRES_IGNORED;
 
 if (
get_gametime() - eyes_skill[id] >= get_pcvar_float(kuca_skill_cooldown) && get_gametime() - eyes_skill[id] < get_pcvar_float(kuca_skill_cooldown)+0.1)
  
ChatColor(id"!g[Zombie Healer]!yNow you can use your skill again!")
 
 return 
FMRES_IGNORED;
}
stock Float:get_range(indextarget)
{
 static 
Float:origin1[3], Float:origin2[3]
 
pev(indexpev_originorigin1)
 
pev(targetpev_originorigin2)
 
 return 
get_distance_f(origin1,origin2)
}
stock show_spr(id)
{
 static 
Float:origin[3]
 
pev(idpev_originorigin)
 
engfunc(EngFunc_MessageBegin,MSG_BROADCAST,SVC_TEMPENTITY,origin,0)
 
write_byte(TE_SPRITE)
 
engfunc(EngFunc_WriteCoord,origin[0])
 
engfunc(EngFunc_WriteCoord,origin[1])
 
engfunc(EngFunc_WriteCoord,origin[2]+16)
 
write_short(heal_spr)
 
write_byte(10)
 
write_byte(255)
 
message_end()
}
stock bool:is_in_view(indextargetignoremonsters 1)
{
 if (
index == target) return false;
 new 
Float:angles[3];
 
pev(indexpev_anglesangles);
 
engfunc(EngFunc_MakeVectorsangles);
 
global_get(glb_v_forwardangles);
 
angles[2] = 0.0;
 new 
Float:origin[3], Float:point[3], Float:diff[3], Float:norm[3], Float:view_ofs[3];
 
pev(indexpev_originorigin);
 
pev(targetpev_originpoint);
 
xs_vec_sub(pointorigindiff);
 
diff[2] = 0.0;
 
xs_vec_normalize(diffnorm);
 
pev(indexpev_view_ofsview_ofs);
 
xs_vec_add(originview_ofsorigin);
 
engfunc(EngFunc_TraceLineoriginpointignoremonstersindex0);
 new 
Float:dotFloat:fov;
 
dot xs_vec_dot(normangles);
 
pev(indexpev_fovfov);
 new 
Float:fraction;
 
get_tr2(0TR_flFractionfraction);
 if (
dot >= floatcos(fov M_PI 360) && fraction == 1.0)
  return 
true;
 return 
false;



Jacob 07-31-2011 11:53

Re: About zombie icon
 
hide icon 1-->0

Osker Lee 07-31-2011 14:10

Re: About zombie icon
 
Hey man, what do you mean?

Exolent[jNr] 07-31-2011 15:51

Re: About zombie icon
 
PHP Code:

#include <amxmodx>
#include <xs>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#define SUPPORT_BOT_TO_USE
new const zclass_name[] = { "Zombie Class: Healer" }
new const 
zclass_info[] = { "=Press 'R' to heal=" }
new const 
zclass_model[] = { "zombie_healer" }
new const 
zclass_clawmodel[] = { "v_knife_healer.mdl" }
const 
zclass_health 5000
const zclass_speed 240
const Float:zclass_gravity 1.0
const Float:zclass_knockback 1.0
new const HealSound[] = { "zombie_plague/td_debuff.wav" }
new 
g_zclass_kuca
new kuca_skill_cooldownkuca_skill_rangekuca_skill_heal_point
new Float:eyes_skill[33]
new 
heal_spr
public plugin_init()
{
 
register_plugin("[ZP] Class: Healer""1.0""I don't know")
 
 
kuca_skill_cooldown register_cvar("zp_kuca_cooldown""20.0")
 
kuca_skill_range register_cvar("zp_kuca_heal_range""300")
 
kuca_skill_heal_point register_cvar("zp_kuca_heal_hp_percentage""10")
 
 
register_forward(FM_CmdStart"fw_CmdStart")
 
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
 
 
register_event("ResetHUD","NewRound","be")
 
register_event("DeathMsg""Death""a")
}
public 
plugin_precache()
{
 
precache_sound(HealSound)
 
heal_spr precache_model("sprites/zombie_plague/zombie_healer.spr")
 
g_zclass_kuca zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}
stock ChatColor(const id, const input[], any:...)
{
 new 
count 1players[32]
 static 
msg[191]
 
vformat(msg190input3)
 
 
replace_all(msg190"!g""^4"// Green Color
 
replace_all(msg190"!y""^1"// Default Color
 
replace_all(msg190"!team""^3"// Team Color
 
replace_all(msg190"!team2""^0"// Team2 Color
 
 
if (idplayers[0] = id; else get_players(playerscount"ch")
        {
 for (new 
0counti++)
 {
  if (
is_user_connected(players[i]))
  {
   
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
   
write_byte(players[i]);
   
write_string(msg);
   
message_end();
  }
 }
}
}
public 
zp_user_infected_post(idinfector)
{
 if (
zp_get_user_zombie_class(id) == g_zclass_kuca)
 {
 
set_hud_spr(id,1)
        
ChatColor(id"!g[Zombie Healer]!yPress 'R' to heal yourself and teamates!Healing Range: %.1f,Restore HP: %d%,Cooldowng Time: %.1f."get_pcvar_float(kuca_skill_range), get_pcvar_num(kuca_skill_heal_point), get_pcvar_float(kuca_skill_cooldown))
 }
}
set_hud_spr(id,status)
{
 
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("StatusIcon"),{0,0,0},id);
 
write_byte(status); // status (0=hide, 1=show, 2=flash)
        
write_string("dmg_bio"); // sprite name
 
write_byte(0); // red
 
write_byte(255); // green
 
write_byte(0); // blue
 
message_end();
}
public 
zp_user_humanized_post(id)
{
 
clear(id)
}
public 
Death()
{
 new 
id read_data(2)
 
clear(id)
}
public 
NewRound(id)
{
 
clear(id)
}
public 
client_connect(id)
{
 
clear(id)
}
public 
client_disconnect(id)
{
 
clear(id)
}
public 
clear(id)
{
 
eyes_skill[id] = 0.0
 set_hud_spr
(id,10)
}
public 
fw_CmdStart(iduc_handleseed)
{
 if (!
is_user_alive(id))
  return 
FMRES_IGNORED;
 
 if (!
zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_kuca)
  return 
FMRES_IGNORED;
 
 if (
zp_get_user_nemesis(id))
  return 
FMRES_IGNORED;
 
 static 
buttonoldbuttoni
 button 
get_uc(uc_handleUC_Buttons)
 
oldbutton pev(idpev_oldbuttons)
 
 if ((
button IN_RELOAD) && !(oldbutton IN_RELOAD))
 {
  if (
get_gametime() - eyes_skill[id] < get_pcvar_float(kuca_skill_cooldown))
  {
   
ChatColor(id"!g[Zpmbie Healer]!yDuring the cooldown...")
   return 
FMRES_IGNORED;
  }
 
  for(
1<= get_playersnum(); i++)
   if(
id != && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
    if (
is_in_view(idi) && get_range(idi) <= get_pcvar_float(kuca_skill_range))
     
heal_zombie(i)
  
heal_zombie(id)
  
eyes_skill[id] = get_gametime()
 }
 
 
#if defined SUPPORT_BOT_TO_USE
 
if (is_user_bot(id))
 {
  if (
get_gametime() - eyes_skill[id] < get_pcvar_float(kuca_skill_cooldown))
   return 
FMRES_IGNORED;
 
  static 
bool:need_heal_in_view[33]
  for(
1<= get_playersnum(); i++)
  if(
id != && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i)) 
                if (
pev(ipev_health) <= float(zp_get_zombie_maxhealth(i))*(100-get_pcvar_float(kuca_skill_heal_point))/100)
  if (
is_in_view(idi) && get_range(idi) <= get_pcvar_float(kuca_skill_range))
  
need_heal_in_view[id] = true
 
  
if (need_heal_in_view[id] || pev(idpev_health) <= float(zp_get_zombie_maxhealth(id))*(100-get_pcvar_float(kuca_skill_heal_point))/100)
  {
   for(
1<= get_playersnum(); i++)
    if(
id != && is_user_alive(i) && zp_get_user_zombie(i) && !zp_get_user_nemesis(i))
     if (
is_in_view(idi) && get_range(idi) <= get_pcvar_float(kuca_skill_range))
      
heal_zombie(i)
   
heal_zombie(id)
   
need_heal_in_view[id] = false
   eyes_skill
[id] = get_gametime()
  }
 }
 
#endif
 
 
return FMRES_HANDLED;
}
public 
heal_zombie(id)
{
 
show_spr(id)
 
engfunc(EngFunc_EmitSoundidCHAN_AUTOHealSound1.0ATTN_NORM0PITCH_NORM)
 if (
pev(idpev_health) < float(zp_get_zombie_maxhealth(id)))
  
set_pev(idpev_healthfloatmin(pev(idpev_health) + float(zp_get_zombie_maxhealth(id))*get_pcvar_float(kuca_skill_heal_point)/100float(zp_get_zombie_maxhealth(id))))
}
public 
fw_PlayerPreThink(id)
{
 if (!
is_user_alive(id)) return FMRES_IGNORED;
 
 if (
zp_get_user_nemesis(id)) return FMRES_IGNORED;
 
 if (!
zp_get_user_zombie(id) || zp_get_user_zombie_class(id) != g_zclass_kuca) return FMRES_IGNORED;
 
 if (
get_gametime() - eyes_skill[id] >= get_pcvar_float(kuca_skill_cooldown) && get_gametime() - eyes_skill[id] < get_pcvar_float(kuca_skill_cooldown)+0.1)
  
ChatColor(id"!g[Zombie Healer]!yNow you can use your skill again!")
 
 return 
FMRES_IGNORED;
}
stock Float:get_range(indextarget)
{
 static 
Float:origin1[3], Float:origin2[3]
 
pev(indexpev_originorigin1)
 
pev(targetpev_originorigin2)
 
 return 
get_distance_f(origin1,origin2)
}
stock show_spr(id)
{
 static 
Float:origin[3]
 
pev(idpev_originorigin)
 
engfunc(EngFunc_MessageBegin,MSG_BROADCAST,SVC_TEMPENTITY,origin,0)
 
write_byte(TE_SPRITE)
 
engfunc(EngFunc_WriteCoord,origin[0])
 
engfunc(EngFunc_WriteCoord,origin[1])
 
engfunc(EngFunc_WriteCoord,origin[2]+16)
 
write_short(heal_spr)
 
write_byte(10)
 
write_byte(255)
 
message_end()
}
stock bool:is_in_view(indextargetignoremonsters 1)
{
 if (
index == target) return false;
 new 
Float:angles[3];
 
pev(indexpev_anglesangles);
 
engfunc(EngFunc_MakeVectorsangles);
 
global_get(glb_v_forwardangles);
 
angles[2] = 0.0;
 new 
Float:origin[3], Float:point[3], Float:diff[3], Float:norm[3], Float:view_ofs[3];
 
pev(indexpev_originorigin);
 
pev(targetpev_originpoint);
 
xs_vec_sub(pointorigindiff);
 
diff[2] = 0.0;
 
xs_vec_normalize(diffnorm);
 
pev(indexpev_view_ofsview_ofs);
 
xs_vec_add(originview_ofsorigin);
 
engfunc(EngFunc_TraceLineoriginpointignoremonstersindex0);
 new 
Float:dotFloat:fov;
 
dot xs_vec_dot(normangles);
 
pev(indexpev_fovfov);
 new 
Float:fraction;
 
get_tr2(0TR_flFractionfraction);
 if (
dot >= floatcos(fov M_PI 360) && fraction == 1.0)
  return 
true;
 return 
false;



Osker Lee 07-31-2011 17:04

Re: About zombie icon
 
I tested it,but it is not what I wanna.Maybe you misunderstood me,in fact I just want to display the icon for zombie, not human.


All times are GMT -4. The time now is 03:24.

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