SA-MP Forums Archive
When kicking players ban info erase - 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: When kicking players ban info erase (/showthread.php?tid=593309)



When kicking players ban info erase - SalmaN97 - 03.11.2015

i have a question about my ban command if i add Kick(tid); so that the banned player will be kicked but it will not save these

INI_WriteInt(File,"Banned",1);
INI_WriteString(File,"BanAdmin",GetPlayerNameEx(pl ayerid));
INI_WriteString(File,"BanReason",res);
INI_WriteString(File,"IP",ip);

i tried timer but same the problem is with yini saving here is my command:

PHP Code:
CMD:ban(playerid,parmas[])
{
    new 
tid,res[125];
    if(
sscanf(parmas,"us[125]",tid,res)) SendClientMessage(playerid,-1,"/ban [id] [reason]");
    else if(
tid == INVALID_PLAYER_IDSendClientMessage(playerid,-1,"ID not connected.");
    else
    {
        new 
ip[16],str[30];
        
GetPlayerIp(tid,ip,sizeof(ip));
        new 
INI:File INI_Open(UserPath(tid));
        
INI_SetTag(File,"data");
        
INI_WriteInt(File,"Banned",1);
        
INI_WriteString(File,"BanAdmin",GetPlayerNameEx(playerid));
        
INI_WriteString(File,"BanReason",res);
        
INI_WriteString(File,"IP",ip);
        
INI_Close(File);
        
format(strsizeof(str),"banip %s"ip);
        
SendRconCommand(str);
        
SendRconCommand("reloadbans");
        
Kick(tid);
    }
    return 
1;

It works perfect without the Kick(tid);


Re: When kicking players ban info erase - Vince - 03.11.2015

Kick and ban have a much higher priority than other instructions, which may cause the player to be disconnected before the data can be saved. Adding to this problem is the fact that IO operations (i.e. writing to file) is extremely slow in comparison.

Using a 100ms timer to kick players should be plenty to ensure everything gets executed.


Re: When kicking players ban info erase - SalmaN97 - 03.11.2015

Quote:
Originally Posted by Vince
View Post
Kick and ban have a much higher priority than other instructions, which may cause the player to be disconnected before the data can be saved. Adding to this problem is the fact that IO operations (i.e. writing to file) is extremely slow in comparison.

Using a 100ms timer to kick players should be plenty to ensure everything gets executed.
nothing happens i banned a player without kicking then checked player .ini file data was written and save and then when i used /kick command ban data got erased


Re: When kicking players ban info erase - Abagail - 04.11.2015

Quote:
Originally Posted by SalmaN97
View Post
nothing happens i banned a player without kicking then checked player .ini file data was written and save and then when i used /kick command ban data got erased
If you are saving the same data(which if it is only changed on ban, itself is illogical) then you probably are only changing the file directly and aren't modifying the variables. I'd say saving the information on save is unneeded and should simply be removed.