AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   My Map Changing Plugin for TS. (https://forums.alliedmods.net/showthread.php?t=55821)

terrum 05-30-2007 19:14

My Map Changing Plugin for TS.
 
this is my script i made myself. Yes it's probably stupidly wrong but it's my first plugin. I want it so it doesn't repeat the cycle more than 1 time, i only want it to do this once, how do i do this? thanks

Quote:

#include <amxmodx>
#include <engine>

//terrum_meckmapchange.sma:
// Custom plugin by Terrum. Not to be released.

new const PLUGIN[] = "Mecklenburg Map Changer"
new const VERSION[] = "1"
new const AUTHOR[] = "Terrum"
new cycler_classname[] = "whatever"

new const Float:cycler_time = 5.0 //cycler runs every so many seconds
new const cvar_name[] = "amx_mecklenburg_mapchange"
new const cvar_default[] = "1" //default cvar value. "1"=on,"0"=off

public plugin_init() {
register_plugin(PLUGIN,VERSION,AUTHOR)
register_cvar( cvar_name , cvar_default )
new entity = create_entity("info_target")
entity_set_string(entity,EV_SZ_classname,cycl er_classname)
entity_set_float(entity,EV_FL_nextthink,halfl ife_time() + cycler_time)
register_think(cycler_classname,"HandleCycler ")
} //public.plugin_init

public HandleCycler(entity) {
if ( get_cvar_num( cvar_name ) > 0 ) { //if cvar greater than zero
} //if.cvar
server_cmd("amx_map mecklenburgv5_a6")
server_cmd("amxx pause terrum_meck")
} //public.HandleCycler
EDIT: Well all i want it to do is change the map to "mecklenburgv5_a6" once after 5 seconds the server starts and have a CVAR "amx_mecklenburg_mapchange" default to 1 (1 = on. 0 = off.)

stupok 05-30-2007 20:49

Re: My Map Changing Plugin for TS.
 
Is this what you're looking for?
Code:
#include <amxmodx> #define PLUGIN "Map Change" #define VERSION "1.0" #define AUTHOR "stupok69" new cvar_meck public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         cvar_meck = register_cvar("amx_mecklenburg_mapchange", "1")         set_task(5.0, "delay_mapchange") } public delay_mapchange() {     if(get_pcvar_num(cvar_meck))     {         server_cmd("changelevel mecklenburgv5_a6")     } }

Lee 05-30-2007 21:11

Re: My Map Changing Plugin for TS.
 
I used this in one of my plugins that ends the map if you use amx_extend -x where x is greater than the time remaining. I believe I may have originally taken some code from the original amx_map command.

Code:
if (invtlimit * 60 >= get_timeleft()) {     client_print(id,print_console, "%s You have ended the map.", TAG)     client_print(0,print_chat, "%s %s has ended the map.", TAG, name)         //server_cmd("amx_map %s", get_cvar_string("amx_nextmap"))                  //make a note of this message to display the     //scoreboard as if the map was ending normally     message_begin(MSG_ALL, SVC_INTERMISSION)     message_end()     set_task(2.0, "change_map")         return PLUGIN_HANDLED } public change_map() {     new nextmap[32]     get_cvar_string("amx_nextmap", nextmap, 31)     server_cmd("changelevel %s", nextmap) }

terrum 05-30-2007 21:18

Re: My Map Changing Plugin for TS.
 
Quote:

Is this what you're looking for?
Code:

#include <amxmodx> #define PLUGIN "Map Change" #define VERSION "1.0" #define AUTHOR "stupok69" new cvar_meck public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) cvar_meck = register_cvar("amx_mecklenburg_mapchange", "1") set_task(5.0, "delay_mapchange") } public delay_mapchange() { if(get_pcvar_num(cvar_meck)) { server_cmd("changelevel mecklenburgv5_a6") } }

That does the same thing as what my plugin does.

It changes the map every 5 seconds, i only want it to change the map ONCE after 5 seconds the server is up (Edit the plugin so it doesn't repeat itself, if possible. If not possible, then forget about it.)

Quote:

Originally Posted by Lee (Post 483913)
I used this in one of my plugins that ends the map if you use amx_extend -x where x is greater than the time remaining. I believe I may have originally taken some code from the original amx_map command.

Code:
if (invtlimit * 60 >= get_timeleft()) {     client_print(id,print_console, "%s You have ended the map.", TAG)     client_print(0,print_chat, "%s %s has ended the map.", TAG, name)         //server_cmd("amx_map %s", get_cvar_string("amx_nextmap"))                  //make a note of this message to display the     //scoreboard as if the map was ending normally     message_begin(MSG_ALL, SVC_INTERMISSION)     message_end()     set_task(2.0, "change_map")         return PLUGIN_HANDLED } public change_map() {     new nextmap[32]     get_cvar_string("amx_nextmap", nextmap, 31)     server_cmd("changelevel %s", nextmap) }

That's not exactly what i need, Thanks anyway though.

stupok 05-30-2007 22:03

Re: My Map Changing Plugin for TS.
 
Well I think this is the easiest way to do that. You could, instead, write a value to a file and check if the function has been executed. If you're just trying to start a server with a specific map, check out the .bat below.

Code:
#include <amxmodx> #define PLUGIN "Map Change" #define VERSION "1.0" #define AUTHOR "stupok69" new cvar_meck public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         cvar_meck = register_cvar("amx_mecklenburg_mapchange", "1")         set_task(5.0, "delay_mapchange") } public delay_mapchange() {     if(get_pcvar_num(cvar_meck))     {         set_pcvar_num(cvar_meck, 0)         server_cmd("changelevel mecklenburgv5_a6")     } }

I use a .bat to start my server, it looks like this:
Code:

start /high hlds.exe -console -game ts -port 27017 -maxplayers 10 +map mecklenburg_b5

terrum 05-30-2007 22:27

Re: My Map Changing Plugin for TS.
 
I use a script in .bat as well to restart my server. But that's not the point.. It's a amxx plugin whats causing the map not to change to mecklenburgv5_a6 so that's why i want this plugin..
anyway.. this plugin works.. thanks +karma


All times are GMT -4. The time now is 10:38.

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