Half-Life и Adrenaline Gamer форум

Всё об игре в Халф-Лайф и АГ
Текущее время: 15 май 2024, 11:06

Часовой пояс: UTC + 5 часов [ Летнее время ]




Начать новую тему Ответить на тему  [ Сообщений: 3 ] 
Автор Сообщение
 Заголовок сообщения: Opposing Force Coop MonsterName ошибка
СообщениеДобавлено: 28 мар 2014, 06:03 
Не в сети
Зарегистрирован:
21 мар 2014, 17:59
Последнее посещение:
20 мар 2023, 23:44
Сообщения: 145
Код:
/*   
*   Opposing Force Coop Monster Name
*
*                     by GordonFreeman
*            http://gordonfreeman.hldm.org/
*/

#include <amxmodx>
#include <fakemeta>

new Trie:g_mnames
new Trie:g_indefy
new Trie:g_health

new g_maxplayers
new skill

public plugin_init(){
   register_plugin("Monster Name","0.3","GordonFreeman")
   
   g_mnames = TrieCreate()
   g_indefy = TrieCreate()
   g_health = TrieCreate()
   
   TrieSetString(g_mnames,"monster_headcrab","Headcrab")
   TrieSetString(g_mnames,"monster_bullchicken","Bullsquid")
   TrieSetString(g_mnames,"monster_barnacle","Barnacle")   // cool thing
   TrieSetString(g_mnames,"monster_houndeye","Houndeye")
   TrieSetString(g_mnames,"monster_alien_slave","Alien Slave")
   TrieSetString(g_mnames,"monster_alien_controller","Alien Controller")
   TrieSetString(g_mnames,"monster_alien_grunt","Alien Grunt")
   TrieSetString(g_mnames,"monster_alien_voltigore","Voltigore")
   TrieSetString(g_mnames,"monster_alien_babyvoltigore","Baby Voltigore")
   TrieSetString(g_mnames,"monster_shocktrooper","Shocktrooper")
   TrieSetString(g_mnames,"monster_zombie","Zombie")
   TrieSetString(g_mnames,"monster_zombie_barney","Zombie Barney")
   TrieSetString(g_mnames,"monster_zombie_soldier","Zombie Soldier")
   TrieSetString(g_mnames,"monster_ichthyosaur","Ichthyosaur")
   TrieSetString(g_mnames,"monster_gonome","Gonome")   // hate it!
   TrieSetString(g_mnames,"monster_pitdrone","Pitdrone")
   TrieSetString(g_mnames,"monster_human_assassin","Blackop Assassin")
   TrieSetString(g_mnames,"monster_male_assassin","Blackop Soldier")
   TrieSetString(g_mnames,"monster_shockroach","Shockroach")
   TrieSetString(g_mnames,"monster_blkop_apache","Blackop Apache")
   TrieSetString(g_mnames,"monster_otis","Otis")
   TrieSetString(g_mnames,"monster_barney","Barney")
   TrieSetString(g_mnames,"monster_gman",/*"Gordon FreeMan"*/"G-Man")
   TrieSetString(g_mnames,"monster_human_grunt_ally","Soldier")
   TrieSetString(g_mnames,"monster_human_torch_ally","Engineer")
   TrieSetString(g_mnames,"monster_human_medic_ally","Medic")
   TrieSetString(g_mnames,"monster_scientist","Scientist")
   TrieSetString(g_mnames,"monster_cleansuit_cleansuit","Scientist")
   
   TrieSetCell(g_indefy,"monster_headcrab",1)
   TrieSetCell(g_indefy,"monster_bullchicken",1)
   TrieSetCell(g_indefy,"monster_barnacle",1)
   TrieSetCell(g_indefy,"monster_houndeye",1)
   TrieSetCell(g_indefy,"monster_alien_slave",1)
   TrieSetCell(g_indefy,"monster_alien_controller",1)
   TrieSetCell(g_indefy,"monster_alien_grunt",1)
   TrieSetCell(g_indefy,"monster_alien_voltigore",1)
   TrieSetCell(g_indefy,"monster_alien_babyvoltigore",1)
   TrieSetCell(g_indefy,"monster_shocktrooper",1)
   TrieSetCell(g_indefy,"monster_zombie",1)
   TrieSetCell(g_indefy,"monster_zombie_barney",1)
   TrieSetCell(g_indefy,"monster_zombie_soldier",1)
   TrieSetCell(g_indefy,"monster_ichthyosaur",1)
   TrieSetCell(g_indefy,"monster_gonome",1)
   TrieSetCell(g_indefy,"monster_pitdrone",1)
   TrieSetCell(g_indefy,"monster_human_assassin",1)
   TrieSetCell(g_indefy,"monster_male_assassin",1)
   TrieSetCell(g_indefy,"monster_shockroach",1)
   TrieSetCell(g_indefy,"monster_blkop_apache",1)
   
   TrieSetCell(g_indefy,"monster_otis",2)
   TrieSetCell(g_indefy,"monster_barney",2)
   TrieSetCell(g_indefy,"monster_gman",2)
   TrieSetCell(g_indefy,"monster_human_grunt_ally",2)
   TrieSetCell(g_indefy,"monster_human_torch_ally",2)
   TrieSetCell(g_indefy,"monster_human_medic_ally",2)
   TrieSetCell(g_indefy,"monster_scientist",2)
   TrieSetCell(g_indefy,"monster_cleansuit_scientist",2)

   g_maxplayers = get_maxplayers()
}

public plugin_cfg(){
   skill = get_cvar_num("skill")
      
   TrieSetCell(g_health,"monster_headcrab",get_monster_health("sk_headcrab_health"))
   TrieSetCell(g_health,"monster_bullchicken",get_monster_health("sk_bullsquid_health"))
   TrieSetCell(g_health,"monster_barnacle",15)
   TrieSetCell(g_health,"monster_houndeye",get_monster_health("sk_houndeye_health"))
   TrieSetCell(g_health,"monster_alien_slave",get_monster_health("sk_islave_health"))
   TrieSetCell(g_health,"monster_alien_controller",get_monster_health("sk_controller_health"))
   TrieSetCell(g_health,"monster_alien_grunt",get_monster_health("sk_agrunt_health"))
   TrieSetCell(g_health,"monster_alien_voltigore",get_monster_health("sk_voltigore_health"))
   TrieSetCell(g_health,"monster_alien_babyvoltigore",get_monster_health("sk_babyvoltigore_health"))
   TrieSetCell(g_health,"monster_shocktrooper",get_monster_health("sk_shocktrooper_health"))
   TrieSetCell(g_health,"monster_zombie",get_monster_health("sk_zombie_health"))
   TrieSetCell(g_health,"monster_zombie_barney",get_monster_health("sk_zombie_barney_health"))
   TrieSetCell(g_health,"monster_zombie_soldier",get_monster_health("sk_zombie_soldier_health"))
   TrieSetCell(g_health,"monster_ichthyosaur",get_monster_health("sk_ichthyosaur_health"))
   TrieSetCell(g_health,"monster_gonome",get_monster_health("sk_gonome_health"))
   TrieSetCell(g_health,"monster_pitdrone",get_monster_health("sk_pitdrone_health"))
   TrieSetCell(g_health,"monster_human_assassin",get_monster_health("sk_hassassin_health"))
   TrieSetCell(g_health,"monster_male_assassin",get_monster_health("sk_massassin_health"))
   TrieSetCell(g_health,"monster_shockroach",get_monster_health("sk_shockroach_health"))
   TrieSetCell(g_health,"monster_blkop_apache",get_monster_health("sk_apache_health"))
   TrieSetCell(g_health,"monster_otis",get_monster_health("sk_otis_health"))
   TrieSetCell(g_health,"monster_barney",get_monster_health("sk_barney_health"))
   TrieSetCell(g_health,"monster_gman",1337)
   TrieSetCell(g_health,"monster_human_grunt_ally",get_monster_health("sk_hgrunt_ally_health"))
   TrieSetCell(g_health,"monster_human_torch_ally",get_monster_health("sk_torch_ally_health"))
   TrieSetCell(g_health,"monster_human_medic_ally",get_monster_health("sk_medic_ally_health"))
   TrieSetCell(g_health,"monster_scientist",get_monster_health("sk_scientist_health"))
   TrieSetCell(g_health,"monster_cleansuit_scientist",get_monster_health("sk_cleansuit_scientist_health"))
}

public client_putinserver(id)
   set_task(0.1,"fw_PlayerPostThink",id,.flags="b")
   
public client_disconnect(id)
   remove_task(id)

public fw_PlayerPostThink(id){
   static ent,bh
   static classname[32],color[3],hpinfo[18]
   
   get_user_aiming(id,ent,bh)
   
   if(!ent)
      return
      
   static health,armor
      
   if(0<ent<=g_maxplayers){
      get_user_name(ent,classname,31)
      health = get_user_health(id)
      armor = get_user_armor(id)
      
      color = {0,255,0}
      
      formatex(hpinfo,17,"(%d/%d)",health,armor)
   }else{
      pev(ent,pev_classname,classname,31)
      
      if(pev(ent,pev_deadflag)!=DEAD_NO)
         return
      
      TrieGetCell(g_indefy,classname,armor)
      
      switch(armor){
         case 1: color = {255,0,0}
         case 2: color = {0,255,0}
         default: return
      }

      TrieGetCell(g_health,classname,health)
      health = pev(ent,pev_health)*100/health
      
      armor = 0
      
      TrieGetString(g_mnames,classname,classname,31)
      
      formatex(hpinfo,17,"(%d)",health)
   }
   
   set_hudmessage(color[0], color[1], color[2], -1.0, 0.60, 1, 1.0, 0.4, 0.01, 0.01, -1)
   show_hudmessage(id,"%s %s",classname,hpinfo)
}

get_monster_health(cvar[]){
   new cv[25]
   formatex(cv,24,"%s%d",cvar,skill)
   
   return get_cvar_num(cv)
}



С такой проблемой прошу фиксануть или помочь найти подобие



 


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Opposing Force Coop MonsterName ошибка
СообщениеДобавлено: 28 мар 2014, 17:16 
Не в сети
Аватара пользователя
Зарегистрирован:
27 июл 2013, 19:43
Последнее посещение:
12 янв 2019, 00:22
Сообщения: 50
Предполагаю, что проблема заключается в строчке
Код:
health = pev(ent,pev_health)*100/health
и возникает когда health == 0

_________________
ИзображениеИзображение


Вернуться к началу
 Профиль 
  
 Заголовок сообщения: Re: Opposing Force Coop MonsterName ошибка
СообщениеДобавлено: 29 мар 2014, 00:41 
Не в сети
Site Admin
Зарегистрирован:
01 июн 2010, 01:27
Последнее посещение:
13 май 2024, 18:07
Сообщения: 6867
Тогда достаточно будет заменить
Код:
health = pev(ent,pev_health)*100/health
на
Код:
health = health == 0 ? 0 : (pev(ent, pev_health) * 100 / health)


Вернуться к началу
 Профиль 
  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 3 ] 

Часовой пояс: UTC + 5 часов [ Летнее время ]


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
Создано на основе phpBB® Forum Software © phpBB Group
Русская поддержка phpBB