04.09.2017, 19:58
For some reason, this code is making all the registration-related dialogs appear at the same time as each other when a new player registers. When I remove this code, this problem does not happen. I am attempting to learn PAWN by editing Emmet_'s SC-RP script. This code is my attempt at a logout system (which lets you switch your character) and it works fine, however for some reason it messes up registration dialogs.
At first, I thought the textdraws were screwing up because I was using ShowCharacterMenu again, so I duplicated ShowCharacterMenu but renamed it to ShowLogoutMenu, but this didn't fix it.
PHP код:
CMD:logout(playerid,params[])
{
new str[128], query[128];
PlayerData[playerid][pLogout] = 1;
if(PlayerData[playerid][pLoopAnim])
{
PlayerData[playerid][pLoopAnim] = 0;
}
CancelDrivingTest(playerid);
format(str, sizeof(str), "%s has logged out.", ReturnName(playerid, 0));
SendAdminAlert(COLOR_GREY, str);
SendNearbyMessage(playerid, 30.0, COLOR_GREY, "%s has logged out.", ReturnName(playerid, 0));
SQL_SaveCharacter(playerid);
PlayerCar_Unload(playerid);
PlayerData[playerid][pLogged] = 0;
SetPlayerName(playerid, PlayerData[playerid][pUsername]);
SetPlayerCameraPos(playerid, 2053.0479, -190.9246, 30.0708);
SetPlayerCameraLookAt(playerid, 2053.6860, -190.1540, 30.0559);
format(query, sizeof(query), "SELECT * FROM `characters` WHERE `Username` = '%s' LIMIT 3", PlayerData[playerid][pUsername]);
mysql_function_query(g_iHandle, query, true, "OnQueryFinished", "dd", playerid, THREAD_CHARACTERS);
return 1;
}
forward OnQueryFinished(extraid, threadid);
public OnQueryFinished(extraid, threadid)
{
if (!IsPlayerConnected(extraid))
return 0;
static
rows,
fields;
switch (threadid)
{
case THREAD_CHARACTERS:
{
cache_get_data(rows, fields, g_iHandle);
for (new i = 0; i < rows; i ++) {
cache_get_field_content(i, "Character", PlayerCharacters[extraid][i], g_iHandle);
}
if(PlayerData[extraid][pLogout] == 0)
{
SendServerMessage(extraid, "You have authenticated into your account successfully.");
ShowCharacterMenu(extraid);
}
else if(PlayerData[extraid][pLogout] == 1)
{
SendServerMessage(extraid, "You have logged out.");
ShowCharacterMenu(extraid);
}
}
// ... more threads
}
return 1;
}
ShowCharacterMenu(playerid)
{
new str[32];
if (PlayerData[playerid][pCharacter] != 0)
{
PlayerData[playerid][pCharacter] = 0;
for (new i = 0; i < 8; i ++) {
PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
}
for (new i = 71; i < 81; i ++) {
PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
}
}
for (new i = 0; i < 8; i ++)
{
if (i < 3) {
format(str, sizeof(str), "%s", (!PlayerCharacters[playerid][i][0]) ? ("Empty Slot") : (PlayerCharacters[playerid][i]));
PlayerTextDrawSetString(playerid, PlayerData[playerid][pTextdraws][i + 5], str);
}
PlayerTextDrawHide(playerid, PlayerData[playerid][pTextdraws][i]);
PlayerTextDrawShow(playerid, PlayerData[playerid][pTextdraws][i]);
}
SelectTextDraw(playerid, -1);
}