AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] map info (https://forums.alliedmods.net/showthread.php?t=110284)

ujjl 11-27-2009 18:01

[Help] map info
 
How can i get the mapname played?

master4life 11-27-2009 18:09

Re: [Help] map info
 
lol
PHP Code:

#include < amxmodx >

public plugin_init( ) {
    
register_plugin"Mapname""beta""wtf" );
    
    
register_clcmd"say /mapname""CmdMap" );    
}

public 
CmdMapid ) {
    new 
szMapname32 ];
    
get_mapnameszMapname31 );
    
    
client_printidprint_chat"%s"szMapname );



ujjl 11-27-2009 18:31

Re: [Help] map info
 
:D

matsi 11-27-2009 19:02

Re: [Help] map info
 
Type /currentmap or currentmap don't know which one but it should be default amx commnd iirc. :) But you can also see current map from status.

Alucard^ 11-27-2009 21:03

Re: [Help] map info
 
Quote:

Originally Posted by matsi (Post 1000814)
Type /currentmap or currentmap don't know which one but it should be default amx commnd iirc. :) But you can also see current map from status.

Yes but he is in scripting help, so... i think he don't want to know what mapname played, he want to know HOW TO DETECT that =p.

ConnorMcLeod 11-27-2009 22:37

Re: [Help] map info
 
You can save it as global if you know you gonna need it lot of times.

PHP Code:

#include < amxmodx >

new g_szMapName[32]

public 
plugin_init( )
{
    
register_plugin"Mapname""beta""wtf" )

    
register_clcmd"say /mapname""CmdMap" )

    
get_mapnameg_szMapNamecharsmax(g_szMapName) )
}

public 
CmdMapid )
{    
    
client_printidprint_chat"%s"g_szMapName )



ujjl 11-28-2009 16:35

Re: [Help] map info
 
I want to apply map specific settings so i need to know if there is a map-named config file present in my mod directory.

eg if the played map is sev_leggo, and a sev_leggo.cfg file present in /valve/addons/sev09/maps folder, then i want to open it read data from there and close it. if there is no config file, then we dont have to do anything.

fysiks 11-28-2009 17:13

Re: [Help] map info
 
Quote:

Originally Posted by ujjl (Post 1001309)
I want to apply map specific settings so i need to know if there is a map-named config file present in my mod directory.

Just use the map specific configs that are built into AMX Mod X.

ujjl 11-28-2009 17:17

Re: [Help] map info
 
i have to read data, not setting cvars ...

like:
item_healthkit 324.0 234.0 123.0
item_battery 1231.0 123.0 310.0

fysiks 11-28-2009 17:25

Re: [Help] map info
 
PHP Code:

new szMapName[32], szFilePath[128]
get_mapname(szMapNamecharsmax(szMapName))

formatex(szFilePathcharsmax(szFilePath), "addons/sev09/maps/%s.cfg"szMapName)

new 
fopen(szFilePath"rt")

if(
f)
{
    
// File exists and is open to start reading.
    
new szData[64]
    
    while( !
feof(f) )
    {
        
fgets(szDatacharsmax(szData))
        
trim(szData)
        
        
// szData contains a line from the file.
        // Do something with it :).
    
}
    
fclose(f)


Here ya go :).


All times are GMT -4. The time now is 13:40.

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