Raised This Month: $ Target: $400
 0% 

Req : change cvar + map when..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Visan15
Junior Member
Join Date: Apr 2012
Old 06-12-2024 , 07:00   Req : change cvar + map when..
Reply With Quote #1

Hello everybody,

Im looking for plugin what he can change cvar mp_timelimit and use amx_map mapx when are under 10 players or over 10 .

10 or under :
amx_map fy_snow
amx_cvar mp_timelimit 0

11 or over :

amx_map de_dust2

amx_cvar mp_timelimit 25

Thank you.
Visan15 is offline
Tote
Senior Member
Join Date: Jul 2023
Old 06-13-2024 , 05:20   Re: Req : change cvar + map when..
Reply With Quote #2

Code:
#include <amxmodx>
#include <amxmisc>

public plugin_init() {
	
	set_task(1.0, "check_players", .flags = "b")
}

public check_players() {
	new iPlayers[32], pnum
	get_players(iPlayers, pnum)
	
	if(pnum <= 10) {
		server_cmd("amx_map fy_snow")
		server_cmd("amx_cvar mp_timelimit 0")
	} else if(pnum >= 11) {
		server_cmd("amx_map de_dust2")
		server_cmd("amx_cvar mp_timelimit 25")
	}
}
Tote is offline
Visan15
Junior Member
Join Date: Apr 2012
Old 06-13-2024 , 18:31   Re: Req : change cvar + map when..
Reply With Quote #3

Thank you Tote for your time but i think its a problem here.

If both commands gonna be done in same time, then when map change the timelimit gonna be default one from server.cfg.

Its any chance the mp_timelimit to happen after 30s ? like server change map on fy_snow and after 30s to set the timelimit.

Thank you.
Visan15 is offline
Tote
Senior Member
Join Date: Jul 2023
Old 06-15-2024 , 05:52   Re: Req : change cvar + map when..
Reply With Quote #4

Quote:
Originally Posted by Visan15 View Post
Thank you Tote for your time but i think its a problem here.

If both commands gonna be done in same time, then when map change the timelimit gonna be default one from server.cfg.

Its any chance the mp_timelimit to happen after 30s ? like server change map on fy_snow and after 30s to set the timelimit.

Thank you.
Code:
#include <amxmodx>

public plugin_init() {
	
	set_task(1.0, "check_players", .flags = "b")
}

public check_players() {
	new iPlayers[32], pnum
	get_players(iPlayers, pnum)
	
	if(pnum <= 10) {
		server_cmd("changelevel fy_snow")
		set_task(30.0, "do_time_snow")
	} else if(pnum >= 11) {
		server_cmd("changelevel de_dust2")
		set_task(30.0, "do_time_dust2")
	}
}

public do_time_snow() {
	server_cmd("mp_timelimit 0")
}
public do_time_dust2() {
	server_cmd("mp_timelimit 25")
}

Last edited by Tote; 06-15-2024 at 05:54.
Tote is offline
v120kaaimcfg
Member
Join Date: Apr 2024
Old 06-15-2024 , 11:38   Re: Req : change cvar + map when..
Reply With Quote #5

‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

Last edited by v120kaaimcfg; 06-17-2024 at 07:14.
v120kaaimcfg is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 06-15-2024 , 14:53   Re: Req : change cvar + map when..
Reply With Quote #6

have you put it to the test will go into an endless loop, It's not a good way to do it.
__________________
mlibre is offline
Tote
Senior Member
Join Date: Jul 2023
Old 06-15-2024 , 15:22   Re: Req : change cvar + map when..
Reply With Quote #7

Quote:
Originally Posted by mlibre View Post
have you put it to the test will go into an endless loop, It's not a good way to do it.
oh yeah now u bring it up, i didnt thought about that at that moment do most stuff when im sleepy

oh yeah i guess its bad idea to do like this. i just need to check plays on client disconnected and client putinserver i will look do it tomorrow

also now i see it that i need to make a check if current map is already fy snow or dedust2 or not lmao, i didnt know i do such things when sleepy xD

Last edited by Tote; 06-15-2024 at 15:26.
Tote is offline
Visan15
Junior Member
Join Date: Apr 2012
Old 06-15-2024 , 17:40   Re: Req : change cvar + map when..
Reply With Quote #8

Thank you for help guys , im waiting the new version.. Thanks.

Last edited by Visan15; 06-15-2024 at 17:42.
Visan15 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-15-2024 , 21:01   Re: Req : change cvar + map when..
Reply With Quote #9

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.
__________________
fysiks is offline
Tote
Senior Member
Join Date: Jul 2023
Old 06-16-2024 , 05:06   Re: Req : change cvar + map when..
Reply With Quote #10

Quote:
Originally Posted by fysiks View Post
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)
	}
}

Last edited by Tote; 06-16-2024 at 09:15. Reason: updated from idea of v120kaaimcfg
Tote 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 15:13.


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