Problem with writing to players INI file
#1

For some reason the following code does not seem to be changing the players Admin value in their INI file. I use it on a player (for example set them to level 1 admin), check their file in my servers scriptfiles but their Admin still = 0. What am I doing wrong? I am using YSI INI.

P.S. Sorry about the indentation, It doesn't actually look like that in pawno but when I paste it over it seems to mess up.

Код:
CMD:setadmin(playerid, params[])
	{
	    if (PlayerInfo[playerid][pAdmin] == 2)
	    {
     		new receiver, amount;
     		if (!sscanf(params, "ui", receiver, amount))
     		{
         		if(!IsPlayerConnected(receiver)) 
                    return SendClientMessage(playerid, -1, "That player isn't connected!");

                if ((amount <= 2) && (amount >= 0))
                {
          			new INI:File = INI_Open(UserPath(receiver));
					if (UserPath(receiver) != INI_NO_FILE)
					{
          			        INI_SetTag(File, "data");
          			        INI_WriteInt(File,"Hit",amount);
          			        INI_Close(File);
          			        new plarname[MAX_PLAYER_NAME+1], yourname[MAX_PLAYER_NAME+1], message[100];
           			        GetPlayerName(receiver, plarname, MAX_PLAYER_NAME+1);
					format(message, sizeof(message), "You have set %s to a level %d admin.", plarname, amount);
					SendClientMessage(playerid, COLOR_YELLOW, message);
					GetPlayerName(playerid, yourname, MAX_PLAYER_NAME+1);
					format(message, sizeof(message), "%s has set you as a level %d admin, please relog.", yourname, amount);
					SendClientMessage(receiver, COLOR_YELLOW, message);
					}
					else
					{
					    SendClientMessage(playerid, COLOR_BRIGHTRED, "Invalid INI file.");
					}
          		}
          		else
          		{
          		    SendClientMessage(playerid, COLOR_BRIGHTRED, "Level must be between 0 and 2. 0=player 1=admin 2=manager");
          		}
			}
	    }
	    else
		{
		    SendClientMessage(playerid, COLOR_BRIGHTRED, "You are not a level 2 admin.");
		}
		return 1;
	}
Reply
#2

Anyone see the problem?
Reply
#3

Does it actually send you the message telling you that you set their admin level? Does it say the correct admin level in the message?
Reply
#4

Quote:
Originally Posted by RvGamers
Посмотреть сообщение
Does it actually send you the message telling you that you set their admin level? Does it say the correct admin level in the message?
Yes It did. I managed to fix the problem by using enums which are then saved to the INI file when the player disconnects, so instead of using INI_Write on the command I used PlayerInfo[playerid][pAdmin] = amount.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)