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

[Help] Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bally
Senior Member
Join Date: Aug 2015
Old 10-13-2015 , 13:56   [Help] Error
Reply With Quote #1

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:446: [SM] Native "ArrayList.GetString" reported: Invalid index 6 (count: 2)
L 10/13/2015 - 19:446: [SM] Displaying call stack trace for plugin "AdsAdvanced.smx":
L 10/13/2015 - 19:446: [SM] [0] Line 258, /groups/sourcemod/upload_tmp/textqdfvPR.sp::GetURLData()
L 10/13/2015 - 19:446: [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
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 10-13-2015 at 13:58.
bally is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 10-13-2015 , 16:10   Re: [Help] Error
Reply With Quote #2

Edit: Nvm wrong
__________________

Last edited by Chaosxk; 10-13-2015 at 16:15.
Chaosxk is offline
bally
Senior Member
Join Date: Aug 2015
Old 10-14-2015 , 19:30   Re: [Help] Error
Reply With Quote #3

thanks for trying, even if you didn't found the solution.
__________________
Perhaps my lack of faith was my undoing,
bally is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 10-15-2015 , 01:16   Re: [Help] Error
Reply With Quote #4

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.
__________________
Chaosxk is offline
bally
Senior Member
Join Date: Aug 2015
Old 10-15-2015 , 11:38   Re: [Help] Error
Reply With Quote #5

Quote:
Originally Posted by Chaosxk View Post
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
__________________
Perhaps my lack of faith was my undoing,

Last edited by bally; 10-15-2015 at 11:38.
bally is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 10-15-2015 , 13:33   Re: [Help] Error
Reply With Quote #6

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.
__________________

Last edited by Chaosxk; 10-15-2015 at 13:33.
Chaosxk is offline
bally
Senior Member
Join Date: Aug 2015
Old 10-15-2015 , 13:35   Re: [Help] Error
Reply With Quote #7

Quote:
Originally Posted by Chaosxk View Post
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
__________________
Perhaps my lack of faith was my undoing,
bally is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 10-15-2015 , 14:19   Re: [Help] Error
Reply With Quote #8

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
__________________
Chaosxk is offline
bally
Senior Member
Join Date: Aug 2015
Old 10-15-2015 , 16:22   Re: [Help] Error
Reply With Quote #9

thanks what about index on the temp entities do they start from 0?
__________________
Perhaps my lack of faith was my undoing,
bally is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 10-15-2015 , 19:21   Re: [Help] Error
Reply With Quote #10

I don't know its from your code.
__________________
Chaosxk is offline
Reply


Thread Tools
Display Modes

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 11:30.


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