
   /*
   Invisible Wars MOD 1.0
   Author: Freecode
   Author of Remember the frags: Johnny got his gun
       ===========
       Makes both team invisible depending on their frags.
       USAGE
       =====

       * amx_inviswars <1=ON|| 0=OFF>
       * amx_storefrags  <save frags>

       Releases:
       ========
       2003-09-17    version 1.0
       TO DO
       =====
       Add Support for shutting off the mod completely.
       Add short term.

   */
   #include <amxmod>
   new gmsgStatusText
   new gmsgScoreInfo
   new bool:reread = false
   new playersFrags[33]
   new playersDeaths[33]
   new inviswars
   new iFrags
   new bool:cstrike_running
   new level0=250
   new level1=230
   new level2=205
   new level3=180
   new level4=155
   new level5=130
   new level6=105
   new level7=80
   new level8=55
   new level9=30
   new level10=5
   //--------------------------------------------------------------------
   -----------------
   public client_disconnect(id) {
   storeFrags(id)
   storeDeaths(id)
   }
   //--------------------------------------------------------------------
   -----------------
   public client_putinserver(id) {
   // Restore frags n deaths from file.
   new idd[1]
   idd[0] = id
   set_task(1.0,"delayedrestore",0,idd,1)
   return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   -----------------
   public delayedrestore(idd[]) {
   restoreFrags(idd[0])
   }
   //--------------------------------------------------------------------
   -----------------
   public saveme(id,level,cid) {
   /*
   if (!cmd_access(id,level,cid,1)) {
   return PLUGIN_HANDLED
   }
   */
   storeFrags(id)
   storeDeaths(id)
   return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   -----------------
   native set_user_deaths_cs(index,frags);
   restoreFrags(id) {
   new keyString[40] = "frags", frags, deaths
   setKeyString(id,keyString)
   if (vaultdata_exists(keyString)) {
   frags = get_vaultdata(keyString)
   set_user_frags(id,frags)
   }
   keyString = "death"
   setKeyString(id,keyString)
   if (vaultdata_exists(keyString)) {
   deaths = get_vaultdata(keyString)
   set_user_deaths_cs(id,deaths)
   }
   if (!frags)
   frags = get_user_frags(id)
   if (!deaths)
   deaths = get_user_deaths(id)
   //  With  the  below  message,  we can update the scores shown without
   having to wait
   //  for  next  round  or when id dies/shoots someone or something like
   that.
   sendScoreInfo(id,frags,deaths,get_user_team(id))
   }
   sendScoreInfo(id,frags,deaths,team) {
   message_begin(MSG_ALL,gmsgScoreInfo)
   write_byte(id)
   write_short(frags)
   write_short(deaths)
   write_short(0)
   write_short(team)
   message_end()
   }
   setKeyString(id,keyString[40]) {
   if (is_user_bot(id)) {
   new name[32]
   get_user_name(id,name,31)
   new spaces = charOccurances(name," ")
   for (new i = 0;i < spaces;i++) {
   replace(name,31," ","_")
   }
   copy(keyString[5],34,name)
   }
   else {
   new wonId = get_user_wonid(id)
   new wonIdString[32]
   numtostr(wonId,wonIdString,19)
   copy(keyString[5],34,wonIdString)
   }
   }
   //--------------------------------------------------------------------
   -----------------
   storeFrags(id) {
   new keyString[40] = "frags"
   setKeyString(id,keyString)
   //client_print(0,print_chat,"fragKeyString      after      copy     is
   '%s'.",fragKeyString)
   new fragsString[10]
   numtostr(get_user_frags(id),fragsString,9)
   set_vaultdata(keyString,fragsString)
   //client_print(0,print_chat,"Stored %s to %s.",fragsString,keyString)
   }
   //--------------------------------------------------------------------
   -----------------
   stock charOccurances(string[],matchchar[]) {
   if (strlen(matchchar) != 1)
   return -1
   new occurances
   new len = strlen(string)
   for (new i = 0;i < len;i++) {
   if (string[i] == matchchar[0]) {
   occurances++
   }
   }
   return occurances
   }
   //--------------------------------------------------------------------
   -----------------
   storeDeaths(id) {
   new keyString[40] = "death"
   setKeyString(id,keyString)
   //client_print(0,print_chat,"keyString after copy is '%s'.",keyString)
   new deathString[10]
   numtostr(get_user_deaths(id),deathString,9)
   set_vaultdata(keyString,deathString)
   //client_print(0,print_chat,"Stored %s to %s.",deathString,keyString)
   }
   //--------------------------------------------------------------------
   -----------------
   public restarting_event() {
   reread = true
   // Will need to do a quick remembering of current frags here...
   // Restore these values at next newround_event. Only restore
   // if these are larger than the values in the vault. If not,
   // use those larger values.
   new players[32], playersFound
   get_players(players,playersFound)
   for (new i = 0;i < playersFound;i++) {
   playersFrags[players[i]] = get_user_frags(players[i])
   playersDeaths[players[i]] = get_user_deaths(players[i])
   }
   }
   //--------------------------------------------------------------------
   -----------------
   public commencing_event() {
   reread = true
   // Will need to do a quick remembering of current frags here...
   // Restore these values at next newround_event. Only restore
   // if these are larger than the values in the vault. If not,
   // use those larger values.
   new players[32], playersFound
   get_players(players,playersFound)
   for (new i = 0;i < playersFound;i++) {
   playersFrags[players[i]] = get_user_frags(players[i])
   playersDeaths[players[i]] = get_user_deaths(players[i])
   }
   }
   //--------------------------------------------------------------------
   -----------------
   public instantReread() {
   if (reread) {
   reread = false
   reread_function()
   }
   }
   //--------------------------------------------------------------------
   -----------------
   stock getVaultFrags(id) {
   new keyString[40] = "frags"
   setKeyString(id,keyString)
   if (vaultdata_exists(keyString)) {
   return get_vaultdata(keyString)
   }
   else {
   return playersFrags[id]
   }
   return 0
   }
   //--------------------------------------------------------------------
   -----------------
   stock getVaultDeaths(id) {
   new keyString[40] = "death"
   setKeyString(id,keyString)
   if    (vaultdata_exists(keyString)   &&   get_vaultdata(keyString)   >
   playersDeaths[id]) {
   return get_vaultdata(keyString)
   }
   else {
   return playersDeaths[id]
   }
   return 0
   }
   //--------------------------------------------------------------------
   -----------------
   public reread_function() {
   new players[32], playersFound, keyString[40], vaultFrags, vaultDeaths,
   name[32]
   get_players(players,playersFound)
   for (new i = 0;i < playersFound;i++) {
   get_user_name(players[i],name,31)
   keyString = "frags"
   setKeyString(players[i],keyString)
   if (!vaultdata_exists(keyString)) {
   //client_print(0,print_chat,"%s   has   no   previous   frags  stored,
   restoring %d from variable.",name,playersFrags[players[i]])
   set_user_frags(players[i],playersFrags[players[i]])
   vaultDeaths = getVaultDeaths(players[i])
   set_user_deaths_cs(players[i],vaultDeaths)
   sendScoreInfo(players[i],playersFrags[players[i]],vaultDeaths,get_user
   _team(players[i]))
   }
   else {
   // Compare values, set the biggest one.
   vaultFrags = get_vaultdata(keyString)
   if (vaultFrags >= playersFrags[players[i]]) {
   set_user_frags(players[i],vaultFrags)
   vaultDeaths = getVaultDeaths(players[i])
   set_user_deaths_cs(players[i],vaultDeaths)
   sendScoreInfo(players[i],vaultFrags,vaultDeaths,get_user_team(players[
   i]))
   //client_print(0,print_chat,"%s  has  larger  value in variable, %d to
   %d.",name,vaultFrags,playersFrags[players[i]])
   }
   else {
   set_user_frags(players[i],playersFrags[players[i]])
   vaultDeaths = getVaultDeaths(players[i])
   set_user_deaths_cs(players[i],vaultDeaths)
   sendScoreInfo(players[i],playersFrags[players[i]],vaultDeaths,get_user
   _team(players[i]))
   //client_print(0,print_chat,"%s  has  larger  value  in  vault,  %d to
   %d.",name,playersFrags[players[i]],vaultFrags)
   }
   }
   }
   }
   //--------------------------------------------------------------------
   -----------------
   public admin_inviswars(id) {
   new arg[8]
   read_argv(1,arg,7)
   new parm[1]
   parm[0]=id
   inviswars = str_to_num(arg)
   if(inviswars == 1) {
   set_task(0.1,"statusinvis",0,parm,1,"b")
   console_print(id,"Invisible Wars are now ON")
   set_hudmessage(222, 70,0, -1.0, 0.3, 1, 10.0, 10.0, 2.0, 4.0,6)
   show_hudmessage(0,"Invisible Wars are now ON")
   return PLUGIN_HANDLED
   }
   if(inviswars == 0) {
   new players[32], inum
   get_players(players,inum)
   for(new a=0;a<inum;++a){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,255)
   console_print(id,"Invisible Wars are now OFF")
   set_hudmessage(222, 70,0, -1.0, 0.3, 1, 10.0, 10.0, 2.0, 4.0,6)
   show_hudmessage(0,"Invisible Wars are now OFF")
   }
   }
   return PLUGIN_HANDLED
   }
   //--------------------------------------------------------------------
   -----------------
   public plugin_log(){
   new args = read_logargc()
   if(args == 2){
   new msg[32]
   read_logargv(1,msg,31)
   if(msg[6] == 'S')
   round_start()
   }
   return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   -----------------
   public round_start() {
   if(!inviswars)
   return PLUGIN_CONTINUE
   new maxplayers = get_maxplayers() + 1
   for(new i=1;i<maxplayers;i++){
   if(is_user_alive(i))
   iFrags=get_user_frags(i)
   if(iFrags < 10){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level0
   )
   }else if(10 >= iFrags && iFrags < 25){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level1
   )
   }else if(25 >= iFrags && iFrags < 50){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level2
   )
   }else if(50 >= iFrags && iFrags < 100){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level3
   )
   }else if(100 >= iFrags && iFrags < 250){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level4
   )
   }else if(250 >= iFrags && iFrags < 425){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level5
   )
   }else if(425 >= iFrags && iFrags < 500){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level6
   )
   }else if(500 >= iFrags && iFrags < 575){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level7
   )
   }else if(575 >= iFrags && iFrags < 650){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level8
   )
   }else if(650 >= iFrags && iFrags < 750){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level9
   )
   }else if(750 >= iFrags && iFrags < 1000){
   set_user_rendering(i,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level1
   0)
   }
   }
   return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   -----------------
   public new_spawn(id) {
   if( (!inviswars) || (cstrike_running) )
   return PLUGIN_CONTINUE
   iFrags=get_user_frags(id)
   if(iFrags < 10){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   0)
   }else if(10 >= iFrags && iFrags < 25){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   1)
   }else if(25 >= iFrags && iFrags < 50){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   2)
   }else if(50 >= iFrags && iFrags < 100){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   3)
   }else if(100 >= iFrags && iFrags < 250){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   4)
   }else if(250 >= iFrags && iFrags < 425){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   5)
   }else if(425 >= iFrags && iFrags < 500){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   6)
   }else if(500 >= iFrags && iFrags < 575){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   7)
   }else if(575 >= iFrags && iFrags < 650){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   8)
   }else if(650 >= iFrags && iFrags < 750){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   9)
   }else if(750 >= iFrags && iFrags < 1000){
   set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,level
   10)
   }
   return PLUGIN_CONTINUE
   }
   //--------------------------------------------------------------------
   -----------------
   public statusinvis(id){
   new lvlstring[256]
   new players[32], inum
   get_players(players,inum)
   for(new a=0;a<inum;++a) {
   iFrags=get_user_frags(players[a])
   if(iFrags < 10){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level0)
   }else if(10 >= iFrags && iFrags < 25){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level1)
   }else if(25 >= iFrags && iFrags < 50){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level2)
   }else if(50 >= iFrags && iFrags < 100){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level3)
   }else if(100 >= iFrags && iFrags < 250){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level4)
   }else if(250 >= iFrags && iFrags < 425){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level5)
   }else if(425 >= iFrags && iFrags < 500){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level6)
   }else if(500 >= iFrags && iFrags < 575){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level7)
   }else if(575 >= iFrags && iFrags < 650){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level8)
   }else if(650 >= iFrags && iFrags < 750){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level9)
   }else if(750 >= iFrags && iFrags < 1000){
   set_user_rendering(players[a],kRenderFxGlowShell,0,0,0,kRenderTransAlp
   ha,level10)
   }
   if(iFrags < 10){
   format(lvlstring,255,"Your Frags: %i Need: 10",iFrags)
   }else if(10 >= iFrags && iFrags < 25){
   format(lvlstring,255,"Your Frags: %i Need: 25",iFrags)
   }else if(25 >= iFrags && iFrags < 50){
   format(lvlstring,255,"Your Frags: %i Need: 50",iFrags)
   }else if(50 >= iFrags && iFrags < 100){
   format(lvlstring,255,"Your Frags: %i Need: 100",iFrags)
   }else if(100 >= iFrags && iFrags < 250){
   format(lvlstring,255,"Your Frags: %i Need: 250",iFrags)
   }else if(250 >= iFrags && iFrags < 425){
   format(lvlstring,255,"Your Frags: %i Need: 425",iFrags)
   }else if(425 >= iFrags && iFrags < 500){
   format(lvlstring,255,"Your Frags: %i Need: 500",iFrags)
   }else if(500 >= iFrags && iFrags < 575){
   format(lvlstring,255,"Your Frags: %i Need: 575",iFrags)
   }else if(575 >= iFrags && iFrags < 650){
   format(lvlstring,255,"Your Frags: %i Need: 650",iFrags)
   }else if(650 >= iFrags && iFrags < 750){
   format(lvlstring,255,"Your Frags: %i Need: 750",iFrags)
   }else if(750 >= iFrags && iFrags < 1000){
   format(lvlstring,255,"Your Frags: %i Need: 1000",iFrags)
   }
   message_begin(MSG_ONE, gmsgStatusText, {0,0,0}, players[a])
   write_byte(0)
   write_string(lvlstring)
   message_end()
   }
   }
   //--------------------------------------------------------------------
   -----------------
   public plugin_init() {
   register_plugin("Invisible Wars MOD","1.0","Freecode")
   register_clcmd("amx_storefrags","saveme",0,":  stores  your  frags and
   deaths.")
   register_clcmd("amx_inviswars","admin_inviswars",ADMIN_MENU,"<1|0>")
   register_event("ResetHUD", "new_spawn", "b")
   register_event("TextMsg","commencing_event","a","2=#Game_Commencing")
   register_event("TextMsg","restarting_event","a","2=#Game_will_restart_
   in")
   register_event("SendAudio","instantReread","b","2=%!MRAD_GO","2=%!MRAD
   _MOVEOUT","2=%!MRAD_LETSGO","2=%!MRAD_LOCKNLOAD")
   gmsgScoreInfo = get_user_msgid("ScoreInfo")
   gmsgStatusText = get_user_msgid("StatusText")
   new mod_name[32]
   get_modname(mod_name,31)
   cstrike_running = equal(mod_name,"cstrike") ? true : false
   }
