SA-MP Forums Archive
Y_ini error - 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: Y_ini error (/showthread.php?tid=632702)



Y_ini error - 1fret - 17.04.2017

Ok so im trying to make an offline jailing system this is my code.

PHP код:
CMD:ojail(playeridparams[])
{
    if(
IsPlayerAdmin(playerid) || pInfo[playerid][Admin] >= 4)
    {
        new 
playerb[32], string[128], file[32], time[6];
          if(
sscanf(params"s[32]i[6]s[128]"playerbtimeparams)) return SendClientMessage(playeriderror"Usage: /ojail [playername] [time] [reason]");
        if(
idCheck(playerb) != INVALID_PLAYER_ID) return SendClientMessage(playeriderror"Player is connected to the server, use /ajail instead.");
        if (!
fexist(file)) return SendClientMessage(playerid,error,"Error: This player doesn't have an account.");
        new 
INI:ACCOUNT INI_Open(file);
        
INI_SetTag(ACCOUNT,"data");
        
INI_WriteInt(ACCOUNT"Jailed"2);
        
INI_WriteInt(ACCOUNT"JailedTime"time);
        
INI_Close(ACCOUNT);
        
format(stringsizeof(string), "[AdmCmd]: {FF6347}An Administrator has been jailed %s. [Reason: %s]"playerbparams);
        
SendClientMessageToAll(redstring);
        
format(stringsizeof(string), "[OJAIL] %s has offline jailed %s . [Reason: %s]"GetName(playerid), playerbparams);
        
WriteToLog(string,"oJail");
    }
    else return 
ShowMessage(playeriderror1);
      return 
1;
}
//But i keep getting an argument type mismatch at this line
INI_WriteInt(ACCOUNT"JailedTime"time); 
Also could someone tell me how to read from a specific line in y_ini. Example say i want to show the players reason why he was banned on his next connection to the server , how do i read from the file..

Dont send me the link to the Y_ini topic cause i tried it already and failed... So could someone explain it and show me as well.


Re: Y_ini error - Nyitz - 17.04.2017

time is an array, WriteInt writes integers.
How about this:

Код:
new unixtime, x, y, z;
unixtime=gettime(x,y,z);
new INI:ACCOUNT = INI_Open(file); 
INI_SetTag(ACCOUNT,"data"); 
INI_WriteInt(ACCOUNT, "Jailed", 2); 
INI_WriteInt(ACCOUNT, "JailedUntil", unixtime+JAIL_TIME_IN_SECONDS); 
INI_Close(ACCOUNT);
Then you can operate on a UNIX timestamp, set jail time by simply passing time in seconds as a command parameter (/ojail <player> 30), and determine if player can leave jail already by comparing current time and his JailedUntil time in the database.


Re: Y_ini error - CaRaM3LL - 17.04.2017

Код:
 if(sscanf(params, "uds[128]", playerb, time, params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ojail [playername] [time] [reason]");
it should solve the problem.


Re: Y_ini error - 1fret - 18.04.2017

Quote:
Originally Posted by CaRaM3LL
Посмотреть сообщение
Код:
 if(sscanf(params, "uds[128]", playerb, time, params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /ojail [playername] [time] [reason]");
it should solve the problem.
that didn't work and also i would just like to know what i should use to save arrays in y_ini instead of you just making a coding and paste it..


Re: Y_ini error - StrikerZ - 18.04.2017

Because you used time as a string and saving the time as Integer


Re: Y_ini error - CaRaM3LL - 18.04.2017

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Because you used time as a string and saving the time as Integer
That's right

transform this:

Код:
time[6];
to this:

Код:
time;
.. this guys explained very well.


Re: Y_ini error - 1fret - 18.04.2017

OMG im really sorry but i read true the comments and got what he was trying to say and the error was fixed but i forgot to update the thread..

I will still rep+ you guys


Re: Y_ini error - StrikerZ - 18.04.2017

Also change
PHP код:
if(sscanf(params"s[32]i[6]s[128]" 
To
PHP код:
if(sscanf(params"s[32]ds[128]"