Raised This Month: $ Target: $400
 0% 

map check


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GhostMan
Senior Member
Join Date: Jun 2012
Old 04-19-2013 , 03:53   map check
Reply With Quote #1

I have a small plugin which changes to 'default' map if there no players found in server.

I would like to hear some improvements for this plugin. I'm thinking of changing mp_timelimit to 0 when map is default and no players found and change it back to 35 when somebody connects. But the problem is that if nobody connects to server for more than 35mins after connection server will instantly change the map. What alternatives could i do becouse of that?

PHP Code:
#include <amxmodx>
     
new nCvar_TimesnCvar_MapnMaps
     
public plugin_init()
{
    
register_plugin("Map check""1.1""None")
       
    
nCvar_Times register_cvar("nmap_check_time""3")
    
nCvar_Map register_cvar("nmap_check_map""de_dust2_2x2")

    new 
mapname[32
    
get_mapname(mapname,31)

    if(
equali(mapname"de_dust2_2x2"))
    {
        return 
PLUGIN_HANDLED
    
}
    else
    {
        
set_task(60.0"nice_map_check"___"b")
    }
    return 
PLUGIN_CONTINUE
}
     
public 
nice_map_check()
{
    new 
nMap[40], nPlayers get_playersnum()
       
    
get_pcvar_string(nCvar_MapnMapcharsmax(nMap))
       
    if(
nPlayers == 0)
    {
        
nMaps++
           
        if(
nMaps == get_pcvar_num(nCvar_Times))
        {
            
server_cmd("changelevel %s"nMap)
        }
    }

GhostMan is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 04-19-2013 , 09:55   Re: map check
Reply With Quote #2

Check in client_disconnect(id) only.

Try this: (Not tested)

PHP Code:
#include <amxmodx>

new p_Map;

public 
plugin_init()
{
    
register_plugin("Changelevel",AMXX_VERSION_STR,"SmileY");
    
    
p_Map register_cvar("amx_default_map","de_dust2");
}

public 
client_disconnect(id)
{
    new 
iPlayers get_playersnum(1); // Check if any player its connecting to server

    
new szMap[32];
    
get_pcvar_string(p_Map,szMap,charsmax(szMap));
    
    if(
is_map_valid(szMap) && !iPlayers)
    {
        new 
szThisMap[32];
        
get_mapname(szThisMap,charsmax(szThisMap));
        
        if(!
equali(szMap,szName)) server_cmd("changelevel %s",szMap);
    }

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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:52.


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