AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can I fix it? (https://forums.alliedmods.net/showthread.php?t=250317)

csaba1998 10-22-2014 02:29

How can I fix it?
 
This works perfectly, when the map is hd_harlem.
But I change map to de_dust2, don't work.

Code:

new allow_maps[][][] = {
        { "hd_harlem", "Hidden City" }, 
        { "de_dust2",  "Dust2"      }     
}

public plugin_init()
{
        register_dictionary(DICTIONARY)

        new map_name[32], buffer[128], index
        get_mapname(map_name, 31)

        for(index=0;index<sizeof(allow_maps);index++)
        {
                if(equali(map_name, allow_maps[index][0]))
                {
                        Patch_MapName(allow_maps[index][1])
                        break
                }

                else
                {
                        formatex(buffer, sizeof(buffer), "%L", LANG_SERVER, "HIDDEN_WRONG_MAP")
                        set_fail_state(buffer)
                        return
                }
             
        }
}


Jhob94 10-22-2014 05:53

Re: How can I fix it?
 
new allow_maps[][][] = {
{ "hd_harlem", "Hidden City" },
{ "de_dust2", "Dust2" }
}

Try:

new allow_maps[][][] = {
{ "", "" },
{ "hd_harlem", "Hidden City" },
{ "de_dust2", "Dust2" }
}

Because the first line is 0 andyour first index is 1. Thats the problem i guess

HamletEagle 10-22-2014 09:41

Re: How can I fix it?
 
Why your maps const is three dimensional ? It should be two.
@Jhob, what do you mean ? The loop starts from 0 and hd_harlem has already index 0 :)

claudiuhks 10-22-2014 10:02

Re: How can I fix it?
 
Fast tested with Visual Studio (for C) and it worked properly.
You might check out the picture (view raw image) so you know what to change. Some numbers were set.
I don't really know how to fix it properly for AMX Mod X that way (as you prepared the array), I might give you a wrong example.

Quote:

Originally Posted by HamletEagle (Post 2214417)
Why your maps const is three dimensional ? It should be two.
@Jhob, what do you mean ? The loop starts from 0 and hd_harlem has already index 0 :)

It's OK what he did. What the thread's starter did.

fysiks 10-22-2014 19:54

Re: How can I fix it?
 
Quote:

Originally Posted by Jhob94 (Post 2214355)
new allow_maps[][][] = {
{ "hd_harlem", "Hidden City" },
{ "de_dust2", "Dust2" }
}

Try:

new allow_maps[][][] = {
{ "", "" },
{ "hd_harlem", "Hidden City" },
{ "de_dust2", "Dust2" }
}

Because the first line is 0 andyour first index is 1. Thats the problem i guess

No. That is wrong.

Quote:

Originally Posted by csaba1998 (Post 2214303)
This works perfectly, when the map is hd_harlem.
But I change map to de_dust2, don't work.

Code:

new allow_maps[][][] = {
        { "hd_harlem", "Hidden City" }, 
        { "de_dust2",  "Dust2"      }     
}

public plugin_init()
{
        register_dictionary(DICTIONARY)

        new map_name[32], buffer[128], index
        get_mapname(map_name, 31)

        for(index=0;index<sizeof(allow_maps);index++)
        {
                if(equali(map_name, allow_maps[index][0]))
                {
                        Patch_MapName(allow_maps[index][1])
                        break
                }

                else
                {
                        formatex(buffer, sizeof(buffer), "%L", LANG_SERVER, "HIDDEN_WRONG_MAP")
                        set_fail_state(buffer)
                        return
                }
             
        }
}


Take a second to run through the execution of the code in your head. What happens when the map is de_dust2 and the for loop starts? What happens (especially when it checks to see if the map is hd_harlem)?

NikKOo31 10-23-2014 12:59

Re: How can I fix it?
 
PHP Code:

new allow_maps[][][] = {
    { 
"hd_harlem""Hidden City" },  
    { 
"de_dust2",  "Dust2"       }       
}

public 
plugin_init()
{
        
register_dictionary(DICTIONARY)

    new 
map_name[32], buffer[128], mapindex = -1
    get_mapname
(map_name31)

    for(new 
index=0;index<sizeof(allow_maps);index++)
    {
        if(
equali(map_nameallow_maps[index][0]))
        {
            
mapindex index
            
break
        }

    }

    if(
mapindex > -1)
    {
        
Patch_MapName(allow_maps[mapindex][1])
    }
    else
    {
        
formatex(buffersizeof(buffer), "%L"LANG_SERVER"HIDDEN_WRONG_MAP")
        
set_fail_state(buffer)
    }


:bee:


All times are GMT -4. The time now is 17:44.

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