• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] how to load every user.ini in scriptfiles using YINI
#23
(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(playeridparams[])

{

? ? new 
Filehandle fopen("allusers.txt"io_read), nick[24],INIfile;

? ? new 
string[46], gsflevel;

? ? if((
IsPlayerAdmin(playerid)) || PlayerInfo[playerid][AdminLevel] == 3) {

? ? ? ? if(
sscanf(params"i"gsflevel)) return SendClientMessage(playeridCOLOR_RED"Syntax: /setallgsf <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(string46"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(playeridCOLOR_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?
  Reply


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

Forum Jump: