Quote:
Originally Posted by fysiks
Since you're clearly new at writing plugins, Tote, you really need to test anything you write for forum requests before posting it.
Also, there are functions in AMX Mod X specifically for setting cvar values e.g. set_cvar_num() in this case. Trying to do what he asks requires some more advanced functionality to bridge the logic through a map change.
|
You are not wrong, I am "clearly new" at writing plugins. When i see someone requesting something interesting(atleast interesting for myself), It makes me want to help them. Also, as i mentioned, I wrote that at night. I don't know where my brain is at night and i miss most of stuff, Just now when i saw the code again i see that what did i even made XD there was no LOGIC. But also when i post something, People point my mistake out and it helps me to improve as well that what mistake i've made and where etc..
At that time when i wrote the plugin, i was sure of myself that it was going to work fine. But when i saw again at DAY what i wrote, it was funny xD like wtf i even wrote
here you go, this might do fine
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Mapchange when specific players"
#define PLAYERS_FOR_SNOW 10
#define PLAYERS_FOR_DUST2 11
new cvar_timelimit
new bool:checked_timelimit
new curmap[33]
public plugin_init() {
register_plugin(PLUGIN, "1.0", "Tote")
cvar_timelimit = get_cvar_pointer("mp_timelimit")
get_mapname(curmap, charsmax(curmap))
if(checked_timelimit != true) {
set_task(10.0, "check_map")
checked_timelimit = true
}
}
public client_putinserver() { // check when a player gets in sv
check_players()
}
public client_disconnected() { // check when a player disconnects from server
check_players()
}
public check_players() {
if(get_playersnum() <= PLAYERS_FOR_SNOW) { // if lower or equal to 10
if(!equali(curmap, "fy_snow")) {
server_cmd("changelevel fy_snow")
}
} else if(get_playersnum() >= PLAYERS_FOR_DUST2) { // if higher or equal to 11
if(!equali(curmap, "de_dust2")) {
server_cmd("changelevel de_dust2")
}
}
}
public check_map() {
if(equali(curmap, "de_dust2")) {
set_pcvar_num(cvar_timelimit, 25)
} else if(equali(curmap, "fy_snow")) {
set_pcvar_num(cvar_timelimit, 0)
}
}