PHP Code:
public Native_GetBestRound(Handle:plugin, numParams)
{
new client = GetNativeCell(1);
new style = GetNativeCell(2);
new track = GetNativeCell(3);
new String:auth[32];
if (!GetClientAuthString(client, auth, sizeof(auth))) {
return false;
}
new size = GetArraySize(g_hCache[style][track]);
for (new i = 0; i < size; i++)
{
new nCache[RecordCache];
GetArrayArray(g_hCache[style][track], i, nCache[0]);
if (StrEqual(nCache[Auth], auth))
{
SetNativeCellRef(4, nCache[Time]);
SetNativeCellRef(5, nCache[Jumps]);
return true;
}
}
return false;
}
PHP Code:
public Native_GetStyleRank(Handle:plugin, numParams)
{
new client = GetNativeCell(1);
new track = GetNativeCell(2);
new style = GetNativeCell(3);
new String:auth[32];
if (!GetClientAuthString(client, auth, sizeof(auth))) {
return 0;
}
new size = GetArraySize(g_hCache[style][track]);
for (new i = 0; i < size; i++)
{
new nCache[RecordCache];
GetArrayArray(g_hCache[style][track], i, nCache[0]);
if (StrEqual(nCache[Auth], auth)) {
return i+1;
}
}
return 0;
}
Is the best you're going to get without modifications outside of those functions, and probably isn't going to save you much at all. The GetArrayArray is indeed going to be expensive (depending on the size of the array) as it has to copy the contents. The best route forwards for these calls would be to have an additional cache in a StringMap keyed on the steamid (I'm going to guess that the current one cannot be easily converted as it is primarily used as an ordered list).
__________________