Ban system
#1

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
Reply
#2

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; 
}
Reply
#3

not saving
Reply
#4

Show us your mysql logs.
Reply
#5

You should check the mysql log.

EDIT: Sunehildeep was faster.
Reply
#6

[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)
Reply
#7

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.
Reply
#8

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......
Reply
#9

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
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)