SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 08/03/2019, 11:42 PM   #1
NikodemPolak
Little Clucker
 
Join Date: Sep 2017
Posts: 9
Reputation: 0
Default /banoff mysql error

After entering calls - Player not found.
But the player is in the database.

if(cont == 0) return SCM(playerid, COLOR_LIGHTGREEN3, "Player not found.");
mysql_real_escape_string(reason, reasone);


PHP Code:
function MySQLCheckAccountplayername[ ] ) {
    new 
playerIDgString] = (EOS);
    
formatgStringsizeof gString"SELECT * FROM `users` WHERE `name` = '%e'"playername );
    new 
Cacheusercache mysql_querySQLgString );
    if( !
cache_get_row_count( ) ) {
        
cache_deleteusercache );
        return 
false;
    }
    
playerID cache_get_field_content_int0"id" );
    
cache_deleteusercache );
    return 
playerID; } 
PHP Code:
YCMD:banoff(playeridparams[], help) {
    if(
gPlayerLogged[playerid] == 0) return SendClientMessage(playeridCOLOR_LIGHTRED"Nie jesteś zalogowany!");
    if(
IsPlayerConnected(playerid))
     {
        if(
PlayerInfo[playerid][pAdmin] >= 1)
        {
            new 
id[30],reason[128],reasone[128],string[200],sendername[30],days,str[1400],year,month,day,hour,minute,second,time,cont,qstr[500],playeridd,escape[30],admlevel;
            if(
sscanf(params"s[30]ds[128]"id,days,reason)) return SCM(playeridCOLOR_WHITE"{AB0000}Użyj: {FFFFFF}/banoff [exactly name] [day/0= perm] [reason]");
            if(
days 0) return SCM(playeridCOLOR_WHITE"{AB0000}Użyj: {FFFFFF}/banoff [exactly name] [day/0= perm] [reason]");
            
cont MySQLCheckAccount(id);
            if(
cont == 0) return SCM(playeridCOLOR_LIGHTGREEN3"Player not found.");
            
mysql_real_escape_string(reasonreasone);
            
getdate(yearmonthday);
            
gettime(hourminutesecond);
            
GetPlayerName(playeridsendernamesizeof(sendername));
            
mysql_real_escape_string(idescape);
            
format(qstr,sizeof(qstr),"SELECT * FROM bans WHERE `PlayerName`='%s' AND `Active`='1'"escape);
            new 
Cachebanuri mysql_query(SQL,qstr);
            if(
cache_get_row_count() > 0)
            {
                
SendClientMessage(playeridCOLOR_LIGHTRED"This player is already banned.");
            }
            else
            {
                
format(qstrsizeof(qstr), "SELECT `id` FROM users WHERE `name` = '%s'"escape);
                new 
Cacheabs mysql_query(SQL,qstr);
                if(
cache_get_row_count() > 0) {
                    
playeridd cache_get_field_content_int(0"id");
                    
admlevel cache_get_field_content_int(0"Admin");
                }
                
cache_delete(abs);
                if( 
admlevel >= PlayerInfoplayerid ][ pAdmin ] )
                    return 
SendClientMessageplayeridCOLOR_GREY"You can not ban a higher admin (equal)" );
                if(
days == 0) {
                    
format(string,sizeof(string),"AdmBan: %s was permanently banned by %s, reason: %s."idsendernamereasone);
                       if(
strfind(reason"silent"true) != -1)
                    {
                        
ABroadCast(COLOR_LIGHTREDstring1);
                    }
                    else
                    {
                        
SCMTA(COLOR_LIGHTREDstring);
                    }
                    
mysql_format(SQL,str,sizeof(str),"INSERT INTO bans (PlayerName, AdminName, Reason, IP, Days, IPBan, Permanent, Active, Time) VALUES('%s', '%s', '%s', '0', 0, 0, 1, 1, 0)",
                    
escape,PlayerInfo[playerid][pNormalName],reasone);
                    
mysql_tquery(SQL,str,"","");
                    new 
var100[256];
                    
mysql_format(SQLvar100sizeof(var100), "INSERT INTO punishlogs (`playerid`,`giverid`,`actionid`,`actiontime`,`reason`,`playername`,`givername`) VALUES ('%d','%d','1','0','%s','%s','%s')"playeridd,PlayerInfo[playerid][pSQLID],reasone,escape,sendername);
                    
mysql_tquery(SQL,var100,"","");
                }
                if(
days 0) {
                    
time gettime() + (days*86400);
                    
format(string,sizeof(string),"AdmBan: %s was banned by %s for %d day, reason: %s.",id,sendername,days,reasone);
                       if(
strfind(reason"silent"true) != -1)
                    {
                        
ABroadCast(COLOR_LIGHTREDstring1);
                    }
                    else
                    {
                        
SCMTA(COLOR_LIGHTREDstring);
                    }
                    
mysql_format(SQL,str,sizeof(str),"INSERT INTO bans (PlayerName, AdminName, Reason, IP, Days, IPBan, Permanent, Active, Time) VALUES('%s', '%s', '%s', '0', %d, 0, 0, 1, %d)",
                    
id,PlayerInfo[playerid][pNormalName],reasone,days,time);
                    
mysql_tquery(SQL,str,"","");
                    new 
var100[256];
                    
mysql_format(SQLvar100sizeof(var100), "INSERT INTO punishlogs (`playerid`,`giverid`,`actionid`,`actiontime`,`reason`,`playername`,`givername`) VALUES ('%d','%d','2','%d','%s','%s','%s')"playeridd,PlayerInfo[playerid][pSQLID],days,reasone,escape,sendername);
                    
mysql_tquery(SQL,var100,"","");
                }
            }
            
cache_delete(banuri);
        }
        else return 
SendClientMessage(playeridCOLOR_LIGHTGREEN3AdminOnly);
    }
    return 
1;

NikodemPolak is offline   Reply With Quote
Old 09/03/2019, 07:39 PM   #2
Autorojo
Little Clucker
 
Join Date: Mar 2015
Posts: 17
Reputation: 0
Default Re: /banoff mysql error

Maybe the 'id' value from 'users' table is returning zero. 0 = false.

Try to debug.
Autorojo 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] Error (0): Failed to exeute query. You have an error in your SQL syntax; check the manual that corresponds to you lulo356 Scripting Help 3 24/07/2015 06:58 AM
(error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for t SandKing94 Scripting Help 3 22/05/2015 09:53 AM
[MYSQL ERROR ] Access denied for user 'your username here'@'localhost' (using password: YES) (error ID: 1045). SpikY_ Scripting Help 3 07/11/2014 05:09 PM
MySQL Plugin r39-2 Error: Can't connect to local MySQL server through socket Emre__ Scripting Help 10 30/07/2014 09:26 AM
Mysql queriesYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for th audriuxxx Scripting Help 4 11/04/2014 07:42 PM


All times are GMT. The time now is 11:34 AM.


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