SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/11/2015, 10:16 PM   #1
SalmaN97
Big Clucker
 
Join Date: Oct 2013
Posts: 144
Reputation: 15
Default When kicking players ban info erase

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);
SalmaN97 is offline   Reply With Quote
Old 03/11/2015, 10:49 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: When kicking players ban info erase

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.
__________________
Vince is offline   Reply With Quote
Old 03/11/2015, 11:02 PM   #3
SalmaN97
Big Clucker
 
Join Date: Oct 2013
Posts: 144
Reputation: 15
Default Re: When kicking players ban info erase

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
SalmaN97 is offline   Reply With Quote
Old 04/11/2015, 12:58 AM   #4
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,133
Reputation: 445
Default Re: When kicking players ban info erase

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.
Abagail is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
NPCs kicking players 6Dragon6 Scripting Help 3 28/03/2014 09:36 PM
Kicking X because they didn't logon to the game. [ NEW FOUND INFO ] Kyle Server Support 8 03/01/2014 10:40 AM
[Include] rInfoBox - Cool looking textdraw Info boxes ! Show info to players in one line! RajatPawar Includes 39 24/07/2013 01:33 PM
Kicking Paused Players Michael[NBK] Scripting Help 3 11/11/2011 08:53 PM


All times are GMT. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.