public OnPlayerConnect(playerid)
{
new Query[512], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE Username='%s'", name);
mysql_function_query(dbconnect, Query, false, "OnQueryFinish", "");
mysql_store_result();
if(mysql_num_rows() != 0)
{
ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_PASSWORD,"SpectralRP: Login","Enter your password below to login","Login","Cancel");
}
else
{
ShowPlayerDialog(playerid,REGISTER_DIALOG,DIALOG_STYLE_PASSWORD,"SpectralRP: Register","Enter your password below to register:","Register","Cancel");
}
mysql_free_result();
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid)
{
case LOGIN_DIALOG:
{
if(!response)
{
SendClientMessage(playerid, COLOR_LIGHTRED,"You need to be logged in!");
Kick(playerid);
}
LoginPlayer(playerid, inputtext);
}
case REGISTER_DIALOG:
{
if(!response)
{
SendClientMessage(playerid, COLOR_LIGHTRED,"You need to be logged in!");
Kick(playerid);
}
new query[512], username[MAX_PLAYER_NAME];
GetPlayerName(playerid, username, sizeof(username));
format(query, sizeof(query),"INSERT INTO `Users` (Username,Password) VALUES ('%s',md5('%s'))",username, inputtext);
mysql_function_query(dbconnect, query, false, "OnQueryFinish", "");
ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_PASSWORD,"SpectralRP: Login","Enter your password below to login:","Login","Cancel");
}
}
return 1;
}
stock LoginPlayer(playerid, pass[])
{
new query[1000], username[MAX_PLAYER_NAME];
GetPlayerName(playerid, username, sizeof(username));
format(query, sizeof(query),"SELECT * FROM `Users` WHERE Username = '%s' AND password = md5('%s')",username, pass);
mysql_function_query(dbconnect, query, false, "OnQueryFinish", "");
mysql_store_result();
if(mysql_num_rows() != 0)
{
if(mysql_fetch_row_format(query, "|"))
{
sscanf(query,"e<p<|>s[24]s[32]iiiiiiiiiiiiiifffiii>", PlayerInfo[playerid]);
new str[80];
format(str, sizeof(str),"Welcome %s, you have been loged to your account",username);
SendClientMessage(playerid, COLOR_BLUE, str);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
}
}
else
{
ShowPlayerDialog(playerid,LOGIN_DIALOG,DIALOG_STYLE_PASSWORD,"SpectralRP: Login.","Wrong password:","Login","Cancel");
}
}
stock SavePlayerStats(playerid)
{
new squery[1000];
GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
format(squery, sizeof(squery), "UPDATE Users SET Sex = %d,Age = %d, Origin = %d, Warns = %d, Money = %d, Level = %d, VIP = %d, Admin = %d, Tester = %d, Kills = %d, Deaths = %d, Muted = %d, Jailed = %d, Banned = %d, X = %f, Y = %f, Z = %f, Job = %d, Faction = %d, Rank = %d, WHERE username='%s'", PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pOrigin], PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pVIP], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pTester], PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pMuted], PlayerInfo[playerid][pJailed], PlayerInfo[playerid][pBanned], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pJob], PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pRank]);
mysql_function_query(dbconnect, squery, false, "OnQueryFinish", "");
mysql_free_result();
}
[21:58:55] >> mysql_query_callback( Connection handle: 1 )
[21:58:55] >> mysql_store_result( Connection handle: 1 )
[21:58:55] CMySQLHandler::StoreResult() - No data to store.
[21:58:55] >> mysql_num_rows( Connection handle: 1 )
[21:58:55] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)
[21:58:55] >> mysql_free_result( Connection handle: 1 )
[21:58:55] CMySQLHandler::FreeResult() - The result is already empty.
[21:58:55] Passing query SELECT * FROM `Users` WHERE Username='Connor_Howell' |
[21:58:55] ProcessQueryThread(OnQueryFinish) - Query was successful. (SELECT * FROM `Users` WHERE Username='Connor_Howell')
[21:58:55] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[21:58:55] OnQueryFinish() - Threaded function called.
[21:58:59] >> mysql_query_callback( Connection handle: 1 )
[21:58:59] >> mysql_store_result( Connection handle: 1 )
[21:58:59] CMySQLHandler::StoreResult() - Result was stored.
[21:58:59] >> mysql_num_rows( Connection handle: 1 )
[21:58:59] CMySQLHandler::NumRows() - Returned 0 row(s)
[21:58:59] Passing query SELECT * FROM `Users` WHERE Username = '' AND password = md5('') |
[21:58:59] ProcessQueryThread(OnQueryFinish) - Query was successful. (SELECT * FROM `Users` WHERE Username = '' AND password = md5(''))
[21:58:59] CMySQLHandler::ProcessQueryThread() - Data is getting passed to ->ProcessTick()
[21:58:59] OnQueryFinish() - Threaded function called.
Threaded queries cannot immediately be retrieved after you've sent them. That's the whole point of threads. The MySQL server will call your specified Pawn function (OnQueryFinish) as soon as it's done executing.
|
stock SavePlayerStats(playerid)
{
new squery[1000], username[MAX_PLAYER_NAME];
GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
GetPlayerName(playerid, username, sizeof(username));
format(squery, sizeof(squery), "UPDATE Users SET Sex = %d,Age = %d, Origin = %d, Warns = %d, Money = %d, Level = %d, VIP = %d, Admin = %d, Tester = %d, Kills = %d, Deaths = %d, Muted = %d, Jailed = %d, Banned = %d, X = %f, Y = %f, Z = %f, Job = %d, Faction = %d, Rank = %d, WHERE username='%s'", PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pOrigin], PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pVIP], PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pTester], PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pMuted], PlayerInfo[playerid][pJailed], PlayerInfo[playerid][pBanned], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pJob], PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pRank], username);
mysql_function_query(dbconnect, squery, false, "OnQueryFinish", "");
mysql_free_result();
}
Y:\Documents\SpectralRP\gamemodes\spectral.pwn(366) : error 075: input line too long (after substitutions) Y:\Documents\SpectralRP\gamemodes\spectral.pwn(367) : error 017: undefined symbol "P" Y:\Documents\SpectralRP\gamemodes\spectral.pwn(368) : warning 217: loose indentation Y:\Documents\SpectralRP\gamemodes\spectral.pwn(368) : error 017: undefined symbol "layerInfo" Y:\Documents\SpectralRP\gamemodes\spectral.pwn(368) : warning 215: expression has no effect Y:\Documents\SpectralRP\gamemodes\spectral.pwn(368) : error 001: expected token: ";", but found "]" Y:\Documents\SpectralRP\gamemodes\spectral.pwn(368) : error 029: invalid expression, assumed zero Y:\Documents\SpectralRP\gamemodes\spectral.pwn(368) : fatal error 107: too many error messages on one line
Are you using mysql R7, or why do you use mysql_query_function? ... Use mysq_query.
|
stock SavePlayerStats(playerid) { new squery[1000], username[MAX_PLAYER_NAME]; GetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]); PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid); GetPlayerName(playerid, username, sizeof(username)); format(squery, sizeof(squery), "UPDATE Users SET Sex = %d,Age = %d, Origin = %d, Warns = %d, Money = %d, Level = %d, VIP = %d, Admin = %d",PlayerInfo[playerid][pSex], PlayerInfo[playerid][pAge], PlayerInfo[playerid][pOrigin], PlayerInfo[playerid][pWarns], PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pVIP], PlayerInfo[playerid][pAdmin]); format(squery, sizeof(squery), "%s,Tester = %d, Kills = %d, Deaths = %d, Muted = %d, Jailed = %d, Banned = %d, X = %f, Y = %f", szQuery, PlayerInfo[playerid][pTester], PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pMuted], PlayerInfo[playerid][pJailed], PlayerInfo[playerid][pBanned], PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY]); format(squery, sizeof(squery), "%s,Z = %f, Job = %d, Faction = %d, Rank = %d, WHERE username='%s'", szQuery, PlayerInfo[playerid][pPosZ], PlayerInfo[playerid][pJob], PlayerInfo[playerid][pFaction], PlayerInfo[playerid][pRank], username); mysql_function_query(dbconnect, squery, false, "OnQueryFinish", ""); mysql_free_result(); }