mysql from r33 to r40
#1

PHP Code:
CMD:tempban(playeridparams[])
{
    new 
banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedidreason[25], hoursstring[400], secsunbantsip[16], query[180];
    if(!
IsPlayerAdmin(playerid) && pInfo[playerid][playerAdmin] < 2) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command."); //this is just my admin check, yours may be different.
    
if(sscanf(params"uds[25]"bannedidhoursreason)) return SendClientMessage(playerid, -1"Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
    
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1"Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
    
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1"You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
    
if(strlen(reason) < || strlen(reason) > 24) return SendClientMessage(playerid, -1"Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
    
if(hours 12 || hours 720) return SendClientMessage(playerid, -1"Ban hours are between 12 and 720 hours");
    
GetPlayerName(playeridbannersizeof(banner));
    
GetPlayerName(bannedidbannedsizeof(banned));
    
GetPlayerIp(bannedidipsizeof(ip));
     
secs hours*3600
    unbants 
gettime()+ secs;
    
format(querysizeof(query), "INSERT INTO `bans` (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES ('0', '%s', '%s', '%s', '%s', %d, %d)",
    
bannedipbannerreasongettime(), unbants);
    
mysql_query(query);
    
format(stringsizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s"bannerreason);
    
ShowPlayerDialog(bannedid678DIALOG_STYLE_MSGBOX"Banned!"string"Close""");
    
format(stringsizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s"bannerplayeridbannedbannedidhoursreason);
    
SendClientMessageToAll(-1string);
    
SetTimerEx("KickEx"500falseplayerid"i");
    return 
1;
}
forward KickEx(playerid);
public 
KickEx(playerid)
{
    
Kick(playerid);
    return 
1;
}
forward OnBanCheck(playerid);
public 
OnBanCheck(playerid)
{
    new 
banquery[180], ip[16];
    
GetPlayerIp(playeridip16);
    
format(banquerysizeof(banquery), "SELECT unban_time FROM `bans` WHERE ip = '%s'"ip);
    
mysql_query(banquery);
    
mysql_store_result();
    if(
mysql_num_rows() != 0
    {
        new 
unbantimestamp mysql_fetch_int(); 
        if(
unbantimestamp gettime())
        {
            
SendClientMessage(playerid, -1"You're banned from this server.");
            
SetTimerEx("KickEx"500falseplayerid"i");
        }
    }
    return 
1;

i have this code and i wanna to make it use r40mysql insteand of r33 actually i tried but i dont know how to transfer them
so if someone can help me
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=616103
Reply
#3

You need a handle, if you already have one, make sure you use it, also change to threaded queries
PHP Code:
// MySQL connection handle
new MySQLYOURHANDLENAME;//Your Connection Handle, can be whatever you want it to be, if you have this already, disregard this.
CMD:tempban(playeridparams[])
{
    new 
banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedidreason[25], hoursstring[400], secsunbantsip[16], query[180];
    if(!
IsPlayerAdmin(playerid) && pInfo[playerid][playerAdmin] < 2) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command."); //this is just my admin check, yours may be different.
    
if(sscanf(params"uds[25]"bannedidhoursreason)) return SendClientMessage(playerid, -1"Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
    
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1"Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
    
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1"You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
    
if(strlen(reason) < || strlen(reason) > 24) return SendClientMessage(playerid, -1"Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
    
if(hours 12 || hours 720) return SendClientMessage(playerid, -1"Ban hours are between 12 and 720 hours");
    
GetPlayerName(playeridbannersizeof(banner));
    
GetPlayerName(bannedidbannedsizeof(banned));
    
GetPlayerIp(bannedidipsizeof(ip));
    
secs hours*3600;
    
unbants gettime()+ secs;
    
mysql_format(YOURHANDLENAMEquerysizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)"bannedipbannerreasongettime(), unbants);
    
mysql_tquery(YOURHANDLENAMEquery);
    
format(stringsizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s"bannerreason);
    
ShowPlayerDialog(bannedid678DIALOG_STYLE_MSGBOX"Banned!"string"Close""");
    
format(stringsizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s"bannerplayeridbannedbannedidhoursreason);
    
SendClientMessageToAll(-1string);
    
SetTimerEx("KickEx"500falseplayerid"i");
    return 
1;
}
forward KickEx(playerid);
public 
KickEx(playerid)
{
    
Kick(playerid);
    return 
1;
}
forward OnBanCheck(playerid);
public 
OnBanCheck(playerid)
{
    new 
banquery[180], ip[16];
    
GetPlayerIp(playeridip16);
    new 
rows;
    
mysql_format(YOURHANDLENAMEbanquerysizeof(banquery), "SELECT unban_time FROM `bans` WHERE `ip` = '%s'"ip);
    
mysql_tquery(YOURHANDLENAMEbanquery);
    if(
cache_get_row_count(rows))
    {
        new 
unbantimestamp mysql_fetch_int();
        if(
unbantimestamp gettime())
        {
            
SendClientMessage(playerid, -1"You're banned from this server.");
            
SetTimerEx("KickEx"500falseplayerid"i");
            return 
1;
        }
    }
    return 
1;

Reply
#4

Quote:
Originally Posted by Kwarde
View Post
Thanks for the help +rep
Reply
#5

PHP Code:
CMD:tempban(playeridparams[])
{
    new 
banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedidreason[25], hoursstring[400], secsunbantsip[16], query[180];
    if(!
pInfo[playerid][playerAdmin]) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command.");
    if(
sscanf(params"uds[25]"bannedidhoursreason)) return SendClientMessage(playerid, -1"Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
    
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1"Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
    
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1"You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
    
if(strlen(reason) < || strlen(reason) > 24) return SendClientMessage(playerid, -1"Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
    
if(hours 12 || hours 720) return SendClientMessage(playerid, -1"Ban hours are between 12 and 720 hours");
    
GetPlayerName(playeridbannersizeof(banner));
    
GetPlayerName(bannedidbannedsizeof(banned));
    
GetPlayerIp(bannedidipsizeof(ip));
    
secs hours*3600
    unbants 
gettime()+ secs;
    
mysql_format(connectionHandlequerysizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)"bannedipbannerreasongettime(), unbants);
    
mysql_tquery(connectionHandlequery);
    
format(stringsizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s"bannerreason);
    
ShowPlayerDialog(bannedid678DIALOG_STYLE_MSGBOX"Banned!"string"Close""");
    
format(stringsizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s"bannerplayeridbannedbannedidhoursreason);
    
SendClientMessageToAll(-1string);
    
SetTimerEx("Kick"500falseplayerid"i");
    return 
1;
}
forward OnBanCheck(playerid);
public 
OnBanCheck(playerid)
{
    new 
banquery[180], ip[16];
    
GetPlayerIp(playeridip16);
    new 
rows;
    
mysql_format(connectionHandlebanquerysizeof(banquery), "SELECT unban_time FROM `bans` WHERE `ip` = '%s'"ip);
    
mysql_tquery(connectionHandlebanquery);
    if(
cache_get_row_count(rows))
    {
        new 
unbantimestamp mysql_fetch_int();
        if(
unbantimestamp gettime())
        {
            
SendClientMessage(playerid, -1"You're banned from this server.");
            
SetTimerEx("Kick"500falseplayerid"i");
            return 
1;
        }
    }
    return 
1;
}
forward KickEx(playerid);
public 
KickEx(playerid)
{
    
Kick(playerid);
    return 
1;

PHP Code:
(3348) : warning 213tag mismatch
(3358) : error 001expected token";"but found "-identifier-"
(3365) : error 035argument type mismatch (argument 4)
(
3378) : error 017undefined symbol "mysql_fetch_int"
(3382) : error 035argument type mismatch (argument 4
PHP Code:
unbants gettime()+ secsline 3358
if(!pInfo[playerid][playerAdmin]) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command."); line 3348
SetTimerEx
("Kick"500falseplayerid"i"); line 3365
new unbantimestamp mysql_fetch_int(); 3378 line
forward KickEx
(playerid);
public 
KickEx(playerid)
{
    
Kick(playerid);
    return 
1;
line 3382 
Reply
#6

Quote:
Originally Posted by makemoneynotfriends
View Post
PHP Code:
CMD:tempban(playeridparams[])
{
    new 
banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedidreason[25], hoursstring[400], secsunbantsip[16], query[180];
    if(!
pInfo[playerid][playerAdmin]) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command.");
    if(
sscanf(params"uds[25]"bannedidhoursreason)) return SendClientMessage(playerid, -1"Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
    
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1"Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
    
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1"You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
    
if(strlen(reason) < || strlen(reason) > 24) return SendClientMessage(playerid, -1"Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
    
if(hours 12 || hours 720) return SendClientMessage(playerid, -1"Ban hours are between 12 and 720 hours");
    
GetPlayerName(playeridbannersizeof(banner));
    
GetPlayerName(bannedidbannedsizeof(banned));
    
GetPlayerIp(bannedidipsizeof(ip));
    
secs hours*3600
    unbants 
gettime()+ secs;
    
mysql_format(connectionHandlequerysizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)"bannedipbannerreasongettime(), unbants);
    
mysql_tquery(connectionHandlequery);
    
format(stringsizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s"bannerreason);
    
ShowPlayerDialog(bannedid678DIALOG_STYLE_MSGBOX"Banned!"string"Close""");
    
format(stringsizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s"bannerplayeridbannedbannedidhoursreason);
    
SendClientMessageToAll(-1string);
    
SetTimerEx("Kick"500falseplayerid"i");
    return 
1;
}
forward OnBanCheck(playerid);
public 
OnBanCheck(playerid)
{
    new 
banquery[180], ip[16];
    
GetPlayerIp(playeridip16);
    new 
rows;
    
mysql_format(connectionHandlebanquerysizeof(banquery), "SELECT unban_time FROM `bans` WHERE `ip` = '%s'"ip);
    
mysql_tquery(connectionHandlebanquery);
    if(
cache_get_row_count(rows))
    {
        new 
unbantimestamp mysql_fetch_int();
        if(
unbantimestamp gettime())
        {
            
SendClientMessage(playerid, -1"You're banned from this server.");
            
SetTimerEx("Kick"500falseplayerid"i");
            return 
1;
        }
    }
    return 
1;
}
forward KickEx(playerid);
public 
KickEx(playerid)
{
    
Kick(playerid);
    return 
1;

PHP Code:
(3348) : warning 213tag mismatch
(3358) : error 001expected token";"but found "-identifier-"
(3365) : error 035argument type mismatch (argument 4)
(
3378) : error 017undefined symbol "mysql_fetch_int"
(3382) : error 035argument type mismatch (argument 4
PHP Code:
unbants gettime()+ secsline 3358
if(!pInfo[playerid][playerAdmin]) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command."); line 3348
SetTimerEx
("Kick"500falseplayerid"i"); line 3365
new unbantimestamp mysql_fetch_int(); 3378 line
forward KickEx
(playerid);
public 
KickEx(playerid)
{
    
Kick(playerid);
    return 
1;
line 3382 
Youre missing ";" in secs = hours*3600
PHP Code:
CMD:tempban(playeridparams[])
{
    new 
banner[MAX_PLAYER_NAME], banned[MAX_PLAYER_NAME], bannedidreason[25], hoursstring[400], secsunbantsip[16], query[180];
    if(!
pInfo[playerid][playerAdmin]) return SendClientMessage(playeridERROR"You do not have sufficient permissions to use this command.");
    if(
sscanf(params"uds[25]"bannedidhoursreason)) return SendClientMessage(playerid, -1"Usage: /tempban [player name/ID] [hours] [reason]"); // here, we're checking if the administrator entered the command correctly. "u" is a player name or ID, "d" is the amount of hours as an integer, and "s[25]" is the reason.
    
if(!IsPlayerConnected(bannedid)) return SendClientMessage(playerid, -1"Invalid player name/ID."); //checking if the player that the admin is trying to ban is connected to the server
    
if(pInfo[playerid][playerAdmin] < pInfo[bannedid][playerAdmin]) return SendClientMessage(playerid, -1"You cannot ban someone with a higher level than you!"); //I don't allow admins to ban those with higher levels than their own.
    
if(strlen(reason) < || strlen(reason) > 24) return SendClientMessage(playerid, -1"Your reason must be between 3 and 24 characters."); //limiting the reason length to 3-24 characters
    
if(hours 12 || hours 720) return SendClientMessage(playerid, -1"Ban hours are between 12 and 720 hours");
    
GetPlayerName(playeridbannersizeof(banner));
    
GetPlayerName(bannedidbannedsizeof(banned));
    
GetPlayerIp(bannedidipsizeof(ip));
    
secs hours*3600;//You were missing the ; at the end of this line
    
unbants gettime()+ secs;
    
mysql_format(connectionHandlequerysizeof(query), "INSERT INTO bans (ban_id, player, ip, admin, reason, ban_time, unban_time) VALUES('0', '%s', '%s', '%s', '%s', %d, %d)"bannedipbannerreasongettime(), unbants);
    
mysql_tquery(connectionHandlequery);
    
format(stringsizeof(string), "You've been temporarily banned.\n\n{FFFFFF}Staff member: %s\nReason: %s"bannerreason);
    
ShowPlayerDialog(bannedid678DIALOG_STYLE_MSGBOX"Banned!"string"Close""");
    
format(stringsizeof(string), "%s(%d) has banned %s(%d) for %d hours for: %s"bannerplayeridbannedbannedidhoursreason);
    
SendClientMessageToAll(-1string);
    
SetTimerEx("Kick"500falseplayerid"i");
    return 
1;

Reply
#7

still the others errors 1only fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)