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

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-25-2020 , 14:09   ZombieClasses.ini File Problem
Reply With Quote #1

Hello everyone,
I need help
I was want to make something for basebuilder mod and i made .ini file for zombie classes everythings are good but the problem in admin flag it show me numbers not words.
Why i have got this problem, can i get help plz

Codes

PHP Code:
    g_zclass_name ArrayCreate(321)
    
g_zclass_info ArrayCreate(321)
    
g_zclass_modelsstart ArrayCreate(11)
    
g_zclass_modelsend ArrayCreate(11)
    
g_zclass_playermodel ArrayCreate(321)
    
g_zclass_modelindex ArrayCreate(11)
    
g_zclass_clawmodel ArrayCreate(321)
    
g_zclass_hp ArrayCreate(11)
    
g_zclass_spd ArrayCreate(11)
    
g_zclass_grav ArrayCreate(11)
    
g_zclass_admin ArrayCreate(11)
    
g_zclass_credits ArrayCreate(11)
    
    
g_zclass2_realname ArrayCreate(321)
    
g_zclass2_name ArrayCreate(321)
    
g_zclass2_info ArrayCreate(321)
    
g_zclass2_modelsstart ArrayCreate(11)
    
g_zclass2_modelsend ArrayCreate(11)
    
g_zclass2_playermodel ArrayCreate(321)
    
g_zclass2_clawmodel ArrayCreate(321)
    
g_zclass2_hp ArrayCreate(11)
    
g_zclass2_spd ArrayCreate(11)
    
g_zclass2_grav ArrayCreate(11)
    
g_zclass2_admin ArrayCreate(11)
    
g_zclass2_credits ArrayCreate(11)
    
g_zclass_new ArrayCreate(11)
    
                        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))



            
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 knockback
            
formatex(buffercharsmax(buffer), "^nFLAG = %d^n"ArrayGetCell(g_zclass_admini))
            
fputs(filebuffer
Picture: See everything's good but the problem in flag
Supremache is offline
alferd
Veteran Member
Join Date: Dec 2019
Location: Iran is Always Eternal
Old 06-25-2020 , 14:15   Re: ZombieClasses.ini File Problem
Reply With Quote #2

Code:
flag = 131072/524288
???
alferd is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-25-2020 , 14:28   Re: ZombieClasses.ini File Problem
Reply With Quote #3

This is what i asking for, Those code are replaceng automatic zombie's privileges in .ini file like "name,info,model,gravity,speed,flag.." but i dont know why i have got this problem in admin flag
Those are the code
PHP Code:
else if (equal(key"FLAG"))
                
ArrayPushCell(g_zclass2_adminstr_to_num(value))

// Add admin flag
            
formatex(buffercharsmax(buffer), "^nFLAG = %d^n"ArrayGetCell(g_zclass_admini))
            
fputs(filebuffer
Where's the problem ?? I Tried to change %d to %i and i got the samething

Last edited by Supremache; 06-25-2020 at 14:32.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-25-2020 , 14:40   Re: ZombieClasses.ini File Problem
Reply With Quote #4

I mean
If zombie class sma file is this then will load everything to zombie classes.ini for edit everything without edit scriept but as you see i have problem in admin flag it's loading in zombieclasses.ini numbers number's not words like "ADMIN_LEVEL_%"

Supremache is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-25-2020 , 15:48   Re: ZombieClasses.ini File Problem
Reply With Quote #5

That's because ADMIN_LEVEL_* are bitflag constants. What you want to do here is convert the bitflag value to a flag string when saving/loading.
get_flags and read_flags are what you're looking for.
__________________









Last edited by CrazY.; 06-25-2020 at 15:49.
CrazY. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 06-26-2020 , 02:43   Re: ZombieClasses.ini File Problem
Reply With Quote #6

Quote:
Originally Posted by CrazY. View Post
That's because ADMIN_LEVEL_* are bitflag constants. What you want to do here is convert the bitflag value to a flag string when saving/loading.
get_flags and read_flags are what you're looking for.
Give me example plz
Supremache is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-26-2020 , 09:29   Re: ZombieClasses.ini File Problem
Reply With Quote #7

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

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

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

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
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 00:50.


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