misterM Posted February 16, 2015 Share Posted February 16, 2015 (edited) Well I need to do a check using libconfig, I'm creating a custom conf file. { NPC = "Name const" Effect = Name const } if (!config_setting_lookup_string(rs, "Name", &var) { ShowWarning("NPC: NPC name '%s' unknown\n", name); continue; } How can I make to the NPC and Effect option check if name exists in the const Edited February 16, 2015 by misterM Quote Link to comment Share on other sites More sharing options...
Cydh Posted February 16, 2015 Share Posted February 16, 2015 use ... int n = 0; if (!script_get_constant(var, &n)) // const value not found ... Hello Cydh, I had tried to do this before, but it didn't work out, always shows that npceffect was not found in const. that's why I said this above^^^^ npceffect: ( { NPC = "4_M_ORIENT01" Effect = "EF_SC_ESCAPE" } ) npceff = config_lookup(&npceffect_conf, "npceffect"); if (npceff != NULL) { while ((npcef = config_setting_get_elem(npceffect_conf.root, i++))) { const char *namevar = config_setting_name(npcef); if (!config_setting_lookup_string(npcef, "NPC", &var)) { ShowWarning("npceffect_conf: NPC name '%s' unknown.\n", namevar); continue; } if (!config_setting_lookup_string(npcef, "Effect", &var)) { ShowWarning("npceffect_conf: Effect '%s' unknown.\n", namevar); continue; } } } ... ... int eff_id = -1; ... if (config_setting_lookup_string(npcef, "Effect", &var)) script_get_constant(var, &eff_id); if (eff_id == -1) { ShowWarning("npceffect_conf: Effect '%s' unknown.\n", var); continue; } else ShowInfo("npceffect_conf: Effect '%d'\n", eff_id); ... ... Quote Link to comment Share on other sites More sharing options...
Cydh Posted February 16, 2015 Share Posted February 16, 2015 use ... int n = 0; if (!script_get_constant(var, &n)) // const value not found ... Quote Link to comment Share on other sites More sharing options...
misterM Posted February 16, 2015 Author Share Posted February 16, 2015 use ... int n = 0; if (!script_get_constant(var, &n)) // const value not found ... Hello Cydh, I had tried to do this before, but it didn't work out, always shows that npceffect was not found in const. npceffect: ( { NPC = "4_M_ORIENT01" Effect = "EF_SC_ESCAPE" } ) npceff = config_lookup(&npceffect_conf, "npceffect"); if (npceff != NULL) { while ((npcef = config_setting_get_elem(npceffect_conf.root, i++))) { const char *namevar = config_setting_name(npcef); if (!config_setting_lookup_string(npcef, "NPC", &var)) { ShowWarning("npceffect_conf: NPC name '%s' unknown.\n", namevar); continue; } if (!config_setting_lookup_string(npcef, "Effect", &var)) { ShowWarning("npceffect_conf: Effect '%s' unknown.\n", namevar); continue; } } } Quote Link to comment Share on other sites More sharing options...
misterM Posted February 16, 2015 Author Share Posted February 16, 2015 (edited) ... ... int eff_id = -1; ... if (config_setting_lookup_string(npcef, "Effect", &var)) script_get_constant(var, &eff_id); if (eff_id == -1) { ShowWarning("npceffect_conf: Effect '%s' unknown.\n", var); continue; } else ShowInfo("npceffect_conf: Effect '%d'\n", eff_id); ... ... Thanks Cydh is working. Edited February 17, 2015 by misterM Quote Link to comment Share on other sites More sharing options...
Well I need to do a check using libconfig, I'm creating a custom conf file.
{ NPC = "Name const" Effect = Name const }if (!config_setting_lookup_string(rs, "Name", &var) { ShowWarning("NPC: NPC name '%s' unknown\n", name); continue; }How can I make to the NPC and Effect option check if name exists in the const
Edited by misterMLink to comment
Share on other sites