SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 28/02/2010, 06:51 PM   #1
NeRoSiS
Gangsta
 
Join Date: Feb 2008
Posts: 555
Reputation: 3
Default MYSQL Issue - Callback "hanging"

Hey,

I have a problem where my "OnPlayerLogin" callback hangs, I know roughly where it hangs, and after hours of debugging, have no idea whats up.

Heres my whole OnPlayerLogin code, the commented lines show where I believe the problem is. ( I know this because of print() tests and the mysql log.)

pawn Code:
public OnPlayerLogin(playerid,password[])
{

    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
  new query[1024];
  MySQLCheck();
  mysql_real_escape_string(pName,pName);
  mysql_real_escape_string(password,password);
  format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' AND Password = '%s' LIMIT 1",pName,md5(password));
  mysql_query(query);
  mysql_store_result();
  if(mysql_num_rows() != 0) {

    new pName1[MAX_PLAYER_NAME];//
        GetPlayerName(playerid,pName1,sizeof(pName1));//
      format(query,sizeof(query),"SELECT * FROM `"TABLENAME"` WHERE Username = '%s' LIMIT 1", pName1);//
        mysql_query(query);//
        mysql_store_result();//
       
    new resultline[512],player[44][128];//
    mysql_fetch_row_format(resultline,"|");//
    split(resultline, player, '|');//

    PlayerInfo[playerid][pLevel] = strval(player[3]);
    PlayerInfo[playerid][pAdmin] = strval(player[4]);
    PlayerInfo[playerid][pDonateRank] = strval(player[5]);
    PlayerInfo[playerid][pRegistered] = strval(player[6]);
    PlayerInfo[playerid][pSex] = strval(player[7]);
    PlayerInfo[playerid][pAge] = strval(player[8]);
    PlayerInfo[playerid][pExp] = strval(player[9]);
    PlayerInfo[playerid][pCash] = strval(player[10]);
    PlayerInfo[playerid][pBank] = strval(player[11]);
    PlayerInfo[playerid][pSkin] = strval(player[12]);
    PlayerInfo[playerid][pDrugs] = strval(player[13]);
    PlayerInfo[playerid][pMaterials] = strval(player[14]);
    PlayerInfo[playerid][pJob] = strval(player[15]);
    PlayerInfo[playerid][pPlayingHours] = strval(player[16]);
    PlayerInfo[playerid][pAllowedPayday] = strval(player[17]);
    PlayerInfo[playerid][pPayCheck] = strval(player[18]);
    PlayerInfo[playerid][pFaction] = strval(player[19]);
    PlayerInfo[playerid][pRank] = strval(player[20]);
    PlayerInfo[playerid][pHouseKey] = strval(player[21]);
    PlayerInfo[playerid][pBizKey] = strval(player[22]);
    PlayerInfo[playerid][pSpawnPoint] = strval(player[23]);
    PlayerInfo[playerid][pBanned] = strval(player[24]);
    PlayerInfo[playerid][pWarnings] = strval(player[25]);
    PlayerInfo[playerid][pCarLic] = strval(player[26]);
    PlayerInfo[playerid][pFlyLic] = strval(player[27]);
    PlayerInfo[playerid][pWepLic] = strval(player[28]);
    PlayerInfo[playerid][pPhoneNumber] = strval(player[29]);
    PlayerInfo[playerid][pPhoneC] = strval(player[30]);
    PlayerInfo[playerid][pPhoneBook] = strval(player[31]);
    PlayerInfo[playerid][pListNumber] = strval(player[32]);
    PlayerInfo[playerid][pDonator] = strval(player[33]);
    PlayerInfo[playerid][pJailed] = strval(player[34]);
    PlayerInfo[playerid][pJailTime] = strval(player[35]);
    PlayerInfo[playerid][pProducts] = strval(player[36]);
    PlayerInfo[playerid][pCrashX] = strval(player[37]);
    PlayerInfo[playerid][pCrashY] = strval(player[38]);
    PlayerInfo[playerid][pCrashZ] = strval(player[39]);
    PlayerInfo[playerid][pCrashInt] = strval(player[40]);
    PlayerInfo[playerid][pCrashW] = strval(player[41]);
    PlayerInfo[playerid][pCrashed] = strval(player[42]);

    mysql_free_result();
    SendClientMessage(playerid,COLOR_MEDIUMBLUE,"mysql_free_result();");
//other variables
        ResetPlayerCash(playerid);
    GivePlayerCash(playerid, PlayerInfo[playerid][pCash]);

    gPlayerLogged[playerid] = 1;
    SendClientMessage(playerid,COLOR_MEDIUMBLUE,"gPlayerLogged[playerid] = 1;");
    SendClientMessage(playerid, COLOR_BLUE,"        You are now logged in!");
    if(PlayerInfo[playerid][pFaction] != 255) {
      if(DynamicFactions[PlayerInfo[playerid][pFaction]][fUseColor]) {
        SetPlayerToFactionColor(playerid);
      }
    }
    else {
      SetPlayerColor(playerid,COLOR_CIVILIAN);
    }
    if(PlayerInfo[playerid][pBanned]) {
      KickPlayer(playerid,"System","Account Banned.");
    }
    if(PlayerInfo[playerid][pRegistered] == 0) {
      PlayerInfo[playerid][pLevel] = 1;
      PlayerInfo[playerid][pCash] = 2500;
      PlayerInfo[playerid][pBank] = 7500;
      PlayerInfo[playerid][pSkin] = 200;
      SetPlayerCash(playerid,PlayerInfo[playerid][pCash]);
      TogglePlayerControllable(playerid,0);
      SendClientMessage(playerid,COLOR_LIGHTYELLOW2,"[INFO:] You have not yet set your age, set it now by typing ages between 16-100.");
      RegistrationStep[playerid] = 1;
      ShowPlayerDialog(playerid,DIALOG_REG2,DIALOG_STYLE_INPUT,"Age","Please select your age, type in a value from 16 to 100.","Select","Cancel");
    }
    SetPlayerCash(playerid,PlayerInfo[playerid][pCash]);
    SendClientMessage(playerid, COLOR_YELLOW2, "[INFO:] Successfully logged in.");
    gPlayerLogged[playerid] = 1;
    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin],CivilianSpawn[X],CivilianSpawn[Y],CivilianSpawn[Z],0,0,0,0,0,0,0);
    if(PlayerInfo[playerid][pRegistered] == 1)SpawnPlayer(playerid);

  }
  else {
    SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "Incorrect password!");
    ShowPlayerDialog(playerid,DIALOG_LOG,DIALOG_STYLE_INPUT,"Login","Enter your password below:","Login","Cancel");
    mysql_free_result();
    return 1;
  }
  return 1;
}

Thanks a lot.
NeRoSiS is offline  
 

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
Admin script requires "ReturnUser", "strtok" and "IsNumeric" Rubennnnn Help Archive 1 02/12/2009 06:08 PM
Issue about /enter & /exit commands at an "i" icon Alice[WS] Help Archive 1 07/08/2009 08:18 PM
Does exist a callback like "OnGameModeChange" GammerZ Help Archive 3 14/06/2009 12:07 AM
"Bots", "AI", "NPCs"... Computer-controlled pedestrians and traffic! ssflsnoob General 2 23/11/2008 06:06 PM


All times are GMT. The time now is 08:30 AM.


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