Raised This Month: $ Target: $400
 0% 

Change map, when is x player on map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 05-26-2015 , 17:34   Re: Change map, when is x player on map
Reply With Quote #1

This is an example how to change to a specified map.

Use cvar: cm_playercount "<number>" to set when the mod should change map. Default is 16 (you can change it in the code if you want).

PHP Code:
#include <amxmodx>

#define PLUGIN    "Change map at X playercount"
#define VERSION    "0.1"
#define AUTHOR    "RaZ_HU"

new playerCount;

public 
plugin_init()
{
    
register_plugin(PLUGIN,VERSION,AUTHOR)
    
playerCount register_cvar("cm_playercount","16")
    
    
set_task(20.0"clientnumCheck"0__"b"// Run check every 20 seconds
    
    
return PLUGIN_CONTINUE;
}

public 
clientnumCheck(client)
{
    new 
mapname[32]
    
get_mapname(mapname,31)
    
    
// Count how many players are on the server and check if the current map is the same as the wanted one
    
if(get_playersnum() >=playerCount && strcmp(mapname"de_dust2")) 
    {
        
server_cmd"changelevel de_dust2");
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE


I wanted to add support to be able to change wanted map, but I don't know how to do that yet.
RaZ_HU 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 20:21.


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