Calling Functions
#1

hi,

recently i added a mysql function can accept guests but after OnPlayerConnect server freeze and OnPlayerRequestClass not called :/

idk why

this is last lines on onplayerconnect

PHP код:
    new queryS[128], Cache:resultsX;
    
mysql_format(registerquerySsizeof(queryS), "SELECT `Password` FROM `accounts` WHERE `Name` = '%s' LIMIT 1"GetName(playerid)); 
    
resultsX mysql_query(registerqueryS);
    new 
        
rows
        
fields
    
cache_get_row_count(rows);
    
cache_get_field_count(fields); 
    if(
rows
    { 
        
cache_get_value_name(0"Password"PlayerInfo[playerid][Password]); 
        
ShowPlayerDialog(playeridLogin+200DIALOG_STYLE_INPUT"Login""Welcome !\nthis account already registred. Please fill in your password:""Login""Quit"); 
    } 
    else
    {
        
isGuest[playerid] = 1;
    }
    
cache_delete(resultsX);
    return 
1;

any ideas ?

Pics:

Reply
#2

Here you go, Mr. Lead Scripter:

PHP код:
    new queryS[128]; 
    
mysql_format(registerquerySsizeof(queryS), "SELECT Password FROM accounts WHERE Name = '%e' LIMIT 1;"GetName(playerid));  
    new 
Cache:resultsX mysql_query(registerqueryS); 
    new 
rows;
    
cache_get_row_count(rows); 
    
    if(
rows)  
    {  
        
cache_get_value_name(0"Password"PlayerInfo[playerid][Password]);  
        
cache_delete(resultsX); 
        
ShowPlayerDialog(playeridLogin+200DIALOG_STYLE_INPUT"Login""Welcome !\nthis account already registred. Please fill in your password:""Login""Quit");  
    }  
    else 
    { 
        
isGuest[playerid] = 1
    } 
    return 
1

And yes, your code will still fail i guess, anyways, use mysql_errno() to check if u get any errors and check your mysql log.


Btw you might not want to use Limit 1 in that case, since it should be impossible to get more than 1, if u get more, you have a defect in your register system
Reply
#3

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Here you go, Mr. Lead Scripter:

PHP код:
    new queryS[128]; 
    
mysql_format(registerquerySsizeof(queryS), "SELECT Password FROM accounts WHERE Name = '%e' LIMIT 1;"GetName(playerid));  
    new 
Cache:resultsX mysql_query(registerqueryS); 
    new 
rows;
    
cache_get_row_count(rows); 
    
    if(
rows)  
    {  
        
cache_get_value_name(0"Password"PlayerInfo[playerid][Password]);  
        
cache_delete(resultsX); 
        
ShowPlayerDialog(playeridLogin+200DIALOG_STYLE_INPUT"Login""Welcome !\nthis account already registred. Please fill in your password:""Login""Quit");  
    }  
    else 
    { 
        
isGuest[playerid] = 1
    } 
    return 
1

And yes, your code will still fail i guess, anyways, use mysql_errno() to check if u get any errors and check your mysql log.


Btw you might not want to use Limit 1 in that case, since it should be impossible to get more than 1, if u get more, you have a defect in your register system
It's always good to use LIMIT 1, so it will return only 1 result.
Reply
#4

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
Here you go, Mr. Lead Scripter:

PHP код:
    new queryS[128]; 
    
mysql_format(registerquerySsizeof(queryS), "SELECT Password FROM accounts WHERE Name = '%e' LIMIT 1;"GetName(playerid));  
    new 
Cache:resultsX mysql_query(registerqueryS); 
    new 
rows;
    
cache_get_row_count(rows); 
    
    if(
rows)  
    {  
        
cache_get_value_name(0"Password"PlayerInfo[playerid][Password]);  
        
cache_delete(resultsX); 
        
ShowPlayerDialog(playeridLogin+200DIALOG_STYLE_INPUT"Login""Welcome !\nthis account already registred. Please fill in your password:""Login""Quit");  
    }  
    else 
    { 
        
isGuest[playerid] = 1
    } 
    return 
1

And yes, your code will still fail i guess, anyways, use mysql_errno() to check if u get any errors and check your mysql log.


Btw you might not want to use Limit 1 in that case, since it should be impossible to get more than 1, if u get more, you have a defect in your register system
Setting limit will ofcourse increase performance since when system finds one or specified number of match it will "break" searching through rows and prepare cache/result.
Reply
#5

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Setting limit will ofcourse increase performance since when system finds one or specified number of match it will "break" searching through rows and prepare cache/result.
Good point!
Reply
#6

Since its non threaded query, either mysql_query is taking forever to execute which is ultimately freezing player in OnPlayerConnect thread or its not related to the code you gave us.
Reply
#7

full code :

PHP код:
public OnPlayerConnect(playerid

    if(
BetaVersion == 1)
    {
        
TogglePlayerSpectating(playeridtrue); 
        new 
query[128];
        
mysql_format(registerquerysizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%s' LIMIT 1"GetName(playerid)); 
        
mysql_tquery(registerquery"OnMySQLInit""i"playerid);
        return 
1;
    }
    
inEvent[playerid] = false;
    
PlayAudioStreamForPlayer(playerid"https://ia601504.us.archive.org/35/items/login_201612/login.mp3");
    
TextDrawShowForPlayer(playeridVisual[0]);
    
TextDrawShowForPlayer(playeridVisual[1]);
    for(new 
050i++) SendClientMessage(playeridCOLOR_WHITE,"");
    for(new 
050i++) SendClientMessage(playeridCOLOR_WHITE,"");
    new 
stringjk[100];
    
format(stringjk,sizeof(stringjk), ""GRI"**%s[%d] Has joined "R"Vice Land"GetName(playerid), playerid);
    
SendClientMessageToAll(COLOR_GREYstringjk);
    
SendClientMessage(playeridCOLOR_GOLD,   "[VCL] : Welcome To Vice Land");
    
SendClientMessage(playeridCOLOR_ORANGE"[VCL] : You Can use /cmds for see Commands");
    
SendClientMessage(playeridCOLOR_ORANGE"[VCL] : I Hope you like our Server" );
    
SendClientMessage(playeridCOLOR_ORANGE"[VCL] : Enjoy !");
    
SetPlayerColor(playeridPlayerColors[playerid]);
    
InitFly(playerid);
    new 
joinMsg[80];
    
format(joinMsgsizeof(joinMsg), "02[%d] 03*** %s has joined Vice Land."playeridGetName(playerid));
    
IRC_GroupSay(groupIDIRCChanneljoinMsg);
    
SetTimerEx("OnAntiCheatLoad"5001"i"playerid);
    
SetTimerEx("onLVPiratesShipUpdate"5001"i"playerid);
    
SpawnArmour[playerid] = 0;
    
SpawnProtection[playerid] = 0;
    
SPDuration[playerid] = 0;
    
Ammo[playerid] = 0;
    
MyCar[playerid] = 0;
    
SetPVarInt(playerid"dWep0"0);
    
SetPVarInt(playerid"dWep1"0);
    
SetPVarInt(playerid"dWep2"0);
    
SetPVarInt(playerid"dPID", -1);
    
SetPVarInt(playerid"dLoc", -1);
    
SetPVarInt(playerid"dBet"0);
    
SetPlayerMapIcon(playerid62085.06101577.102311.434160MAPICON_LOCAL);
    
RemoveBuildingForPlayer(playerid35092089.3201583.4799.7260.250);
    
RemoveBuildingForPlayer(playerid35092089.3201566.1899.7260.250);
    
RemoveBuildingForPlayer(playerid35092109.0501547.2709.7730.250);
    
RemoveBuildingForPlayer(playerid86232093.8791553.51010.5700.250);
    
RemoveBuildingForPlayer(playerid86182093.6791553.31922.8280.250);
    
RemoveBuildingForPlayer(playerid89712093.6791553.31922.8280.250);
    
RemoveBuildingForPlayer(playerid13502082.51561538.81259.78910.25);
    
AudioDJ[playerid] = 0;
    
PropTycoon[playerid] = 0;
    
RemoveBuildingForPlayer(playerid89692071.6250702.890622.00780.25);
    
RemoveBuildingForPlayer(playerid34592257.3750623.429717.29690.25);
    
RemoveBuildingForPlayer(playerid13502277.2578627.67199.81250.25);
    
RemoveBuildingForPlayer(playerid13502297.5000638.78919.74220.25);
    
RemoveBuildingForPlayer(playerid13502281.8125643.33599.78910.25);
    
RemoveBuildingForPlayer(playerid12942283.2656653.812514.30470.25);
    
RemoveBuildingForPlayer(playerid12942291.5625692.093814.30470.25);
    
RemoveBuildingForPlayer(playerid13502293.0156703.11729.79690.25);
    
RemoveBuildingForPlayer(playerid34592346.6484623.429717.29690.25);
    
RemoveBuildingForPlayer(playerid34592411.7656623.429717.29690.25);
    
RemoveBuildingForPlayer(playerid85962490.4297703.195321.94530.25);
    for(new 
i_:G_USER_DATA; ++i)
        
GInfo[playerid][G_USER_DATA:i] = 0;
    
Iter_Add(SS_Playerplayerid);
    
GetPlayerName(playeridGInfo[playerid][username], MAX_PLAYER_NAME);
    
GInfo[playerid][Capturing] = false;
//** some texdraws
    
foreach(new Zones)
    {
        if(
isnull(ZInfo[i][Owner]))
            
GangZoneShowForPlayer(playeridZInfo[i][_Zone], ZONE_COLOR);
        else
            
GangZoneShowForPlayer(playeridZInfo[i][_Zone], ZInfo[i][Color]);
    }
    new 
IPx[16], Adminx[20], reason[50];
    
GetPlayerIp(playeridIPxsizeof(IPx));
    new 
querys[128], Cache:results;
    
format(querys128"SELECT * FROM `banlist` WHERE `ip` = '%s'"IPx);
       
results =  mysql_query(registerquerys);
    new 
rowsK;
    
cache_get_row_count(rowsK);
    if(
rowsK)
    {
        
cache_get_value_name(0"Admin"Adminx);
        
cache_get_value_name(0"Reason"reason);
        new 
str[150];
        for(new 
050i++) SendClientMessage(playeridCOLOR_WHITE,"");
        for(new 
050i++) SendClientMessage(playeridCOLOR_WHITE,"");
        
SendClientMessage(playerid, -1,""YE"You are Still Banned From x");
        
format(strsizeof(str), "You are Banned by Administrator : "R"%s "W"with given a reason : "R"%s"Adminxreason );
        
SendClientMessage(playerid, -1str);
        
SendClientMessage(playerid, -1"if You Think This Ban was unfair ! Feel Free to create a ban appeal in our forum ");
        
SetTimerEx("DelayKick"1000false"i"playerid);
    }
    
TogglePlayerSpectating(playeridtrue); 
    
cache_delete(results);
    new 
queryS[128], Cache:resultsX;
    
mysql_format(registerquerySsizeof(queryS), "SELECT `Password` FROM `accounts` WHERE `Name` = '%s' LIMIT 1"GetName(playerid)); 
    
resultsX mysql_query(registerqueryS);
    new 
        
rows
        
fields
    
cache_get_row_count(rows);
    
cache_get_field_count(fields); 
    if(
rows
    { 
        
cache_get_value_name(0"Password"PlayerInfo[playerid][Password]); 
        
ShowPlayerDialog(playeridLogin+200DIALOG_STYLE_INPUT"Login""Welcome !\nthis account already registred. Please fill in your password:""Login""Quit"); 
        return 
1;
    } 
    
cache_delete(resultsX);
    
isGuest[playerid] = 1;
    return 
1

notice: BetaVersion = 0

about mysql logs (error.log, warnings.log) are empty's
Reply
#8

Can you show us where you established the connection to db?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)