Thread: Keyvalues
View Single Post
Author Message
marquezs
Member
Join Date: Jun 2010
Old 09-06-2012 , 10:52   Keyvalues
Reply With Quote #1

Hello, I'm trying to get the value of a key, and I've tried many ways and it still doesn't work... there's no errors in the compilation, but I can't get the name of key, when I do a print chat it doesn't show anything.

here my config file


test.cfg
Code:
"Test"
{
	"name" "jesus"
}
function which grabs key value
Code:
public motd(client, target) {

	
    new String:sPath[PLATFORM_MAX_PATH]; 

    BuildPath(Path_SM, sPath, sizeof(sPath), "configs/test.cfg"); 
	
	new String:sVal[64]; 
    if(!FileExists(sPath)) { 
        PrintToChat(client, "Error"); 
        return; 
    } 

    new Handle:KV = CreateKeyValues("Test"); 
    FileToKeyValues(KV, sPath); 


    KvGetString(KV, "name", sVal, sizeof(sVa)); 
    PrintToChat(client, "good to go %s", sVal)
Thanks

Last edited by marquezs; 09-06-2012 at 10:56. Reason: edit: forgot to put an l but the was an issue of copy/paste, in my original code it's ok
marquezs is offline