Raised This Month: $ Target: $400
 0% 

ZombieClasses.ini File Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-27-2020 , 06:05   Re: ZombieClasses.ini File Problem
Reply With Quote #1

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
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