View Single Post
joaokb
Junior Member
Join Date: Apr 2021
Location: brazil
Old 04-19-2021 , 19:08   Re: Current map name edit in "find servers"
Reply With Quote #3

Quote:
Originally Posted by tarsisd2 View Post
try this:

PHP Code:
//#define REHLDS_SERVER
new const CONFIG_FILE[] = "fake_maps"

#include <amxmodx>

#if !defined REHLDS_SERVER
    #include <fakemeta>

    #define ALLOC_STRING(%0)         engfunc(EngFunc_AllocString, %0)

    
new Trie:g_tMapNamesg_iGlobalVar_MapName
#else
    #include <reapi>
#endif

public plugin_init()
{
    
register_plugin("Fake Map""0.3""Vaqtincha")
    
register_concmd("set_fakemap""ConCmd_ChangeMapName"ADMIN_CFG"set_fakemap < fake name > or < default >")

    new 
szMapName[32]
    
get_mapname(szMapNamecharsmax(szMapName))

#if !defined REHLDS_SERVER
    
g_tMapNames TrieCreate()

    
TrieSetCell(g_tMapNames"default"ALLOC_STRING(szMapName))

    new 
iGlobalVar is_linux_server() ? -0xC0 0x11320
    g_iGlobalVar_MapName 
engfunc(EngFunc_GetInfoKeyBuffer, -1) + iGlobalVar 0xC
#endif

    
LoadFakeList(szMapName)
}

public 
ConCmd_ChangeMapName(const pPlayer, const level)
{
    if(!(
get_user_flags(pPlayer) & level))
        return 
PLUGIN_HANDLED

    
if(read_argc() != 2)
    {
        
server_print("set_fakemap < fake name > or < default >")
        return 
PLUGIN_HANDLED
    
}

    new 
szMapName[32]
    
read_argv(1szMapNamecharsmax(szMapName))

    
SetMapName(szMapName)

    return 
PLUGIN_HANDLED
}

SetMapName(const szMapName[])
{
#if !defined REHLDS_SERVER
    
new iszNewName
    
// strtolower(szMapName)

    
if(!TrieGetCell(g_tMapNamesszMapNameiszNewName))
    {
        
iszNewName ALLOC_STRING(szMapName)
        
TrieSetCell(g_tMapNamesszMapNameiszNewName)
    }

    
UTIL__PatchMapName(iszNewName)

#else
    
if(equali(szMapName"default")) {
        
rh_reset_mapname()
    }
    else {
        
rh_set_mapname(szMapName)
    }
#endif
}

LoadFakeList(const szCurrentMapName[])
{
    new 
szConfigFile[256], pFile
    
new iLen get_localinfo("amxx_configsdir"szConfigFilecharsmax(szConfigFile))
    
formatex(szConfigFile[iLen], charsmax(szConfigFile) - iLen"%s/%s.ini"szConfigFile[iLen], CONFIG_FILE)

    if(!(
pFile fopen(szConfigFile"rt")))
        return

    new 
szBuffer[128], szFakeMapName[128]

    while(!
feof(pFile))
    {
        
fgets(pFileszBuffercharsmax(szBuffer))
        
trim(szBuffer)
    
        if(!
szBuffer[0] || szBuffer[0] == ';' || szBuffer[0] == '#')
            continue
    
        if(
szBuffer[0] == '[')
        {
            
copyc(szFakeMapNamecharsmax(szFakeMapName), szBuffer[1], ']')       
            continue
        }
    
        if(!
szFakeMapName[0])
        {
            
server_print("[FAKE MAP] Error: Invalid config file!")
            break
        }

        if(
equali(szCurrentMapNameszBuffer))
        {
            
server_print("[FAKE MAP] Info: Current map %s set to %s"szCurrentMapNameszFakeMapName)
            
SetMapName(szFakeMapName)
            break
        }
    }
}

// thanks to PRoSToTeM@, good idea.
// -- implemented hack: PRoSToTeM@
// -- by s1lent
stock UTIL__PatchMapName(const iszNewName)
{
    if(
iszNewName) {
        
set_tr2(g_iGlobalVar_MapNameTR_AllSolidiszNewName)
    }

PHP Code:
//#define REHLDS_SERVER 
- uncomment, if you have a ReHLDS server

cvar
PHP Code:
set_fakemap de_dust2 
you can also set different names for diff maps

PHP Code:
FakeMaps configuration file
;[name you want it to be]
name of the maps you want to change

[de_dust2]
de_dust2x2_sneg
de_dust2_snow


[de_inferno]
de_inferno_pro
de_inferno_xmas 

How can i talk to you in private bro?!
joaokb is offline