AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Own Mapchooser (https://forums.alliedmods.net/showthread.php?t=228975)

Phant 10-30-2013 10:26

Own Mapchooser
 
Hello.
GoldSrc (CS) (without AMXX) have own mapcycle system ("mapcycle.txt"), and it works even works AMXX Mapchooser system.

Default Mapchooser system of AMXX works via two plugins:
Code:

nextmap.amxx        ; displays next map in mapcycle
mapchooser.amxx        ; allows to vote for next map

And we can see this "hack" in "nextmap.sma":
PHP Code:

public changeMap()
{
    new 
string[32]
    new 
Float:chattime get_cvar_float("mp_chattime")
    
    
set_cvar_float("mp_chattime"chattime 2.0)        // make sure mp_chattime is long
    
new len getNextMapName(string31) + 1
    set_task
(chattime"delayedChange"0stringlen)    // change with 1.5 sec. delay


For example, I want create my own mapchooser (mapcycle) system.
And I do not want to use this "hack". What are the options?
Can I set default nextmap (not amx_nextmap, like from "mapcycle.txt") for server via AMXX?

fysiks 10-30-2013 12:27

Re: Own Mapchooser
 
That is the only way. I've looked for another way before but didn't find anything.

What is wrong with using it?

ConnorMcLeod 10-30-2013 13:50

Re: Own Mapchooser
 
You want to change the map picked by game ?

Phant 10-30-2013 14:27

Re: Own Mapchooser
 
Quote:

Originally Posted by ConnorMcLeod (Post 2054725)
You want to change the map picked by game ?

No. Ideally I want replace next map picked by game to any map what I want.
Or find way to disable original mapcycle system (like "mapcycle.txt" not exist, forever intermission).

fysiks 10-30-2013 18:12

Re: Own Mapchooser
 
Quote:

Originally Posted by Phant (Post 2054767)
No. Ideally I want replace next map picked by game to any map what I want.
Or find way to disable original mapcycle system (like "mapcycle.txt" not exist, forever intermission).

Have you tried deleting or just emptying mapcycle.txt?

ConnorMcLeod 10-31-2013 01:58

Re: Own Mapchooser
 
Change cvar mapcyclefile on each map and write 1 map in it should force the game to reload mapcycle and to use that map.

PHP Code:

#include < amxmodx >

#pragma semicolon 1

#define PLUGIN ""
#define VERSION "0.0.1"

#define cm(%0)    ( sizeof(%0) - 1 )

new const SERVERINFO_MAPCYCLEFILE[] = "ourmapcyclefile";

// use 2 files : amx_nextmap1.txt and amx_nextmap2.txt, so the 11th char change in the name
new g_szMapCycleFile[] = "amx_nextmap1.txt";

public 
plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" );

    
// better to do that here rather than in intermission callback
    
ChangeMapCycleFile();

    
register_event("30""Event_SVC_INTERMISSION""a");
}

ChangeMapCycleFile()
{
    
get_localinfo(SERVERINFO_MAPCYCLEFILEg_szMapCycleFilecharsmax(g_szMapCycleFile));
    if( 
g_szMapCycleFile[11] == '1' )
    {
        
g_szMapCycleFile[2] = '2';
    }
    else
    {
        
g_szMapCycleFile[2] = '1';
    }
    
set_cvar_string("mapcyclefile"g_szMapCycleFile);
}

public 
Event_SVC_INTERMISSION()
{
    new 
szNextMap[32];
    
// write here some code to choose your next map
    // when it is done, write its name in the .txt file.
    // GetNextMap(szNextMap, charsmax(szNextMap));
    
    
new fp fopen(g_szMapCycleFile"wt");
    
fprintf(fp"%s^n"szNextMap);
    
fclose(fp);



Phant 10-31-2013 04:50

Re: Own Mapchooser
 
Quote:

Originally Posted by fysiks (Post 2054873)
Have you tried deleting or just emptying mapcycle.txt?

Yes.

ConnorMcLeod, thanks you for example! I did not know about "mapcyclefile" cvar.

Also, for disabling default mapcycle system and got "forever intermission" we can do this:
Code:

mapcyclefile ""
Without files manipulations.

ConnorMcLeod 10-31-2013 12:54

Re: Own Mapchooser
 
Do you know HLSDK is avalaible and you can read it for lot of references even if cs code is a bit different ?
It would have helped you a lot for this.


All times are GMT -4. The time now is 23:19.

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