Mysql Error 2013
#1

This is a repost with the new code.

I've got this code which sometimes causes the server to lose connection to mysql db.
PHP код:
under OnPlayerConnect
CheckPlayerBan
(playerid)
{
    
format(BanInfo[playerid][bip],20,"%s",ReturnPlayerIp(playerid));
    new 
ORM:ormid2 BanInfo[playerid][ORM_ID] = orm_create("pbans"c_handle);
    
orm_addvar_string(ormid2BanInfo[playerid][bname], 25"pBanned");
    
orm_addvar_string(ormid2BanInfo[playerid][badmin], 25"pBannedBy");
    
orm_addvar_string(ormid2BanInfo[playerid][btime], 30"pBanTime");
    
orm_addvar_string(ormid2BanInfo[playerid][bdate], 30"pBanDate");
    
orm_addvar_string(ormid2BanInfo[playerid][bip], 20"IP");
    
orm_addvar_string(ormid2BanInfo[playerid][breason], 128"pBanReason");
    
orm_setkey(ormid2"IP");
    
orm_select(ormid2"pbancheck""d"playerid);
    return 
1;

PHP код:
forward pbancheck(playerid);
public 
pbancheck(playerid)
{
    if(
playerid != INVALID_PLAYER_ID// if the player is still connected
    
{
        switch(
orm_errno(BanInfo[playerid][ORM_ID]))
        {
            case 
ERROR_OK:
            {
                new 
string[128];
                   
format(stringsizeof(string), "%s, you were banned by %s for %s. Time: %s, %s"GetPlayerNameEx(playerid), BanInfo[playerid][badmin], BanInfo[playerid][breason], BanInfo[playerid][bdate], BanInfo[playerid][btime]);
                
SendClientMessage(playeridCOLOR_WHITE" ");
                
SendClientMessage(playeridCOLOR_WHITE" ");
                
SendClientMessage(playerid,    COLOR_RED,string);
                
SendClientMessage(playeridCOLOR_CYAN2"To play again visit: www.paruni.com");
                
SendClientMessage(playeridCOLOR_CYAN2"This connection has been put on record.");
                new 
query2[128];
                
mysql_format(c_handle,query2sizeof(query2), "UPDATE pbans SET pBanEvade = %d WHERE `pBanned` = '%e'"1GetPlayerNameEx(playerid));
                
mysql_tquery(c_handlequery2"SendQuery""");
                   
printf("%s Has Been Blocked From Connecting To The Server.  IP: %s",GetPlayerNameEx(playerid),ReturnPlayerIp(playerid));
                
PlayerPlaySound(playerid10620.00.00.0);
                
orm_destroy(BanInfo[playerid][ORM_ID]);
                for(new 
bInfo:ebInfo; ++e)
                {
                    
BanInfo[playerid][e] = 0;
                }
                
KickEx(playerid);
            }
            case 
ERROR_NO_DATA:
            {
                
orm_destroy(BanInfo[playerid][ORM_ID]);
                new 
query[128];
                
mysql_format(c_handle,querysizeof(query), "SELECT * FROM `tban` WHERE `IP` = '%e' OR `Name` = '%e'"ReturnPlayerIp(playerid), GetPlayerNameEx(playerid));
                
mysql_tquery(c_handlequery"tbancheck""i"playerid);
            }
            case 
ERROR_INVALID:
            {
                
CheckPlayerBan(playerid);
            }
        }
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)