2021-02-15, 11:38 PM
(2021-02-15, 11:07 PM)mems Wrote:(2021-02-15, 09:32 PM)Radical Wrote: Try this:
PHP Code:CMD:osetallgsf(playerid, params[]) { ? ? new gsflevel; ? ? if((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] == 3) { ? ? ? ? if(sscanf(params, "i", gsflevel)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /osetallgsf <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"); ? ? ? ? new File: handle = fopen("allusers.txt", io_read), nick[MAX_PLAYER_NAME], INI: file, string[192], fstring[46], pname[MAX_PLAYER_NAME]; ? ? ? ? GetPlayerName(playerid, pname, sizeof(pname)); ? ? ? ? if(handle) ? ? ? ? { ? ? ? ? ? ? while(fread(handle, nick)) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? StripNewLine(nick); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? format(fstring, 46, "Users/%s.ini", nick); ? ? ? ? ? ? if(INI_ParseFile(fstring, "LoadGSFLevel", .bPassTag = true)) { ? ? ? ? ? ? if(GSFLevelInfo >= 1) { ? ? ? ? ? ? ? ? format(string, sizeof(string), "[STAFF]: \"%s\" has issued the command: {FF0000}OSETALLGSF{00FFFF}.", pname); ? ? ? ? ? ? ? ? SendToRCON(COLOR_AQUA, string); ? ? ? ? ? ? ? ? format(string, sizeof(string), "[{FF0000}GSF{FFFFFF}]: Successfully offline set {FF0000}%s's{FFFFFF} GSF level to: %i.", nick, gsflevel); ? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_WHITE, string); ? ? ? ? ? ? ? ? file = INI_Open(fstring); ? ? ? ? ? ? ? ? INI_SetTag(file, "=|PlayerData|="); ? ? ? ? ? ? ? ? INI_WriteInt(file, "GSFLevel", gsflevel); ? ? ? ? ? ? ? ? INI_Close(file); ? ? ? ? ? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: No account was found having a GSF level."); } ? ? ? ? ? ? } ? ? ? ? ? ? fclose(handle); ? ? ? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: The file \"allusers.txt\" does not exist, therefore canceling the process."); ? ? ? ? return 1; ? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: Authorization revoked."); }
this code worked but if it checked one player who didnt have a level it would stop so i made this code. however a message isn't sent when gsflevel isn't >= 1 or if player's online:
PHP Code:CMD:osetallgsf(playerid, params[]) { ? ? new File: handle = fopen("allusers.txt", io_read), nick[MAX_PLAYER_NAME], INI: file; ? ? new string[192], fstring[46], pname[MAX_PLAYER_NAME], gsflevel; ? ? GetPlayerName(playerid, pname, sizeof(pname)); ? ? if((IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] == 3) { ? ? ? ? if(sscanf(params, "i", gsflevel)) return SendClientMessage(playerid, COLOR_RED, "Syntax: /osetallgsf <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(fstring, 46, "Users/%s.ini", nick); ? ? ? ? ? ? if(INI_ParseFile(fstring, "LoadGSFLevel", .bPassTag = true)) { ? ? ? ? ? ? ? ? if(onlineinfo || !GSFLevelInfo) continue; ? ? ? ? ? ? if(GSFLevelInfo >= 1 && !onlineinfo) { ? ? ? ? ? ? format(string, sizeof(string), "[STAFF]: \"%s\" has issued the command: {FF0000}OSETALLGSF{00FFFF}.", pname); ? ? ? ? SendToRCON(COLOR_AQUA, string); ? ? ? ? ? ? ? ? format(string, sizeof(string), "[{FF0000}GSF{FFFFFF}]: Successfully offline set {FF0000}%s's{FFFFFF} GSF level to: %i.", nick, gsflevel); ? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_WHITE, string); ? ? ? ? ? ? ? ? file = INI_Open(fstring); ? ? ? ? ? ? ? ? INI_SetTag(file, "=|PlayerData|="); ? ? ? ? ? ? ? ? INI_WriteInt(file, "GSFLevel", gsflevel); ? ? ? ? ? ? ? ? INI_Close(file); ? ? ? ? ? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: No account was found having a GSF level."); } ? ? ? ? ? ? } ? ? ? ? ? ? fclose(handle); ? ? ? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: The file \"allusers.txt\" does not exist, therefore canceling the process."); ? ? ? ? return 1; ? ? } else return SendClientMessage(playerid, COLOR_RED, "ERROR: Authorization revoked."); }
you should remove return statement in loop?because it stops the loop.
(2021-02-15, 11:07 PM)mems Wrote:
and i have one question, is it possible to make this
Code:
? ? ? ? ? ? format(string, sizeof(string), "[STAFF]: \"%s\" has issued the command: {FF0000}OSETALLGSF{00FFFF}.", pname);
? ? ? ? SendToRCON(COLOR_AQUA, string);Put it outside the loop.
