Raised This Month: $51 Target: $400
 12% 

HELP needed : arrays reset on mapchange?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rthompson
Member
Join Date: Oct 2010
Old 11-28-2012 , 00:50   HELP needed : arrays reset on mapchange?
Reply With Quote #1

im working on a match plugin, which contains player info of previous map.
So when the plugin puts info of player to the array, it stays until the map changes, but after
map change is finished, the array is just empty.

array is created by CreateArray


new Handle:g_CapList = INVALID_HANDLE;
g_CapList = CreateArray(4);

Last edited by rthompson; 11-28-2012 at 02:07.
rthompson is offline
rthompson
Member
Join Date: Oct 2010
Old 11-28-2012 , 00:58   Re: arrays reset on mapchange?
Reply With Quote #2

Quote:
Originally Posted by mcpan313 View Post
PHP Code:
public OnMapStart()
{
    if (
g_CapList != INVALID_HANDLE)
    {
        
ClearArray(g_CapList);
    }


im not asking how to reset array but how to keep array from being reset
rthompson is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 11-28-2012 , 01:04   Re: arrays reset on mapchange?
Reply With Quote #3

Don't reset it. Magic! (It doesn't reset unless you tell it to reset somewhere.)
__________________
thetwistedpanda is offline
rthompson
Member
Join Date: Oct 2010
Old 11-28-2012 , 01:18   Re: arrays reset on mapchange?
Reply With Quote #4

Quote:
Originally Posted by thetwistedpanda View Post
Don't reset it. Magic! (It doesn't reset unless you tell it to reset somewhere.)
There is no resetting thats why im asking

Code:
 
 
new Handle:g_TestList = INVALID_HANDLE;
 
public OnPluginStart()
{
    g_TestList = CreateArray(16);
    RegConsoleCmd("sm_test", Command_Test, "sm_3");
}
public Action:Command_Test(client, args)
{
    if (args < 1)
    {
        ReplyToCommand(client, "%s sm_test <nick>", g_sSvName);
        return Plugin_Handled;
    }
    decl String:PlayerName[32];
    decl String:Name[32];
    GetCmdArg(1, PlayerName, sizeof(PlayerName));
 
    PushArrayString(g_TestList, PlayerName);
    new String:message[128];
    for (new i = 0; i < GetArraySize(g_TestList); i++)
    {
        GetArrayString(g_TestList, i, message, sizeof(message));
        PrintToAll(message);
    } 
 
    return Plugin_Handled;
}
thats how the plugins looks like

when i input command sm_test a
it replys

a

when i input command sm_test b
it replys

a
b

when i input command sm_test c
it replys

a
b
c

after map change, when i input command sm_test d
it should reply

a
b
c
d

but it returns

d

Last edited by rthompson; 11-28-2012 at 01:25.
rthompson is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-28-2012 , 12:22   Re: HELP needed : arrays reset on mapchange?
Reply With Quote #5

If you replace the plugin binary, it'll be reloaded on map change.
__________________
asherkin is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-29-2012 , 10:16   Re: HELP needed : arrays reset on mapchange?
Reply With Quote #6

Probably not related to the problem, but by

Code:
g_TestList = CreateArray(16);
you really meant
Code:
g_TestList = CreateArray(ByteCountToCells(MAX_NAME_LENGTH));
right?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
WinterLady
Junior Member
Join Date: May 2023
Old 05-26-2023 , 10:16   Re: HELP needed : arrays reset on mapchange?
Reply With Quote #7

Although this question is a really old one, I'm posting in case anyone is coming to this thread for a workaround still. I don't know what the reason is, but after testing, I learned dynamic arrays (ArrayList) and maps (like StringMap) get reset on map change. Other static variables didn't seem to get reset, so I tried the fixed-length array and that one didn't get reset.

I use linux, so am not sure if the behaviour is any different on windows.

I'll appreciate if anyone who knows the reason comes by and lets me know

Last edited by WinterLady; 05-26-2023 at 10:18.
WinterLady is offline
Reply



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 23:12.


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