Raised This Month: $ Target: $400
 0% 

ZombieClasses.ini File Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-26-2020 , 09:29   Re: ZombieClasses.ini File Problem
Reply With Quote #1

Quote:
Originally Posted by Supremache View Post
Give me example plz
Code:
new flags = (ADMIN_IMMUNITY | ADMIN_BAN) // bits to string new flags_str[15] get_flags(flags, flags_str, charsmax(flags_str)) // string to bits flags = read_flags(flags_str)
__________________








CrazY. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-26-2020 , 09:37   Re: ZombieClasses.ini File Problem
Reply With Quote #2

Quote:
Originally Posted by CrazY. View Post
Code:
new flags = (ADMIN_IMMUNITY | ADMIN_BAN) // bits to string new flags_str[15] get_flags(flags, flags_str, charsmax(flags_str)) // string to bits flags = read_flags(flags_str)
How this can be work ?
It's not admin flag it's zombie flag and the code of this is "g_zclass_admin = ArrayCreate(1, 1)"
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-27-2020 , 06:05   Re: ZombieClasses.ini File Problem
Reply With Quote #3

Those are the codes plz if anyone have idea for how to fix flags then help me i really need it
PHP Code:
load_customization_from_files()
{
    
// Build zombie classes file path
    
new path[64]
    
get_configsdir(pathcharsmax(path))
    
format(pathcharsmax(path), "%s/%s"pathBB_ZOMBIECLASSES_FILE)
    
    
// File not present
    
if (!file_exists(path))
    {
        new 
error[100]
        
formatex(errorcharsmax(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(filelinedatacharsmax(linedata))
            
            
// Replace newlines with a null character to prevent headaches
            
replace(linedatacharsmax(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
(linedatacharsmax(linedata), linedata[1])
                
                
// Store its real name for future reference
                
ArrayPushString(g_zclass2_realnamelinedata)
                continue;
            }
            
            
// Get key and value(s)
            
strtok(linedatakeycharsmax(key), valuecharsmax(value), '=')
            
            
// Trim spaces
            
trim(key)
            
trim(value)
            
            if (
equal(key"NAME"))
                
ArrayPushString(g_zclass2_namevalue)
            else if (
equal(key"INFO"))
                
ArrayPushString(g_zclass2_infovalue)
            else if (
equal(key"MODELS"))
            {
                
// Set models start index
                
ArrayPushCell(g_zclass2_modelsstartArraySize(g_zclass2_playermodel))
                
                
// Parse class models
                
while (value[0] != && strtok(valuekeycharsmax(key), valuecharsmax(value), ','))
                {
                    
// Trim spaces
                    
trim(key)
                    
trim(value)
                    
                    
// Add to class models array
                    
ArrayPushString(g_zclass2_playermodelkey)
                    
ArrayPushCell(g_zclass_modelindex, -1)
                }
                
                
// Set models end index
                
ArrayPushCell(g_zclass2_modelsendArraySize(g_zclass2_playermodel))
            }
            else if (
equal(key"CLAWMODEL"))
                
ArrayPushString(g_zclass2_clawmodelvalue)
            else if (
equal(key"HEALTH"))
                
ArrayPushCell(g_zclass2_hpstr_to_num(value))
            else if (
equal(key"SPEED"))
                
ArrayPushCell(g_zclass2_spdstr_to_num(value))
            else if (
equal(key"GRAVITY"))
                
ArrayPushCell(g_zclass2_gravstr_to_float(value))
            else if (
equal(key"FLAG"))
                
ArrayPushCell(g_zclass2_adminstr_to_num(value))
        

        }
        if (
filefclose(file)
    }

}
save_customization()
{
    new 
ikbuffer[512]
    
    
// Build zombie classes file path
    
new path[64]
    
get_configsdir(pathcharsmax(path))
    
format(pathcharsmax(path), "%s/%s"pathBB_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 (0sizei++)
    {
        if (
ArrayGetCell(g_zclass_newi))
        {
            
// Add real name
            
ArrayGetString(g_zclass_nameibuffercharsmax(buffer))
            
format(buffercharsmax(buffer), "^n[%s]"buffer)
            
fputs(filebuffer)
            
            
// Add caption
            
ArrayGetString(g_zclass_nameibuffercharsmax(buffer))
            
format(buffercharsmax(buffer), "^nNAME = %s"buffer)
            
fputs(filebuffer)
            
            
// Add info
            
ArrayGetString(g_zclass_infoibuffercharsmax(buffer))
            
format(buffercharsmax(buffer), "^nINFO = %s"buffer)
            
fputs(filebuffer)
            
            
// Add models
            
for (ArrayGetCell(g_zclass_modelsstarti); ArrayGetCell(g_zclass_modelsendi); k++)
            {
                if (
== ArrayGetCell(g_zclass_modelsstarti))
                {
                    
// First model, overwrite buffer
                    
ArrayGetString(g_zclass_playermodelkbuffercharsmax(buffer))
                }
                else
                {
                    
// Successive models, append to buffer
                    
ArrayGetString(g_zclass_playermodelkpathcharsmax(path))
                    
format(buffercharsmax(buffer), "%s , %s"bufferpath)
                }
            }
            
format(buffercharsmax(buffer), "^nMODELS = %s"buffer)
            
fputs(filebuffer)
            
            
// Add clawmodel
            
ArrayGetString(g_zclass_clawmodelibuffercharsmax(buffer))
            
format(buffercharsmax(buffer), "^nCLAWMODEL = %s"buffer)
            
fputs(filebuffer)
            
            
// Add health
            
formatex(buffercharsmax(buffer), "^nHEALTH = %d"ArrayGetCell(g_zclass_hpi))
            
fputs(filebuffer)
            
            
// Add speed
            
formatex(buffercharsmax(buffer), "^nSPEED = %d"ArrayGetCell(g_zclass_spdi))
            
fputs(filebuffer)
            
            
// Add gravity
            
formatex(buffercharsmax(buffer), "^nGRAVITY = %.2f"Float:ArrayGetCell(g_zclass_gravi))
            
fputs(filebuffer)
            
            
// Add adminflags
            
formatex(buffercharsmax(buffer), "^nFLAG = %d^n"ArrayGetCell(g_zclass_admini))
            
fputs(filebuffer)
            
        }
    }
    
fclose(file)

Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-27-2020 , 10:33   Re: ZombieClasses.ini File Problem
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
Code:
new flags = (ADMIN_IMMUNITY | ADMIN_BAN) // bits to string new flags_str[15] get_flags(flags, flags_str, charsmax(flags_str)) // string to bits flags = read_flags(flags_str)
I did it and i had got the samething, numbers
Supremache is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-29-2020 , 07:33   Re: ZombieClasses.ini File Problem
Reply With Quote #5

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
alferd is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-29-2020 , 08:08   Re: ZombieClasses.ini File Problem
Reply With Quote #6

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
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 16:59.


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