2021-02-14, 06:51 PM
(2021-02-14, 05:50 PM)Radical Wrote:(2021-02-14, 02:47 PM)mems Wrote:(2021-02-14, 02:38 PM)Kwarde Wrote: There's still a new line between "username" and ".ini"
what do you mean exactly? and in which code?
PHP Code:CMD:test(playerid, params[])
{
? ? new File: handle = fopen("allusers.txt", io_read), nick[24],INI: file;
? ? new string[46], gsflevel;
? ? if((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] == 3) {
? ? ? ? if(sscanf(params, "i", gsflevel)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /setallgsf <level>");
? ? ? ? if(gsflevel > 13) return SendClientMessage(playerid, COLOR_RED, "ERROR: Max GSF level is 13");
? ? ? ? if(gsflevel < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Cannot set lower than 0");
? ? ? ? if(handle)
? ? ? ? {
? ? ? ? ? ? while(fread(handle, nick))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? StripNewLine(nick);
? ? ? ? ? ? ? ? ? format(string, 46, "scriptfiles/Users/%s.ini", nick);
? ? ? ? ? ? ? ? file = INI_Open(string);
? ? ? ? ? ? ? ? INI_SetTag(file, "=|PlayerData|=");
? ? ? ? ? ? ? ? INI_WriteInt(file, "GSFLevel", gsflevel);
? ? ? ? ? ? ? ? INI_Close(file);
? ? ? ? ? ? }
? ? ? ? ? ? fclose(handle);
? ? ? ? } else {
? ? ? ? ? ? print("The file \"allusers.txt\" does not exist, or can't be opened.");
? ? ? ? }
? ? ? ? return 1;
? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: Authorization revoked.");
}
PHP Code:/** BY DRACOBLUE
*? Strips Newline from the end of a string.
*? Idea: Y_Less, Bugfixing (when length=1) by DracoBlue
*? @param? string
*/
stock StripNewLine(string[])
{
new len = strlen(string);
if (string[0]==0) return ;
if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) {
string[len - 1] = 0;
if (string[0]==0) return ;
if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
}
}
thank you, that worked x2, it wouldn't work tho because you included "scriptfiles", so i removed it and now it works x3. if possible, could you explain me what you did so in the future if i ever come across this again i won't have any problems using that?