SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/06/2020, 11:21 AM   #1
makemoneynotfriends
Big Clucker
 
Join Date: Jan 2020
Location: Egypt
Posts: 120
Reputation: 3
Default mysql from r33 to r40

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
makemoneynotfriends is offline   Reply With Quote
Old 28/06/2020, 11:31 AM   #2
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,735
Reputation: 1686
Default Re: mysql from r33 to r40

https://forum.sa-mp.com/showthread.php?t=616103
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Old 28/06/2020, 11:33 AM   #3
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 219
Reputation: 43
Default Re: mysql from r33 to r40

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;

__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs

Last edited by SkyFlare; 28/06/2020 at 01:15 PM.
SkyFlare is offline   Reply With Quote
Old 28/06/2020, 12:03 PM   #4
makemoneynotfriends
Big Clucker
 
Join Date: Jan 2020
Location: Egypt
Posts: 120
Reputation: 3
Default Re: mysql from r33 to r40

Quote:
Originally Posted by Kwarde View Post
Thanks for the help +rep
makemoneynotfriends is offline   Reply With Quote
Old 28/06/2020, 01:02 PM   #5
makemoneynotfriends
Big Clucker
 
Join Date: Jan 2020
Location: Egypt
Posts: 120
Reputation: 3
Default Re: mysql from r33 to r40

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 
makemoneynotfriends is offline   Reply With Quote
Old 28/06/2020, 01:11 PM   #6
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 219
Reputation: 43
Default Re: mysql from r33 to r40

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;

__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 28/06/2020, 01:29 PM   #7
makemoneynotfriends
Big Clucker
 
Join Date: Jan 2020
Location: Egypt
Posts: 120
Reputation: 3
Default Re: mysql from r33 to r40

still the others errors 1only fixed
makemoneynotfriends 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
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 08:26 AM
[Tutorial] [VIDEO] MySQL ORM r38: How to pair GM with MySQL & creation of registration/connection system cArnasLT Tutorials 3 19/05/2014 02:08 PM
[GameMode] MySQL CLEAN GAMEMODE [Whirlpool, MySQL BlueG R7, Cache, Ready Package (Windows)] GiamPy. Gamemode Scripts 13 13/09/2013 04:31 PM
BlueG MySQL plugin - Failed (plugins/mysql.so: undefined symbol: _Z13stringvprintfPKcPc) linuxthefish Plugin Development 10 13/07/2013 10:56 AM
[Tool/Web/Other] MySQL DB Manager - Easily manage your MySQL databases with this remote application fiki574 Tools and Files 13 22/07/2012 09:41 AM


All times are GMT. The time now is 05:08 PM.


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