Raised This Month: $ Target: $400
 0% 

[CLOSED]KeyValues load same name key (Iterate)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nerus
Senior Member
Join Date: Aug 2010
Location: Poland
Old 03-23-2016 , 10:21   [CLOSED]KeyValues load same name key (Iterate)
Reply With Quote #1

Hi, I have question about KV:

Quote:
Is a way to iterate on all keys with same names
Example:
Quote:
"Hostages"
{
"model" "models/hostage_01.mdl"
"model" "models/hostage_02.mdl"
"model" "models/hostage_03.mdl"
"model" "models/hostage_04.mdl"
}
Regards,
Nerus

Last edited by Nerus; 03-31-2016 at 07:41. Reason: Close task without solving problem
Nerus is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 03-23-2016 , 14:47   Re: KeyValues load same name key (Iterate)
Reply With Quote #2

You can put a number after each model entry starting at one and then iterate through code. Example:
PHP Code:
new 1String:name[8], String:value[64];
while(
true){
    
Format(namesizeof(name), "model%d"i);
    
KvGetString(HANDLEnamevaluesizeof(value));
    if(!
StrEqual(value"")){
        
//Do stuff with value string
    
}else{
        break;
    }
    
i++;


Last edited by thecount; 03-23-2016 at 14:47.
thecount is offline
Nerus
Senior Member
Join Date: Aug 2010
Location: Poland
Old 03-31-2016 , 07:40   Re: KeyValues load same name key (Iterate)
Reply With Quote #3

@thecount I was thinking about your solution before, but I wanted to ask if there is another method, anyway thanks for your help.

Regards,
Nerus.
Nerus is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 03-31-2016 , 08:05   Re: [CLOSED]KeyValues load same name key (Iterate)
Reply With Quote #4

I guess you can just iterate all nodes in kv structure and that would give you all keys even with the same name. I am not really sure about that, I never tried...

P.S.: Read the keyvalues functions doc and wiki. There is a lot of info.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick 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:45.


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