SA-MP Forums Archive
not writing to userfile (yini) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: not writing to userfile (yini) (/showthread.php?tid=499833)



not writing to userfile (yini) - HenrySunseri - 09.03.2014

Код:
CMD:jail(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] <= 4) return 1;
   new targetid, minutes, reason[64], str[128];
   if(sscanf(params, "riS[64]", targetid, minutes, reason)) return SendClientMessage(playerid, -1, "USAGE: /jail [id] [minutes] [reason]");
   else
   {
      format(str, sizeof(str), "AdmCmd: Administrator %s has jailed %s for %d minutes. Reason: %s", Name(playerid), Name(targetid), minutes, reason);
      JailTimer[targetid] = SetTimer("Unjail", minutes*1000*60, false);
      SetPlayerInterior(targetid, 6);
      SetPlayerPos(targetid, 264.4176, 77.8930, 1001.0391);
      PlayerInfo[targetid][pJailed] = 1;
      SendClientMessageToAll(0xFF0000FF, str);
      SetPlayerHealth(targetid, 9999);
      GameTextForPlayer(targetid, "Welcome to AJAIL!", 5000, 6);
      new path[32];
      format(path, sizeof(path), "/Users/%s.ini", playerid);
	  new INI:i = INI_Open(path);
      INI_WriteString(i, "test", str);
      INI_Close(i);
   }
   return 1;
}
Whenever a player gets jailed, a file is made ".ini" in the Users folder, and contains the string. What I want it to do is write the string to the players userfile, but for some reason it's not. Can anyone help?


Re: not writing to userfile (yini) - HenrySunseri - 10.03.2014

bump, still need some help with this


AW: not writing to userfile (yini) - Macronix - 10.03.2014

This is because you are trying to open the playerid in a string (%s).
Код:
format(path, sizeof(path), "/Users/%s.ini", playerid);
You have to replace the playerid in this code with the name of the player OR if you want to use playerid, you need to replace the %s with a %d


Re: not writing to userfile (yini) - hEy72 - 10.03.2014

http://forum.sa-mp.com/showthread.ph...90#post2948090 pls


Re: AW: not writing to userfile (yini) - HenrySunseri - 10.03.2014

Quote:
Originally Posted by Macronix
Посмотреть сообщение
This is because you are trying to open the playerid in a string (%s).
Код:
format(path, sizeof(path), "/Users/%s.ini", playerid);
You have to replace the playerid in this code with the name of the player OR if you want to use playerid, you need to replace the %s with a %d
When I replace it with %d all it does, instead of writing it in the blank .ini file, it writes it in a new "0.ini" file.


AW: not writing to userfile (yini) - Macronix - 10.03.2014

Well, then do the other way. Get the name of the targetid and replace "playerid" with the name of the target.
Here:
Код:
format(path, sizeof(path), "/Users/%s.ini", Name(targetid));



Re: not writing to userfile (yini) - Stanford - 10.03.2014

Alright here is what you need I guess:

pawn Код:
new sendername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(path, sizeof(path), "/Users/%s.ini", sendername);
* You got now the player's name so you can know which file!


Re: not writing to userfile (yini) - HenrySunseri - 10.03.2014

fixed, thanks for the help


Re: not writing to userfile (yini) - HenrySunseri - 10.03.2014

update: new problem lol. Whenever another player is jailed, it writes it in the ADMINS file, and replaces the only jail there. Is it possible to get it to write in the players file, and instead of replacing the only jail there, add onto the list?


AW: not writing to userfile (yini) - Macronix - 10.03.2014

Still the same script? Have you tried replacing playerid with targetid?