Hallo people
I made this little plugin, to show what the problem is
PHP Code:
#include <sourcemod>
#pragma semicolon 1
new Handle:Array;
public Plugin:myinfo =
{
name = "Array-BUG",
author = "KK",
description = "Array-BUG ex",
version = "1.0",
url = "http://www.attack2.co.cc/"
};
public OnPluginStart()
{
Array = CreateArray(4);
RegConsoleCmd("sm_acurrnet", Command_aCurrent);
RegConsoleCmd("sm_aset", Command_aSet);
}
public Action:Command_aCurrent(client, args)
{
new index = FindValueInArray(Array, GetClientUserId(client));
new any:cell1 = GetArrayCell(Array, index, 1);
new any:cell2 = GetArrayCell(Array, index, 2);
new any:cell3 = GetArrayCell(Array, index, 3);
PrintToChat(client, "Cell 1 %f | 2 %f | 2 %f", cell1, cell2, cell3);
}
public Action:Command_aSet(client, args)
{
new index = FindValueInArray(Array, GetClientUserId(client));
SetArrayCell(Array, index, 9.0, 1);
SetArrayCell(Array, index, 8.0, 2);
SetArrayCell(Array, index, 7.0, 3);
PrintToChat(client, "Done");
}
public OnClientPostAdminCheck(client)
{
PrintToServer("2Before size %i", GetArraySize(Array));
PushArrayCell(Array, GetClientUserId(client));
PrintToServer("2After size %i", GetArraySize(Array));
}
public OnClientDisconnect(client)
{
new index = FindValueInArray(Array, GetClientUserId(client));
PrintToServer("Before size %i", GetArraySize(Array));
if (index != -1)
{
PrintToServer("Removed");
RemoveFromArray(Array, index);
}
PrintToServer("After size %i", GetArraySize(Array));
PrintToServer("ClientDisconnect");
}
PHP Code:
public OnClientPostAdminCheck(client)
{
PrintToServer("2Before size %i", GetArraySize(Array));
PushArrayCell(Array, GetClientUserId(client));
PrintToServer("2After size %i", GetArraySize(Array));
}
When a player join the server, become their userid pushed to my array named array
If this player type sm_acurrnet in console, he get:
Code:
Cell 1 -0.000027 | 2 0.000000 | 2 0.000000
Normal?
after that he type sm_aset in chat, and then sm_acurrent and he get:
Code:
Cell 1 9.000000 | 2 8.000000 | 2 7.000000
Now he rejoin, and type sm_acurrent, and get:
Code:
Cell 1 9.000000 | 2 8.000000 | 2 7.000000
WTF?
Why do i get this?, I've removed the array index, which stores this information when you disconnect
PHP Code:
public OnClientDisconnect(client)
{
new index = FindValueInArray(Array, GetClientUserId(client));
PrintToServer("Before size %i", GetArraySize(Array));
if (index != -1)
{
PrintToServer("Removed");
RemoveFromArray(Array, index);
}
PrintToServer("After size %i", GetArraySize(Array));
PrintToServer("ClientDisconnect");
}
When this player disconnect, i get:
Code:
Before size 1
Removed
After size 0
In my server console!
PHP Code:
public OnClientPostAdminCheck(client)
{
PrintToServer("2Before size %i", GetArraySize(Array));
PushArrayCell(Array, GetClientUserId(client));
PrintToServer("2After size %i", GetArraySize(Array));
}
When i have PostAdminCheck, i get:
Code:
2Before size 0
2After size 1
Do i something wrong?, are it normally? or a bug?
(hope you understand, not the best to English
)