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

File doesn't read


Post New Thread Reply   
 
Thread Tools Display Modes
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-18-2021 , 12:31   Re: File doesn't read
Reply With Quote #11

@Bugsy
i have experience about debug i told you my plugin working when i was using defines for access and cmd before i use file reading and i used another code type and it still didn't work
PHP Code:

ReadFile
()
{
    new 
szData[96], szValue[64], szKey[32], iSectioniFilePointer
    
    
if (!file_exists(g_szLocalFile))
    {
        
// File not exists, then create it (Here we can use new file system without problems)
        
iFilePointer fopen(szFilename"wt")
        
        
fputs(iFilePointer";Zombie Plague VIP^n^n")
        
fputs(iFilePointer";[Commands]^n")
        
fputs(iFilePointer"; Adding ^"/^" or ^"!^" in front will make it a chat command.^n")
        
fputs(iFilePointer"CHECK_COMMANDS = /vip, /vips, /whovip, /whovips, /checkvips, /checkvip^n")
        
fputs(iFilePointer"MOTD_COMMANDS = /getvip, /getvips, /buyvip, /buyvips^n^n")
        
fputs(iFilePointer";[Player Models]^n")
        
fputs(iFilePointer"MODEL_T = OWNER_Model^n")
        
fputs(iFilePointer"MODEL_CT = administrator^n^n")
        
fputs(iFilePointer";[Access Flags]^n")
        
fputs(iFilePointer"MESSAGES = a^n")
        
fputs(iFilePointer"SCOREBOARD = b^n")
        
fputs(iFilePointer"MULTIJUMP = c^n")
        
fputs(iFilePointer"HEALTH = d^n")
        
fputs(iFilePointer"ARMOR = e^n")
        
fputs(iFilePointer"GRAVITY = f^n")
        
fputs(iFilePointer"NOCLIP = g^n")
        
fputs(iFilePointer"DAMAGE = h^n")
        
fputs(iFilePointer"FALL DAMAGE = i^n")
        
fputs(iFilePointer"VIP MODEL = j^n")
        
fputs(iFilePointer"VIP_NON = z^n^n")
        
fputs(iFilePointer";[Usage Example]^n")
        
fputs(iFilePointer"; ^"Steam/Nick^" ^"Password^" ^"Flags^" ^"ExpireDate^"")
        
        
fclose(iFilePointer)
    }
    
    
iFilePointer fopen(szFilename"rt")
    
    while (!
feof(iFilePointer))
    {
        
fgets(iFilePointerszDatacharsmax(szData))
        
        
replace(szDatacharsmax(szData), "^n""")
        
        if (!
szData[0] || szData[0] == ';') continue;
        
        if (
szData[0] == '[')
        {
            
iSection++
            continue;
        }
        
        
strtok(szDataszKeycharsmax(szKey), szValuecharsmax(szValue), '=')
        
        
trim(szKey); trim(szValue)
    
        switch (
iSection)
        {
            case 
SECTION_SETTINGS:
            {

                if(
equal(szKey"CHECK_COMMANDS"))
                {
                    while(
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                    {
                        
trim(szKey); trim(szValue)
                                    
                        switch(
szKey[0])
                        {
                            case 
'/''!':
                            {
                                
formatex(szDatacharsmax(szData), "say %s"szKey)
                                
register_clcmd(szData"CmdVIP")
                                
formatex(szDatacharsmax(szData), "say_team %s"szKey)
                                
register_clcmd(szData"CmdVIP")
                            }
                            default:
                            {
                                
register_clcmd(szKey"CmdVIP")
                            
                            }
                        }
                    }
                }
                else if(
equal(szKey"MOTD_COMMANDS"))
                {
                    while(
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                    {
                        
trim(szKey); trim(szValue)
                                    
                        switch(
szKey[0])
                        {
                            case 
'/''!':
                            {
                                
formatex(szDatacharsmax(szData), "say %s"szKey)
                                
register_clcmd(szData"CmdMotd")
                                
formatex(szDatacharsmax(szData), "say_team %s"szKey)
                                
register_clcmd(szData"CmdMotd")
                            }
                            default:
                            {
                                
register_clcmd(szKey"CmdMotd")
                            }
                        }
                    }
                }
                else if (
equal(szKey"MESSAGES"))
                {
                    
g_eSettings[VIP_MESSAGES] = read_flags(szValue)
                }
                else if (
equal(szKey"SCOREBOARD"))
                {
                    
g_eSettings[VIP_SCOREBOARD] = read_flags(szValue)
                }
                else if (
equal(szKey"MULTIJUMP"))
                {
                    
g_eSettings[VIP_MULTIJUMP] = read_flags(szValue)
                }
                else if (
equal(szKey"HEALTH"))
                {
                    
g_eSettings[VIP_HEALTH] = read_flags(szValue)
                }
                else if (
equal(szKey"ARMOR"))
                {
                    
g_eSettings[VIP_ARMOR] = read_flags(szValue)
                }
                else if (
equal(szKey"GRAVITY"))
                {
                    
g_eSettings[VIP_GRAVITY] = read_flags(szValue)
                }
                else if (
equal(szKey"NOCLIP"))
                {
                    
g_eSettings[VIP_NOCLIP] = read_flags(szValue)
                }
                else if (
equal(szKey"DAMAGE"))
                {
                    
g_eSettings[VIP_DAMAGE] = read_flags(szValue)
                }
                else if (
equal(szKey"FALL DAMAGE"))
                {
                    
g_eSettings[VIP_FALLDAMAGE] = read_flags(szValue)
                }
                else if (
equal(szKey"VIP MODEL"))
                {
                    
g_eSettings[VIP_MODEL] = read_flags(szValue)
                }
                else if (
equal(szKey"VIP_NON"))
                {
                    
g_eSettings[VIP_NON] = read_flags(szValue)
                }
            }
            case 
SECTION_MODEL:
            {
                if (
equal(szKey"MODEL_T"))
                {
                    while (
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                    {
                        
trim(szKey); trim(szValue)
                                    
                        
ArrayPushString(Player_Model_TszKey)
                    }
                }
                else if (
equal(szKey"MODEL_CT"))
                {
                    while (
szValue[0] != && strtok(szValueszKeycharsmax(szKey), szValuecharsmax(szValue), ','))
                    {
                        
trim(szKey); trim(szValue)
                        
                        
ArrayPushString(Player_Model_CTszKey)
                    }
                }
            }
        }
    }
    
fclose(iFilePointer)

@Natsheh
I think the problem in not here !
Code:
            switch(szData[0])             {
 Check if string empty or starting with ; or # ignore the line
                case EOS, ';', '#': continue
 Check sections
                case '[':                 {                     iSize = strlen(szData)                     if(szData[iSize - 1] == ']')                     {                         switch(szData[1])                         {                             case 'N', 'n': iSection = SECTION_NONE                             case 'S', 's': iSection = SECTION_SETTINGS                             case 'M', 'm': iSection = SECTION_MODEL                             default: continue                         }                     }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-18-2021 , 14:59   Re: File doesn't read
Reply With Quote #12

can you compare each 1st character to the n, s, m characters in each catergory and tell me if they do match.

also show your config file containment
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-18-2021 at 15:00.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-18-2021 , 15:38   Re: File doesn't read
Reply With Quote #13

Quote:
Originally Posted by Natsheh View Post
can you compare each 1st character to the n, s, m characters in each catergory and tell me if they do match.

also show your config file containment
Why do you think the error in those lines ?!
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 05-19-2021 at 00:09.
Supremache is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-18-2021 , 22:12   Re: File doesn't read
Reply With Quote #14

Quote:
Originally Posted by Supremache View Post
Why do you think the error in those lines ?!


Full plugin:
Which of the following sections start with an N, S, or M:
  • Commands
  • Player Models
  • Access Flags
  • Usage Example

Also, I'm not sure why you changed it but replace(szData, charsmax(szData), "^n", "") will be unreliable. You should change it back to trim(szData).

And a bonus tip, you shouldn't use feof() as your while loop condition. You should use the fgets() for the condition. Change this:

PHP Code:
    while(!feof(iFilePointer))
    {
        
fgets(iFilePointerszDatacharsmax(szData)) 
to this:
PHP Code:
    while( fgets(iFilePointerszDatacharsmax(szData)) )
    { 
__________________

Last edited by fysiks; 05-18-2021 at 22:20.
fysiks is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-18-2021 , 22:50   Re: File doesn't read
Reply With Quote #15

Quote:
Originally Posted by fysiks View Post
Which of the following sections start with an N, S, or M:
  • Commands
  • Player Models
  • Access Flags
  • Usage Example

Also, I'm not sure why you changed it but replace(szData, charsmax(szData), "^n", "") will be unreliable. You should change it back to trim(szData).

And a bonus tip, you shouldn't use feof() as your while loop condition. You should use the fgets() for the condition. Change this:

PHP Code:
    while(!feof(iFilePointer))
    {
        
fgets(iFilePointerszDatacharsmax(szData)) 
to this:
PHP Code:
    while( fgets(iFilePointerszDatacharsmax(szData)) )
    { 

Code:
This is start section
        case 'S', 's': iSection = SECTION_SETTINGS

Code:
Also i change it to this but still didn't work
This section for commands, access Flags
        case 'S', 's': iSection = SECTION_SETTINGS
  This section for models
but usage example in get_user_vip function
        case 'M', 'm': iSection = SECTION_MODEL         default:  iSection = SECTION_NONE

I think the problem in not in file coding function because if there the file will work but i will get error but i think there's some other thing blocking it because at first time when i coded it, it worked without any problem but i don't remember what did i do make it doesn't work i recoded it but still didn't work!
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 05-18-2021 at 22:57.
Supremache is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-18-2021 , 23:08   Re: File doesn't read
Reply With Quote #16

If you keep refusing to post your errors then people are likely to stop helping you. You also need to learn to debug your code because you don't seem to be comprehending what anyone is telling you. Create a small plugin with just this function in it (and any global variables that it requires). I would test this in a local server using the server console where I would register a server command to call this function. Then, add server_print() messages to prove to you what part of the code is actually being executed and you can include data so that you know what is occurring in the code. For example, do something like:

Code:
server_print("Seciton name %s results in a value of %d", szData, iSection)
where ever you are determining the section.
__________________
fysiks is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-19-2021 , 00:08   Re: File doesn't read
Reply With Quote #17

Quote:
Originally Posted by fysiks View Post
If you keep refusing to post your errors then people are likely to stop helping you. You also need to learn to debug your code because you don't seem to be comprehending what anyone is telling you. Create a small plugin with just this function in it (and any global variables that it requires). I would test this in a local server using the server console where I would register a server command to call this function. Then, add server_print() messages to prove to you what part of the code is actually being executed and you can include data so that you know what is occurring in the code. For example, do something like:

Code:
server_print("Seciton name %s results in a value of %d", szData, iSection)
where ever you are determining the section.
Okey i will do that...
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
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 02:33.


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