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

ZombieClasses.ini File Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-29-2020 , 08:08   Re: ZombieClasses.ini File Problem
Reply With Quote #31

Quote:
Originally Posted by alferd View Post
Code:
load_customization_from_files() {     // Build zombie classes file path     new path[64]     get_configsdir(path, charsmax(path))     format(path, charsmax(path), "%s/%s", path, BB_ZOMBIECLASSES_FILE)         // File not present     if (!file_exists(path))     {         new error[100]         formatex(error, charsmax(error), "Cannot load customization file %s!", path)         set_fail_state(error)         return;     }         // Set up some vars to hold parsing info     new linedata[1024], key[64], value[960]//, section, teams         // Parse if present     if (file_exists(path))     {         // Open zombie classes file for reading         new file = fopen(path, "rt")                 while (file && !feof(file))         {             // Read one line at a time             fgets(file, linedata, charsmax(linedata))                         // Replace newlines with a null character to prevent headaches             replace(linedata, charsmax(linedata), "^n", "")                         // Blank line or comment             if (!linedata[0] || linedata[0] == ';') continue;                         // New class starting             if (linedata[0] == '[')             {                 // Remove first and last characters (braces)                 linedata[strlen(linedata) - 1] = 0                 copy(linedata, charsmax(linedata), linedata[1])                                 // Store its real name for future reference                 ArrayPushString(g_zclass2_realname, linedata)                 continue;             }                         // Get key and value(s)             strtok(linedata, key, charsmax(key), value, charsmax(value), '=')                         // Trim spaces             trim(key)             trim(value)                         if (equal(key, "NAME"))                 ArrayPushString(g_zclass2_name, value)             else if (equal(key, "INFO"))                 ArrayPushString(g_zclass2_info, value)             else if (equal(key, "MODELS"))             {                 // Set models start index                 ArrayPushCell(g_zclass2_modelsstart, ArraySize(g_zclass2_playermodel))                                 // Parse class models                 while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))                 {                     // Trim spaces                     trim(key)                     trim(value)                                         // Add to class models array                     ArrayPushString(g_zclass2_playermodel, key)                     ArrayPushCell(g_zclass_modelindex, -1)                 }                                 // Set models end index                 ArrayPushCell(g_zclass2_modelsend, ArraySize(g_zclass2_playermodel))             }             else if (equal(key, "CLAWMODEL"))                 ArrayPushString(g_zclass2_clawmodel, value)             else if (equal(key, "HEALTH"))                 ArrayPushCell(g_zclass2_hp, str_to_num(value))             else if (equal(key, "SPEED"))                 ArrayPushCell(g_zclass2_spd, str_to_num(value))             else if (equal(key, "GRAVITY"))                 ArrayPushCell(g_zclass2_grav, str_to_float(value))             else if (equal(key, "FLAG"))            ArrayPushString(g_zclass2_admin, value)                 }         if (file) fclose(file)     } } save_customization() {     new i, k, buffer[512]         // Build zombie classes file path     new path[64]     get_configsdir(path, charsmax(path))     format(path, charsmax(path), "%s/%s", path, BB_ZOMBIECLASSES_FILE)         // Open zombie classes file for appending data     new file = fopen(path, "at"), size = ArraySize(g_zclass_name)     // Add any new zombie classes data at the end if needed     for (i = 0; i < size; i++)     {         if (ArrayGetCell(g_zclass_new, i))         {             // Add real name             ArrayGetString(g_zclass_name, i, buffer, charsmax(buffer))             format(buffer, charsmax(buffer), "^n[%s]", buffer)             fputs(file, buffer)                         // Add caption             ArrayGetString(g_zclass_name, i, buffer, charsmax(buffer))             format(buffer, charsmax(buffer), "^nNAME = %s", buffer)             fputs(file, buffer)                         // Add info             ArrayGetString(g_zclass_info, i, buffer, charsmax(buffer))             format(buffer, charsmax(buffer), "^nINFO = %s", buffer)             fputs(file, buffer)                         // Add models             for (k = ArrayGetCell(g_zclass_modelsstart, i); k < ArrayGetCell(g_zclass_modelsend, i); k++)             {                 if (k == ArrayGetCell(g_zclass_modelsstart, i))                 {                     // First model, overwrite buffer                     ArrayGetString(g_zclass_playermodel, k, buffer, charsmax(buffer))                 }                 else                 {                     // Successive models, append to buffer                     ArrayGetString(g_zclass_playermodel, k, path, charsmax(path))                     format(buffer, charsmax(buffer), "%s , %s", buffer, path)                 }             }             format(buffer, charsmax(buffer), "^nMODELS = %s", buffer)             fputs(file, buffer)                         // Add clawmodel             ArrayGetString(g_zclass_clawmodel, i, buffer, charsmax(buffer))             format(buffer, charsmax(buffer), "^nCLAWMODEL = %s", buffer)             fputs(file, buffer)                         // Add health             formatex(buffer, charsmax(buffer), "^nHEALTH = %d", ArrayGetCell(g_zclass_hp, i))             fputs(file, buffer)                         // Add speed             formatex(buffer, charsmax(buffer), "^nSPEED = %d", ArrayGetCell(g_zclass_spd, i))             fputs(file, buffer)                         // Add gravity             formatex(buffer, charsmax(buffer), "^nGRAVITY = %.2f", Float:ArrayGetCell(g_zclass_grav, i))             fputs(file, buffer)                         // Add adminflags        ArrayGetString(g_zclass_admin, i, buffer, charsmax(buffer))             format(buffer, charsmax(buffer), "^nFLAG = %s", buffer)             fputs(file, buffer)                     }     }     fclose(file) }

load and save file
I did it before and i got the samething it showing flagname without flag grades

FLAG =
Supremache is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-29-2020 , 08:37   Re: ZombieClasses.ini File Problem
Reply With Quote #32

Did you test the code I sent?
alferd is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-29-2020 , 09:51   Re: ZombieClasses.ini File Problem
Reply With Quote #33

Quote:
Originally Posted by alferd View Post
Did you test the code I sent?
Yep, Same thing

Last edited by Supremache; 06-29-2020 at 09:52.
Supremache 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 10:41.


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