• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] how to load every user.ini in scriptfiles using YINI
#29
(2021-02-15, 09:32 PM)Radical Wrote: Try this:
PHP Code:
CMD:osetallgsf(playeridparams[])
{
? ? new 
gsflevel;
? ? if((
IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] == 3) {
? ? ? ? if(
sscanf(params"i"gsflevel)) return SendClientMessage(playeridCOLOR_RED"Syntax: /osetallgsf <level>");
? ? ? ? if(
gsflevel 13) return SendClientMessage(playeridCOLOR_RED"ERROR: Max GSF level is 13");
? ? ? ? if(
gsflevel 0) return SendClientMessage(playeridCOLOR_RED"ERROR: Cannot set lower than 0");
? ? ? ? new 
Filehandle fopen("allusers.txt"io_read), nick[MAX_PLAYER_NAME], INIfilestring[192], fstring[46], pname[MAX_PLAYER_NAME];
? ? ? ? 
GetPlayerName(playeridpnamesizeof(pname));
? ? ? ? if(
handle)
? ? ? ? {
? ? ? ? ? ? while(
fread(handlenick))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? 
StripNewLine(nick);
? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? 
format(fstring46"Users/%s.ini"nick);
? ? ? ? ? ? if(
INI_ParseFile(fstring"LoadGSFLevel", .bPassTag true)) {
? ? ? ? ? ? if(
GSFLevelInfo >= 1) {
? ? ? ? ? ? ? ? 
format(stringsizeof(string), "[STAFF]: \"%s\" has issued the command: {FF0000}OSETALLGSF{00FFFF}."pname);
? ? ? ? ? ? ? ? 
SendToRCON(COLOR_AQUAstring);
? ? ? ? ? ? ? ? 
format(stringsizeof(string), "[{FF0000}GSF{FFFFFF}]: Successfully offline set {FF0000}%s's{FFFFFF} GSF level to: %i."nickgsflevel);
? ? ? ? ? ? ? ? 
SendClientMessage(playeridCOLOR_WHITEstring);
? ? ? ? ? ? ? ? 
file INI_Open(fstring);
? ? ? ? ? ? ? ? 
INI_SetTag(file"=|PlayerData|=");
? ? ? ? ? ? ? ? 
INI_WriteInt(file"GSFLevel"gsflevel);
? ? ? ? ? ? ? ? 
INI_Close(file);
? ? ? ? ? ? } else return 
SendClientMessage(playeridCOLOR_RED"ERROR: No account was found having a GSF level.");
}
? ? ? ? ? ? }
? ? ? ? ? ? 
fclose(handle);
? ? ? ? } else return 
SendClientMessage(playeridCOLOR_RED"ERROR: The file \"allusers.txt\" does not exist, therefore canceling the process.");
? ? ? ? return 
1;
? ? } else return 
SendClientMessage(playeridCOLOR_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(playeridparams[])
{
    new 
Filehandle fopen("allusers.txt"io_read), nick[MAX_PLAYER_NAME], INIfile;
    new 
string[192], fstring[46], pname[MAX_PLAYER_NAME], gsflevel;
    
GetPlayerName(playeridpnamesizeof(pname));
    if((
IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] == 3) {
        if(
sscanf(params"i"gsflevel)) return SendClientMessage(playeridCOLOR_RED"Syntax: /osetallgsf <level>");
        if(
gsflevel 13) return SendClientMessage(playeridCOLOR_RED"ERROR: Max GSF level is 13");
        if(
gsflevel 0) return SendClientMessage(playeridCOLOR_RED"ERROR: Cannot set lower than 0");
        if(
handle)
        {
            while(
fread(handlenick))
            {
                
StripNewLine(nick);
                
format(fstring46"Users/%s.ini"nick);
                if(
INI_ParseFile(fstring"LoadGSFLevel", .bPassTag true)) {
                    if(
onlineinfo || !GSFLevelInfo) continue;
                    if(
GSFLevelInfo >= && !onlineinfo) {
                        
format(stringsizeof(string), "[STAFF]: \"%s\" has issued the command: {FF0000}OSETALLGSF{00FFFF}."pname);
                        
SendToRCON(COLOR_AQUAstring);
                        
format(stringsizeof(string), "[{FF0000}GSF{FFFFFF}]: Successfully offline set {FF0000}%s's{FFFFFF} GSF level to: %i."nickgsflevel);
                        
SendClientMessage(playeridCOLOR_WHITEstring);
                        
file INI_Open(fstring);
                        
INI_SetTag(file"=|PlayerData|=");
                        
INI_WriteInt(file"GSFLevel"gsflevel);
                        
INI_Close(file);
                    } else return 
SendClientMessage(playeridCOLOR_RED"ERROR: No account was found having a GSF level.");
                }
            }
            
fclose(handle);
        } else return 
SendClientMessage(playeridCOLOR_RED"ERROR: The file \"allusers.txt\" does not exist, therefore canceling the process.");
        return 
1;
    } else return 
SendClientMessage(playeridCOLOR_RED"ERROR: Authorization revoked.");


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);
be sent only once even tho it's inside the loop ?
  Reply


Messages In This Thread
RE: how to load every user.ini in scriptfiles using YINI - by mems - 2021-02-15, 11:07 PM

Forum Jump: