Raised This Month: $32 Target: $400
 8% 

Change Mapname


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-17-2018 , 14:12   Change Mapname
Reply With Quote #1

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);
            }
        }
    }

PurposeLessx is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-17-2018 , 14:41   Re: Change Mapname
Reply With Quote #2

Its because you are storing configs directory and mapnames in the same array.
__________________
CrAzY MaN is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-17-2018 , 14:48   Re: Change Mapname
Reply With Quote #3

Quote:
Originally Posted by CrAzY MaN View Post
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".
PurposeLessx is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-17-2018 , 14:50   Re: Change Mapname
Reply With Quote #4

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

Its rarely gonna return true, if ever.
__________________
stuff
maqi is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-17-2018 , 15:03   Re: Change Mapname
Reply With Quote #5

What are you trying to do with this?
PHP Code:
   if(equal(dataleft)) 
__________________
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-17-2018 , 15:09   Re: Change Mapname
Reply With Quote #6

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.

Last edited by PurposeLessx; 06-17-2018 at 15:10.
PurposeLessx is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-18-2018 , 07:03   Re: Change Mapname
Reply With Quote #7

Still no working. Where is the mistake ? :S

Spoiler
PurposeLessx is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 06-18-2018 , 07:21   Re: Change Mapname
Reply With Quote #8

What is left and right?
__________________
CrAzY MaN is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-18-2018 , 07:21   Re: Change Mapname
Reply With Quote #9

Put some debug messages. Output both mapname and left, also put a message inside the if check.
That's how you fix bugs.
__________________
HamletEagle is offline
PurposeLessx
Senior Member
Join Date: Jun 2017
Old 06-18-2018 , 07:25   Re: Change Mapname
Reply With Quote #10

Quote:
Originally Posted by CrAzY MaN View Post
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.
PurposeLessx is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:15.


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