Raised This Month: $51 Target: $400
 12% 

Auto Map Change On Empty Server 1.42


Post New Thread Reply   
 
Thread Tools Display Modes
Vanquishe[rR]
BANNED
Join Date: Feb 2010
Location: Australia, Victoria, Mel
Old 02-25-2010 , 03:46   Re: Auto Map Change On Empty Server 1.42
Reply With Quote #71

Hello
This is my first post on the forums.
I have been around cs for a while and i've always been doing amx stuff (stuff = installing) or having it done for me by my sponsors
So it would sound strange if i ask that
How would i open the .sma file? Do i use the Amx Mod Studio?

Also, regarding this topic, you mentioned:
Quote:
amx_nmap2,amx_nmap3,amx_nmap4,amx_n map5
Where exactly do i place the map name?
amx_ncs_assault ? or amx_n cs_assault (Because #5 seems to have a space..)
Vanquishe[rR] is offline
Send a message via MSN to Vanquishe[rR]
sake
Senior Member
Join Date: Jul 2011
Old 09-29-2011 , 11:01   Re: Auto Map Change On Empty Server 1.42
Reply With Quote #72

Sorry for resurrecting, but maybe fix it to have all three cvars be the same map. Because this could cause an infinite loop:

while(equali(maps[num],curmap) || (strlen(maps[num]) == 0))
{
num = random_num(0,4)
}
__________________
sake is offline
sake
Senior Member
Join Date: Jul 2011
Old 10-05-2011 , 13:47   Re: Auto Map Change On Empty Server 1.42
Reply With Quote #73

Just the fix for the bug i said there was
Attached Files
File Type: sma Get Plugin or Get Source (emptyserver.sma - 588 views - 4.1 KB)
__________________
sake is offline
isotonic
AlliedModders Donor
Join Date: Jun 2011
Location: Moscow, Russia
Old 01-09-2012 , 02:31   Re: Auto Map Change On Empty Server 1.42
Reply With Quote #74

Using #73 and #67 I made 'update' cvar to pcvar.
Code:
#include <amxmodx>
#include <amxmisc>
#include <float>
new filepath[251],curtime=0,staytime=0,curplayers=0,currounds=0
new amx_idletime, amx_smartmap, amx_nmap1, amx_nmap2, amx_nmap3, amx_nmap4, amx_nmap5
public plugin_init()
{
 register_plugin("Empty Server","1.42","twistedeuphoria")
 register_cvar("amx_staytime","600")
 amx_nmap1 = register_cvar("amx_nmap1","de_dust2")
 amx_nmap2 = register_cvar("amx_nmap2","de_train")
 amx_nmap3 = register_cvar("amx_nmap3","de_inferno")
 amx_nmap4 = register_cvar("amx_nmap4","de_nuke")
 amx_nmap5 = register_cvar("amx_nmap5","de_aztec")
 amx_idletime = register_cvar("amx_idletime","5")
 amx_smartmap = register_cvar("amx_smartmap","1")
 register_logevent("newround",2,"1=Round_Start")
 staytime = get_cvar_num("amx_staytime")
 set_task(1.0,"timer",0,"curtime",0,"b",1)
 new directory[201]
 get_datadir(directory,200)
 formatex(filepath,250,"%s/emptyserver.txt",directory)
 if(!file_exists(filepath))
 {
  new writestr[201]
  formatex(writestr,200,"Map - Rounds Played - Total Players")
  write_file(filepath,writestr)
 }
}
public newround()
{
 currounds++
 new players[32], playernum
 get_players(players,playernum,"c")
 curplayers += playernum
} 
public plugin_end()
{
 new retstr[201],p,a,bool:found = false
 for(p=1;read_file(filepath,p,retstr,200,a) != 0;p++)
 {
  new smap[51],srounds[51],splayers[51],curmap[51]
  parse(retstr,smap,50,srounds,50,splayers,50)
  get_mapname(curmap,50)
  if(equali(smap,curmap))
  {
   new rounds = str_to_num(srounds)
   new players = str_to_num(splayers)
   rounds += currounds
   players += curplayers
   num_to_str(rounds,srounds,50)
   num_to_str(players,splayers,50)
   format(retstr,200,"%s %s %s",smap,srounds,splayers)
   write_file(filepath,retstr,p) 
   found = true
  }
 }
 if(found == false)
 {
  new players[51],map[51],rounds[51],writestr[201]
  get_mapname(map,50)
  num_to_str(curplayers,players,50)
  num_to_str(currounds,rounds,50)
  format(writestr,200,"%s %s %s",map,rounds,players)
  write_file(filepath,writestr)
 }
}
 
 
public timer()
{
 if(get_playersnum() == 0)
 {
  curtime ++
  if(curtime >= staytime)
   change_maps()
 }
 else
 {  
  new players,i,noncounted
  players = get_playersnum()
  for(i=1;i<=get_maxplayers();i++)
  {
   if((get_user_time(i,1) >= (get_pcvar_num(amx_idletime) * 216000)) || is_user_bot(i) || is_user_hltv(i))
   {
    noncounted++
   }
  }
  if(players == noncounted)
  {
   curtime++
   if(curtime >= staytime)
    change_maps()
  }
  else
   curtime = 0
 }
 return curtime
}
public change_maps()
{
 new maps[5][51],curmap[51]
 get_mapname(curmap,50)
 if(get_pcvar_num(amx_smartmap) == 1)
 {
  new Float:curpercent = 0.0   
  new retstr[201],p,a
  for(new i = 0;i<5;i++)
  {
   for(p=0;read_file(filepath,p,retstr,200,a) != 0;p++)
   {
    new sroundstr[51],splayerstr[51],smap[51],roundnum,playernum
    parse(retstr,smap,50,sroundstr,50,splayerstr,50)
    if(!equali(smap,curmap) && !equali(smap,maps[0]) && !equali(smap,maps[1]) && !equali(smap,maps[2]) && !equali(smap,maps[3]) && !equali(smap,maps[4]))
    {
     roundnum = str_to_num(sroundstr)
     playernum = str_to_num(splayerstr)
     new Float:curperc = floatdiv(float(roundnum),float(playernum))
     if(curperc > curpercent)
     {
      curpercent = curperc
      copy(maps[i],50,smap)
     }
    }
   }
   curpercent = 0.0
  }
 }
 else
 { 
  get_pcvar_string(amx_nmap1,maps[0],31)
  get_pcvar_string(amx_nmap2,maps[1],31)
  get_pcvar_string(amx_nmap3,maps[2],31)
  get_pcvar_string(amx_nmap4,maps[3],31)
  get_pcvar_string(amx_nmap5,maps[4],31)
 }
 if(strlen(maps[0]) == 0)
  get_pcvar_string(amx_nmap1,maps[0],31)
 if(strlen(maps[1]) == 0)
  get_pcvar_string(amx_nmap2,maps[1],31)
 if(strlen(maps[2]) == 0)
  get_pcvar_string(amx_nmap3,maps[2],31)
 if(strlen(maps[3]) == 0)
  get_pcvar_string(amx_nmap4,maps[3],31)
 if(strlen(maps[4]) == 0)
  get_pcvar_string(amx_nmap5,maps[4],31)
 new num = random_num(0,4)
 if(!(equali(maps[0],maps[1]) 
  && equali(maps[0],maps[2])
  && equali(maps[0],maps[3]) 
  && equali(maps[0],maps[4])))
 {
  while(equali(maps[num],curmap) || (strlen(maps[num]) == 0))
  {
   num = random_num(0,4)
  }
 }
 server_cmd("changelevel %s",maps[num])
 return PLUGIN_HANDLED
}
isotonic is offline
isotonic
AlliedModders Donor
Join Date: Jun 2011
Location: Moscow, Russia
Old 06-08-2012 , 01:55   Re: Auto Map Change On Empty Server 1.42
Reply With Quote #75

I've rewrited original 'Auto Map Change On Empty Server' plugin.

Changes are:
Quote:
- removed stats support (and so 'amx_smartmap' CVAR);
- checking time is now every 10 seconds instead of 1;
- there will be no map change if there are no valid maps defined by CVARs or the only valid map is equal to current one. (Dunno if there is such check in the original because I hadn't completely understand that part of code) So if all of amx_nmapX CVARs are equal that version works same is 'onemap' version;
- used pcvars
I was need version without statistics for Half-Life where there are no rounds. Also it would be suitable if you don't plan to use statistics (neither 'smart map' feature nor manual processing).

I plan to make statistic calculation for mods without rounds. If somebody is interested in it will happen sooner ;)
--

emptyserver.sma is version from my previous post with a little modification: don't count HLTV as a player for statistics.
--
Attached Files
File Type: sma Get Plugin or Get Source (emptyserver_withoutstats.sma - 859 views - 2.6 KB)
File Type: sma Get Plugin or Get Source (emptyserver.sma - 978 views - 4.7 KB)
__________________

Last edited by isotonic; 06-08-2012 at 03:22.
isotonic is offline
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 10:50.


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