SA-MP Forums Archive
Ban system - 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: Ban system (/showthread.php?tid=625853)



Ban system - Loinal - 07.01.2017

PHP код:
CMD:ban(playeridparams[])
{
    if(
pData[playerid][Admin] >= 4)
    {
    new 
string[135],estring[135],Query[300],plid,largestring[300];
    if (
sscanf(params"us[200]"plidestring)) return SendClientMessage(playerid,COLOR_YELLOW"Usage: /ban <id> <reason>");
    if (!
IsPlayerConnected(plid)) return SendClientMessage(playerid,0xFF0000FF"Player Not Connected!");
    
format(stringsizeof(string), "You have banned {FFFFFF}%s(%d)"PlayerName(plid), plid);
    
SendClientMessage(playerid0x66FF33string);
    
format(largestringsizeof(largestring), "Admin %s banned you from the server\r\nReason:%s"PlayerName(playerid), estring);
    
ShowPlayerDialog(plidDIALOG_KICKDIALOG_STYLE_MSGBOX"You have been banned"largestring"Ok""Cancel");
    
GetPlayerIp(plidPIP50);
    new 
HourMinuteSecondYearMonthDay;
    
gettime(HourMinuteSecond);
    
getdate(YearMonthDay);
    
format(stringsizeof(string), "%02d:%02d:%02d on %02d/%02d/%d"HourMinuteSecondDayMonthYear);
    
mysql_format(connectionHandle,Querysizeof(Query), "INSERT INTO `banlog` (`time`, `name`, `ip`, `reason`, `admin`, `banned`) VALUES ('%s', '%s', '%s', '%s', '%s', 1)"stringescpname(plid), PIPescstring(estring), escpname(playerid));
    
mysql_query(connectionHandleQuery);
    
mysql_free_result();
    
Kick(plid);
    }
    return 
1;

It doesn't insert in the banlog


Re: Ban system - Bolex_ - 07.01.2017

Not sure but try this

Код:
CMD:ban(playerid, params[]) 
{ 
    if(pData[playerid][Admin] >= 4) 
    { 
    new string[135],estring[135],Query[300],plid,largestring[300]; 
    if (sscanf(params, "us[200]", plid, estring)) return SendClientMessage(playerid,COLOR_YELLOW, "Usage: /ban <id> <reason>"); 
    if (!IsPlayerConnected(plid)) return SendClientMessage(playerid,0xFF0000FF, "Player Not Connected!"); 
    format(string, sizeof(string), "You have banned {FFFFFF}%s(%d)", PlayerName(plid), plid); 
    SendClientMessage(playerid, 0x66FF33, string); 
    format(largestring, sizeof(largestring), "Admin %s banned you from the server\r\nReason:%s", PlayerName(playerid), estring); 
    ShowPlayerDialog(plid, DIALOG_KICK, DIALOG_STYLE_MSGBOX, "You have been banned", largestring, "Ok", "Cancel"); 
    GetPlayerIp(plid, PIP, 50); 
    new Hour, Minute, Second, Year, Month, Day; 
    gettime(Hour, Minute, Second); 
    getdate(Year, Month, Day); 
    format(string, sizeof(string), "%02d:%02d:%02d on %02d/%02d/%d", Hour, Minute, Second, Day, Month, Year); 
    mysql_format(connectionHandle,Query, sizeof(Query), "INSERT INTO banlog(`time`, `name`, `ip`, `reason`, `admin`, `banned`) VALUES ('%s', '%s', '%s', '%s', '%s', 1)", string, escpname(plid), PIP, escstring(estring), escpname(playerid)); 
    mysql_query(connectionHandle, Query); 
    mysql_free_result(); 
    Kick(plid); 
    } 
    return 1; 
}



Re: Ban system - Loinal - 07.01.2017

not saving


Re: Ban system - StrikerZ - 07.01.2017

Show us your mysql logs.


Re: Ban system - GoldenLion - 07.01.2017

You should check the mysql log.

EDIT: Sunehildeep was faster.


Re: Ban system - Loinal - 07.01.2017

[17:18:48 01/07/17] [DEBUG] mysql_format - connection: 0, len: 300, format: "SELECT `name` FROM `banlog` WHERE name = '%s' AND banned = 1 LIMIT 1"
[17:18:48 01/07/17] [ERROR] mysql_format - invalid connection handle (id: 0)
[17:18:48 01/07/17] [DEBUG] mysql_query - connection: 0, query: "", use_cache: true
[17:18:48 01/07/17] [ERROR] mysql_query - invalid connection handle (id: 0)
[17:18:54 01/07/17] [DEBUG] mysql_escape_string - source: "[LC]Martex", connection: 1, max_len: 24
[17:18:54 01/07/17] [DEBUG] mysql_escape_string - source: "Test", connection: 1, max_len: 200
[17:18:54 01/07/17] [DEBUG] mysql_escape_string - source: "[LC]Martex", connection: 1, max_len: 24
[17:18:54 01/07/17] [DEBUG] mysql_format - connection: 0, len: 300, format: "INSERT INTO banlog(`time`, `name`, `ip`, `reason`, `admin`, `banned`) VALUES ('%s', '%s', '%s', '%s', '%s', 1)"
[17:18:54 01/07/17] [ERROR] mysql_format - invalid connection handle (id: 0)
[17:18:54 01/07/17] [DEBUG] mysql_query - connection: 0, query: "", use_cache: true
[17:18:54 01/07/17] [ERROR] mysql_query - invalid connection handle (id: 0)


Re: Ban system - StrikerZ - 07.01.2017

Show the line in which you use mysql_connect.

connectonHandle means the handle you use to connect to the database.
For example:-
PHP код:
new MDB;
MDB mysql_connect(.....); 
Here MDB is the connection Handle.


Re: Ban system - Loinal - 07.01.2017

i do not use connectionHandle to connect mysql i use new mysql; but i added connectionHandle to make that codes because when i use mysql it say tag mich......


Re: Ban system - StrikerZ - 07.01.2017

Quote:
Originally Posted by Loinal
Посмотреть сообщение
i do not use connectionHandle to connect mysql i use new mysql; but i added connectionHandle to make that codes because when i use mysql it say tag mich......
then use mysql instead of connectionHandle in format query


Re: Ban system - Loinal - 07.01.2017

It gives me error:
PHP код:
warning 213tag mismatch