not writing to userfile (yini)
#1

Код:
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?
Reply
#2

bump, still need some help with this
Reply
#3

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
Reply
#4

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

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.
Reply
#6

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));
Reply
#7

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!
Reply
#8

fixed, thanks for the help
Reply
#9

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)