AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Anyone can check this code if it's correct? (https://forums.alliedmods.net/showthread.php?t=251524)

LJC 11-14-2014 16:26

Anyone can check this code if it's correct?
 
Hi, somehow I think that this my "home-made" plugin causes this error on my server:

sz_getspace: overflow on

Can anyone check if this code is written correctly and doesn't spam any commands to the client? Thanks.


Code:

#include <amxmodx>
#include <amxmisc>

new num
new map[32]
new pCvar_enableswap
new pCvar_swapround
new pCvar_boost
new pCvar_hidetime

public plugin_init()
{
        register_plugin("PapildomiLJC", "1.2", "arbata");
    get_mapname(map, charsmax(map))
        pCvar_enableswap = register_cvar("mp_swapspawns", "0")
        pCvar_swapround = register_cvar("mp_swapround", "0")
        pCvar_boost = register_cvar("hns_semiclip", "0")
        pCvar_hidetime = register_cvar("hns_hidetime", "20")
        set_task(3.0, "hns_mod")
        set_task(8.0, "check_random")
}

public check_random()
{
        num = random_num(5, 10);
        set_pcvar_num(pCvar_enableswap, 2)
        set_pcvar_num(pCvar_swapround, num)
}

public hns_mod()
{
        if(containi(map, "hns_") != -1) {   
        set_pcvar_num(pCvar_boost, 1);
                set_pcvar_num(pCvar_hidetime, 10);
    }
        else if(containi(map, "rayish_") != -1) {   
        set_pcvar_num(pCvar_boost, 1);
                set_pcvar_num(pCvar_hidetime, 10);
    }
        else if(containi(map, "c21_") != -1) {   
        set_pcvar_num(pCvar_boost, 1);
                set_pcvar_num(pCvar_hidetime, 10);
    }
}


Eagle07 11-15-2014 05:06

Re: Anyone can check this code if it's correct?
 
try to add
Code:

public hns_mod()
{
        get_mapname(map, charsmax(map) - 1);
        if(containi(map, "hns_") != -1) {   
                set_pcvar_num(pCvar_boost, 1);
                set_pcvar_num(pCvar_hidetime, 10);
        }
        else if(containi(map, "rayish_") != -1) {   
                set_pcvar_num(pCvar_boost, 1);
                set_pcvar_num(pCvar_hidetime, 10);
        }
        else if(containi(map, "c21_") != -1) {   
                set_pcvar_num(pCvar_boost, 1);
                set_pcvar_num(pCvar_hidetime, 10);
        }
}


HamletEagle 11-15-2014 06:03

Re: Anyone can check this code if it's correct?
 
Code:
get_mapname(map, charsmax(map) - 1);
You have no ideea what you are doing. charsmax already do sizeof -1 so you would have sizeof-2


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

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