AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [Help] Error (https://forums.alliedmods.net/showthread.php?t=273147)

bally 10-13-2015 13:56

[Help] Error
 
Hey guys, I developed a plugin that consisted in displaying a decal on player feet when they spawn. That works fine, I also added a tracer to check which entity index the player is looking at, that also seems to be working fine, now I tried to add a new config for URL in motd, I'm getting array errors
" L 10/13/2015 - 19:44:36: [SM] Native "ArrayList.GetString" reported: Invalid index 6 (count: 2)
L 10/13/2015 - 19:44:36: [SM] Displaying call stack trace for plugin "AdsAdvanced.smx":
L 10/13/2015 - 19:44:36: [SM] [0] Line 258, /groups/sourcemod/upload_tmp/textqdfvPR.sp::GetURLData()
L 10/13/2015 - 19:44:36: [SM] [1] Line 104, /groups/sourcemod/upload_tmp/textqdfvPR.sp::OnPlayerRunCmd()
"... I know what they mean, however I don't know why they happen.

Could anyone help me fix them please?

Thanks in advance.


Source: https://www.dropbox.com/s/zuzye9dcim...201.23.sp?dl=0

Chaosxk 10-13-2015 16:10

Re: [Help] Error
 
Edit: Nvm wrong

bally 10-14-2015 19:30

Re: [Help] Error
 
:) thanks for trying, even if you didn't found the solution.

Chaosxk 10-15-2015 01:16

Re: [Help] Error
 
Not sure what you were trying to do but your pushing decal into an array(1) everytime it spawns. Then your pushing in kv entries into another array(2). Then your using the size of array(2) to loop through the indexes on array(1). The size will always be different, it's why your getting array errors. I don't know what your trying to accomplish but i think you need to do a different way.

bally 10-15-2015 11:38

Re: [Help] Error
 
Quote:

Originally Posted by Chaosxk (Post 2353188)
Not sure what you were trying to do but your pushing decal into an array(1) everytime it spawns. Then your pushing in kv entries into another array(2). Then your using the size of array(2) to loop through the indexes on array(1). The size will always be different, it's why your getting array errors. I don't know what your trying to accomplish but i think you need to do a different way.

check what spray index client is looking and when press E display a motd with the url specified in Kv for each individual spray client is looking, you got any idea? I managed to work and detect whenever a client is looking at a temp spray ent trough location

Chaosxk 10-15-2015 13:33

Re: [Help] Error
 
You can use Tries/Hashmap instead of arrays to store the "index" and "url" when loading KV. Then you can search the Hashmap using the index as lookup.

Or

When you created the spray, create a DataPack that stores index and url. Then you can compare the index and extract the url later.

I think 1st method might be easier to work with.

bally 10-15-2015 13:35

Re: [Help] Error
 
Quote:

Originally Posted by Chaosxk (Post 2353376)
You can use Tries/Hashmap instead of arrays to store the "index" and "url" when loading KV. Then you can search the Hashmap using the index as lookup.

Or

When you created the spray, create a DataPack that stores index and url. Then you can compare the index and extract the url later.

I think 1st method might be easier to work with.

example code if you wouldn't mind

Chaosxk 10-15-2015 14:19

Re: [Help] Error
 
E.G. don't rely too much on this code, i wrote this quickly.
This is just an example, your gonna have to work with it to get what you want.

Code:

StringMap HashMap;

public void OnPluginStart() {
        HashMap = new StringMap();
}

//some method to call kv
Handle kv = CreateKeyValues("mykeyvalues");
char sIndex[8], sURL[64];
do {
        kv.GetSectionName(sIndex, sizoef(sIndex));
        kv.GetString("url", sURL, sizeof(sURL));
        HashMap.SetString(sIndex, url, false);
} while kv.GotoNextKey();

//To extract
char sIndex[8], sURL[64];
temp = g_iUserLookingIndex[client];
Format(sIndex, sizeof(sIndex), "%d", temp);
HashMap.GetString(sIndex, sURL, sizeof(sURL));
//do whatever with the url


bally 10-15-2015 16:22

Re: [Help] Error
 
thanks :) what about index on the temp entities do they start from 0?

Chaosxk 10-15-2015 19:21

Re: [Help] Error
 
I don't know its from your code.


All times are GMT -4. The time now is 22:41.

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