AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Change Mapname (https://forums.alliedmods.net/showthread.php?t=308355)

PurposeLessx 06-17-2018 14:12

Change Mapname
 
I made a mapname changer but I have a problem about file (.ini)
Plugin doesn't get any mapname and change mapname.

PHP Code:

#include <amxmodx>
#include <reapi>

public plugin_init() {
    
register_plugin("MapName""1.1""PurposeLess")

    
load_file()
}

public 
load_file()
{
    new 
filename[64];
    
get_localinfo("amxx_configsdir"filenamecharsmax(filename));
    
format(filenamecharsmax(filename), "%s/map_ismi.ini"filename);

    new 
file fopen(filename"rt");

    new 
data[182], left[64], right[64], mapname[32];
    if(
file)
    {
        while(!
feof(file))
        {
            
fgets(filedatacharsmax(data));
            
trim(data);

            if(
data[0] == ';')
            {
                continue;
            }

            
argbreak(dataleftcharsmax(left), rightcharsmax(right));
            
get_mapname(mapnamecharsmax(mapname));

            if(
equal(dataleft))
            {
                
remove_quotes(right);
                
rh_set_mapname(right);
            }
        }
    }



CrAzY MaN 06-17-2018 14:41

Re: Change Mapname
 
Its because you are storing configs directory and mapnames in the same array.

PurposeLessx 06-17-2018 14:48

Re: Change Mapname
 
Quote:

Originally Posted by CrAzY MaN (Post 2597528)
Its because you are storing configs directory and mapnames in the same array.

It works with using "read_file" but doesn't work with using "fopen".
There is no problem about same file. It breaks "left" and "right".

maqi 06-17-2018 14:50

Re: Change Mapname
 
You can't compare this
Code:
if(equal(data, left))

Its rarely gonna return true, if ever.

HamletEagle 06-17-2018 15:03

Re: Change Mapname
 
What are you trying to do with this?
PHP Code:

   if(equal(dataleft)) 


PurposeLessx 06-17-2018 15:09

Re: Change Mapname
 
What I should do instead? I have to check the map is equal to left.
Omg it should be mapname instead of data !!! I got it.

PurposeLessx 06-18-2018 07:03

Re: Change Mapname
 
Still no working. Where is the mistake ? :S

Spoiler

CrAzY MaN 06-18-2018 07:21

Re: Change Mapname
 
What is left and right?

HamletEagle 06-18-2018 07:21

Re: Change Mapname
 
Put some debug messages. Output both mapname and left, also put a message inside the if check.
That's how you fix bugs.

PurposeLessx 06-18-2018 07:25

Re: Change Mapname
 
Quote:

Originally Posted by CrAzY MaN (Post 2597673)
What is left and right?

Left is mapname, Right is new mapname. File is like that

If mapname is equal to left, mapname is going to be right.
Code:

"de_dust2" "dust2"
"de_dust2_long" "dust2_long"
"fy_iceword16" "iceword"

I don't have anywhere I can test everytime because players are not happy for changin mapname always.


All times are GMT -4. The time now is 14:53.

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