Raised This Month: $ Target: $400
 0% 

Change map, when is x player on map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ziverts
Junior Member
Join Date: Feb 2014
Old 05-26-2015 , 14:20   Change map, when is x player on map
Reply With Quote #1

Hello, hope for the help, I am looking plug-in that changes the folder when the server is x number of players
Ziverts is offline
nnajko
Senior Member
Join Date: May 2009
Location: Sweden
Old 05-26-2015 , 14:44   Re: Change map, when is x player on map
Reply With Quote #2

What do you mean by change folder?
nnajko is offline
Ziverts
Junior Member
Join Date: Feb 2014
Old 05-26-2015 , 14:49   Re: Change map, when is x player on map
Reply With Quote #3

uh, i use google translate, i mean, map, not folder :/
Ziverts is offline
nnajko
Senior Member
Join Date: May 2009
Location: Sweden
Old 05-26-2015 , 15:09   Re: Change map, when is x player on map
Reply With Quote #4

Do you want to change to a specific map?
nnajko is offline
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 #5

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
Ziverts
Junior Member
Join Date: Feb 2014
Old 05-27-2015 , 00:44   Re: Change map, when is x player on map
Reply With Quote #6

RaZ_HU looks good, thank you, i test this this evening ~21:00 GMT +2
Yes, it would be stylish if script dispense players question whether they want to be changed when the map number of players are like 16
Ziverts is offline
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 05-27-2015 , 10:56   Re: Change map, when is x player on map
Reply With Quote #7

Quote:
Originally Posted by Ziverts View Post
RaZ_HU looks good, thank you, i test this this evening ~21:00 GMT +2
Yes, it would be stylish if script dispense players question whether they want to be changed when the map number of players are like 16
Your welcome, also I have forgot to set that current map should not be the same as the selected one. (tl;dr: I have forgot to put a !)
So use this corrected code:

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

RaZ_HU is offline
Ziverts
Junior Member
Join Date: Feb 2014
Old 05-27-2015 , 16:13   Re: Change map, when is x player on map
Reply With Quote #8

Quote:
Originally Posted by RaZ_HU View Post
Your welcome, also I have forgot to set that current map should not be the same as the selected one. (tl;dr: I have forgot to put a !)
So use this corrected code:
Thank you very much, everything works perfectly
Ziverts 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 22:31.


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