Veteran Member
Join Date: Sep 2019
Location: Egypt
|
05-18-2021
, 12:31
Re: File doesn't read
|
#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], iSection, iFilePointer
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(iFilePointer, szData, charsmax(szData))
replace(szData, charsmax(szData), "^n", "")
if (!szData[0] || szData[0] == ';') continue;
if (szData[0] == '[')
{
iSection++
continue;
}
strtok(szData, szKey, charsmax(szKey), szValue, charsmax(szValue), '=')
trim(szKey); trim(szValue)
switch (iSection)
{
case SECTION_SETTINGS:
{
if(equal(szKey, "CHECK_COMMANDS"))
{
while(szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
{
trim(szKey); trim(szValue)
switch(szKey[0])
{
case '/', '!':
{
formatex(szData, charsmax(szData), "say %s", szKey)
register_clcmd(szData, "CmdVIP")
formatex(szData, charsmax(szData), "say_team %s", szKey)
register_clcmd(szData, "CmdVIP")
}
default:
{
register_clcmd(szKey, "CmdVIP")
}
}
}
}
else if(equal(szKey, "MOTD_COMMANDS"))
{
while(szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
{
trim(szKey); trim(szValue)
switch(szKey[0])
{
case '/', '!':
{
formatex(szData, charsmax(szData), "say %s", szKey)
register_clcmd(szData, "CmdMotd")
formatex(szData, charsmax(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] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
{
trim(szKey); trim(szValue)
ArrayPushString(Player_Model_T, szKey)
}
}
else if (equal(szKey, "MODEL_CT"))
{
while (szValue[0] != 0 && strtok(szValue, szKey, charsmax(szKey), szValue, charsmax(szValue), ','))
{
trim(szKey); trim(szValue)
ArrayPushString(Player_Model_CT, szKey)
}
}
}
}
}
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
}
}
__________________
|
|