SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/01/2018, 09:51 AM   #1
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,698
Reputation: 484
Default SQLite: Database is locked

What causes this error?

Code:
[10:37:17] [Warning] db_query: Query failed: database is locked
[10:37:17] [Error] db_free_result(): invalid result handle 0
[10:37:17] [Error] db_free_result(): invalid result handle 1
There is this problem like when I try to connect in the server - The server won't recognize that there is already a row registered under my name. However what I noticed is, It recognized my account the first time I logged in but as soon as I relogged (having 2 players in the server already) the server won't recognize my account anymore and is prompting me to register an account, Why is that?
JaKe Elite is offline   Reply With Quote
Old 04/02/2018, 09:05 AM   #2
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,698
Reputation: 484
Default Re: SQLite: Database is locked

Still experiencing the same exact problem, Can someone at least tell me what is causing this problem?
JaKe Elite is offline   Reply With Quote
Old 04/02/2018, 10:27 AM   #3
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 681
Reputation: 3
Default Re: SQLite: Database is locked

show us the line where a row is added in the mysql database ( after register )
PepsiCola23 is offline   Reply With Quote
Old 04/02/2018, 11:18 AM   #4
GTLS
Huge Clucker
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 481
Reputation: 68
Default Re: SQLite: Database is locked

You're entering the password wrong?
__________________

I don't help for rep. I help cuz I was helped in the past.
GTLS is offline   Reply With Quote
Old 05/02/2018, 11:30 AM   #5
Sithis
Gangsta
 
Join Date: Mar 2013
Location: the Netherlands
Posts: 919
Reputation: 73
Default Re: SQLite: Database is locked

You probably forgot to close the database handle in another query, causing the database to be locked.
__________________
Developer and owner of https://trinityrpg.com
Sithis is offline   Reply With Quote
Old 05/02/2018, 05:36 PM   #6
AdrianGraber
Big Clucker
 
AdrianGraber's Avatar
 
Join Date: Mar 2013
Location: Germany
Posts: 97
Reputation: 102
Default Re: SQLite: Database is locked

Quote:
Originally Posted by GTLS View Post
You're entering the password wrong?
SQLite databases are files, not servers!
AdrianGraber is offline   Reply With Quote
Old 10/02/2018, 09:28 PM   #7
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,698
Reputation: 484
Default Re: SQLite: Database is locked

I'm honestly clueless where the problem is coming from, Should I use db_debug_openresults?
JaKe Elite is offline   Reply With Quote
Old 11/02/2018, 06:14 AM   #8
iKarim
Gangsta
 
iKarim's Avatar
 
Join Date: Oct 2015
Posts: 586
Reputation: 132
Default Re: SQLite: Database is locked

This usually happens when you are writing to the database from 2 different sources. There's a database handle that is active or wasn't closed properly that results in your database being write locked.

Are you sure you aren't accessing the database with any SQLite browser while the server is running?
Does it happen on every query or just specific queries in a specific code block?
iKarim is offline   Reply With Quote
Old 12/02/2018, 11:36 AM   #9
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,698
Reputation: 484
Default Re: SQLite: Database is locked

Not that I know of, But I do think it has something to do with the unoptimized way of reading data like this for example.

PHP Code:
public OnUserPlayerLogin(playeridpassword[])
{
    new 
hash[65], DBResult:Resultsz_Query[92];
    
SHA256_PassHash(passwordPlayerInfo[playerid][pSalt], hash64);
    
    
format(sz_Querysizeof(sz_Query), "SELECT * FROM `users` WHERE `admin_name` = '%s'"GetPlayersName(playerid));
    
Result db_query(Databasesz_Query);
    if(!
strcmp(hashPlayerInfo[playerid][pKey]))
    {
        
db_get_field_assoc(Result"admin_name"PlayerInfo[playerid][pAdminName], MAX_PLAYER_NAME);
        
db_get_field_assoc(Result"email"PlayerInfo[playerid][pEmail], 64);
        
PlayerInfo[playerid][pAdmin] = db_get_field_assoc_int(Result"adminlevel");
        
PlayerInfo[playerid][pBanned] = db_get_field_assoc_int(Result"banned");
        
PlayerInfo[playerid][pPermaBanned] = db_get_field_assoc_int(Result"permbanned");
        
PlayerInfo[playerid][pWarns] = db_get_field_assoc_int(Result"warnings");
        
PlayerInfo[playerid][pLWarns] = db_get_field_assoc_int(Result"logwarnings");
        
PlayerInfo[playerid][pDonateRank] = db_get_field_assoc_int(Result"donaterank");
        
PlayerInfo[playerid][pBuddyInvited] = db_get_field_assoc_int(Result"buddyinvited");
        
PlayerInfo[playerid][pBanAppealer] = db_get_field_assoc_int(Result"banappealer");
        
PlayerInfo[playerid][pShopTech] = db_get_field_assoc_int(Result"shoptech");
        
PlayerInfo[playerid][pVehMods] = db_get_field_assoc_int(Result"vehmodder");
        
PlayerInfo[playerid][pUndercover] = db_get_field_assoc_int(Result"undercover");
        
PlayerInfo[playerid][pTogReports] = db_get_field_assoc_int(Result"togreports");
        
PlayerInfo[playerid][pFactionModerator] = db_get_field_assoc_int(Result"factionmod");
        
PlayerInfo[playerid][pGangModerator] = db_get_field_assoc_int(Result"gangmod");
        
PlayerInfo[playerid][gPupgrade] = db_get_field_assoc_int(Result"upgradepoints");
        
PlayerInfo[playerid][pConnectTime] = db_get_field_assoc_int(Result"connectedtime");
        
PlayerInfo[playerid][pHelper] = db_get_field_assoc_int(Result"helper");
        
PlayerInfo[playerid][pDutyHours] = db_get_field_assoc_int(Result"helphours");
        
PlayerInfo[playerid][pAcceptedHelp] = db_get_field_assoc_int(Result"acceptedhelp");
        
PlayerInfo[playerid][pAcceptReport] = db_get_field_assoc_int(Result"acceptreport");
        
PlayerInfo[playerid][pTrashReport] = db_get_field_assoc_int(Result"trashreport");
          
PlayerInfo[playerid][pGangWarn] = db_get_field_assoc_int(Result"gangwarn");
        
PlayerInfo[playerid][pAMSSent] = db_get_field_assoc_int(Result"amsent");
        
db_get_field_assoc(Result"prisonedby"PlayerInfo[playerid][pPrisonedBy], MAX_PLAYER_NAME);
        
db_get_field_assoc(Result"prisonreason"PlayerInfo[playerid][pPrisonReason], 128);
        
PlayerInfo[playerid][pOrder] = db_get_field_assoc_int(Result"order");
        
PlayerInfo[playerid][pOBlocked] = db_get_field_assoc_int(Result"oblocked");
        
PlayerInfo[playerid][pUnListed] = db_get_field_assoc_int(Result"unlisted");
        
PlayerInfo[playerid][pTokens] = db_get_field_assoc_int(Result"viptokens");
        
PlayerInfo[playerid][pMuted] = db_get_field_assoc_int(Result"muted");
        
PlayerInfo[playerid][pNMute] = db_get_field_assoc_int(Result"newbmuted");
        
PlayerInfo[playerid][pADMute] = db_get_field_assoc_int(Result"admuted");
        
PlayerInfo[playerid][pOOCMute] = db_get_field_assoc_int(Result"oocmuted");
        
PlayerInfo[playerid][pAmute] = db_get_field_assoc_int(Result"amuted");
        
PlayerInfo[playerid][pCMute] = db_get_field_assoc_int(Result"cmuted");
        
PlayerInfo[playerid][pRMuted] = db_get_field_assoc_int(Result"rmuted");
        
PlayerInfo[playerid][pRMutedTime] = db_get_field_assoc_int(Result"rmutedtime");
        
PlayerInfo[playerid][pVMuted] = db_get_field_assoc_int(Result"vmuted");
        
db_free_result(Result);

        
// Loads Characters Data
        
LoadCharacter(playerid);
        
LoadCharItems(playerid);
        
LoadCharJobSkills(playerid);
        
LoadCharLicenses(playerid);
        
LoadCharGuns(playerid);
        
LoadCharTime(playerid); // waiting time (jail time etc..)
        
LoadCharSkills(playerid); // weapon skills
        
LoadCharVehiclesModification(playerid);
        
LoadCharVehiclesWeapon(playerid);
        
LoadCharVehicles(playerid);
        
LoadCharToys(playerid);

        
SetPlayerName(playeridPlayerInfo[playerid][pRPName]);
        
ResetPlayerMoney(playerid);
        
CurrentMoney[playerid] = GetPVarInt(playerid"Cash");
        
TotalLogin++;
        
OnHelp[playerid] = INVALID_PLAYER_ID;
        
PlayerInfo[playerid][pJustLogged] = 30;
        
PlayerInfo[playerid][pLoggedIn] = 1;
        
PlayerInfo[playerid][pLoginTime] = 0;

        if(
PlayerInfo[playerid][pTruckingLevel] == 0PlayerInfo[playerid][pTruckingLevel] = 1;

        
//SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);

        
if(PlayerInfo[playerid][pHospital] == 1)
        {
            
PlayerInfo[playerid][pHospital] = 0;
            
SetPVarInt(playerid"MedicBill"1);
        }

        if( 
PlayerInfo[playerid][pBanAppealer] >= && PlayerInfo[playerid][pAdmin] < 1PlayerInfo[playerid][pBanAppealer] = 0;

        if( 
PlayerInfo[playerid][pUndercover] >= && PlayerInfo[playerid][pAdmin] < 1PlayerInfo[playerid][pUndercover] = 0;

        if( 
PlayerInfo[playerid][pFactionModerator] >= && PlayerInfo[playerid][pAdmin] < 1PlayerInfo[playerid][pFactionModerator] = 0;

        if( 
PlayerInfo[playerid][pBanAppealer] > 1PlayerInfo[playerid][pBanAppealer] = 0;

        if( 
PlayerInfo[playerid][pShopTech] > 1PlayerInfo[playerid][pShopTech] = 0;

        if( 
PlayerInfo[playerid][pUndercover] > 1PlayerInfo[playerid][pUndercover] = 0;

        if( 
PlayerInfo[playerid][pFactionModerator] > 1PlayerInfo[playerid][pFactionModerator] = 0;

        if( 
PlayerInfo[playerid][pGangModerator] > 1PlayerInfo[playerid][pGangModerator] = 0;

        if(
PlayerInfo[playerid][pJob2] >= && PlayerInfo[playerid][pDonateRank] < 1)
        {
            
PlayerInfo[playerid][pJob2] = 0;
            
SendClientMessageEx(playeridCOLOR_YELLOW"VIP: You have lost your secondary job due to the fact that you are longer a VIP.");
        }
        if(
PlayerInfo[playerid][pDonateRank] >= && PlayerInfo[playerid][pArmsSkill] < 400)
        {
            
PlayerInfo[playerid][pArmsSkill] = 401;
            
SendClientMessageEx(playeridCOLOR_YELLOW"Platinum VIP Feature: You have been given Level 5 Arms Dealer.");
        }

        if (
PlayerInfo[playerid][pAdmin] >= 1)
        {
            
PlayerInfo[playerid][pToggedVIPChat] = 1;
        }
        if (
PlayerInfo[playerid][pLevel] < || PlayerInfo[playerid][pAdmin] > 0)
        {
            
gNewbie[playerid] = 0;
        }
        if (
PlayerInfo[playerid][pHelper] >= || PlayerInfo[playerid][pAdmin] == 1)
        {
            
gNewbie[playerid] = 0;
        }
        
        if (
PlayerInfo[playerid][pAdmin] > 0)
        {
            if(
PlayerInfo[playerid][pAdmin] >= 1)
            {
                
format(sz_Querysizeof(sz_Query), "{6CC417}AdminNotice{FFFFFF}: You are logged in as a level %d Administrator.",PlayerInfo[playerid][pAdmin]);
                
SendClientMessageEx(playeridCOLOR_WHITE,sz_Query);
            }

               if(
PlayerInfo[playerid][pAdmin] >= 1)
            {
                
formatsz_Querysizeofsz_Query ), "{6CC417}AdminNotice{FFFFFF}: Administrator %s has just logged in."PlayerInfo[playerid][pAdminName]);
            }

            foreach(
Playeri)
            {
                if( 
PlayerInfo[i][pAdmin] >= 1337 )
                {
                    if(
PlayerInfo[i][pAdmin] >= PlayerInfo[playerid][pAdmin]) SendClientMessageEx(iCOLOR_WHITEsz_Query);
                }
            }

        }

        
ToggleMainMenu(playerid0);
        
printf("%s has logged in."GetPlayersName(playerid));
        
format(sz_Querysizeof(sz_Query), "Welcome to Andreas Nations Roleplay, %s."PlayerInfo[playerid][pAdminName]);
        
SendClientMessageEx(playeridCOLOR_YELLOWsz_Query);
        
SetSpawnInfo(playeridPlayerInfo[playerid][pTeam], PlayerInfo[playerid][pModel], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
        
SpawnPlayer(playerid);
        
SkinDelay(playerid);

        if(
PlayerInfo[playerid][pInt] > || PlayerInfo[playerid][pVW] > 0)
        {
            
TogglePlayerControllable(playerid0);
              
GameTextForPlayer(playerid"Objects loading..."40005);
            
SetPVarInt(playerid"LoadingObjects"1);
            
SetTimerEx("SafeLoadObjects"40000"d"playerid);
        }
        
        
gPlayerLogged{playerid} = 1;
        
SetPVarInt(playerid"MedicBill"0);
        
format(sz_Querysizeof(sz_Query), "~w~Welcome~n~~y~%s~n~~h~~b~www.an-rp.com"PlayerInfo[playerid][pAdminName]);
        
GameTextForPlayer(playeridsz_Query50001);
        
SendClientMessageEx(playeridCOLOR_YELLOWGlobalMOTD);
        if(
PlayerInfo[playerid][pAdmin] >= 1)
        {
            
SendClientMessageEx(playeridCOLOR_GREENAdminMOTD);
        }
        if(
PlayerInfo[playerid][pAdmin] > 0)
        {
            
SendClientMessageEx(playeridTEAM_AZTECAS_COLORCAMOTD);
        }
        if(
PlayerInfo[playerid][pDonateRank] >= 1SendClientMessageEx(playeridCOLOR_VIPVIPMOTD);
        if(
PlayerInfo[playerid][pHelper] >= 1SendClientMessageEx(playeridCOLOR_LIGHTBLUECAMOTD);
        if(
PlayerInfo[playerid][pMember] == 1SendClientMessageEx(playeridCOLOR_DBLUEPDMOTD);
        if(
PlayerInfo[playerid][pMember] == 19SendClientMessageEx(playeridCOLOR_DBLUELVPDMOTD);
        
SetPlayerFightingStyle(playeridPlayerInfo[playerid][pFightStyle]);
        
LoadPlayerVehicles(playerid);
        
SetPlayerToTeamColor(playerid);
        if(
PlayerInfo[playerid][pFMember] < 255)
        {
            
format(sz_Querysizeof(sz_Query), "Family MOTD: %s."FamilyInfo[PlayerInfo[playerid][pFMember]][FamilyMOTD]);
            
SendClientMessageEx(playeridTEAM_VAGOS_COLORsz_Query);
        }

        if(
PlayerInfo[playerid][pOrder] > 0)
        {
            
format(sz_Querysizeof(sz_Query), "SERVER: %s has an outstanding market place order."PlayerInfo[playerid][pAdminName]);
            
ShopTechBroadCast(COLOR_WHITEsz_Query);
          }

         new 
hcheck INVALID_HOUSE_IDhcheck2 INVALID_HOUSE_ID;

        for(new 
0MAX_HOUSESi++)
        {
              if(!
strcmp(PlayerInfo[playerid][pRPName], HouseInfo[i][hOwner], false) && HouseInfo[i][hOwned] != 0)
               {
                   if(
hcheck != INVALID_HOUSE_ID)
                   {
                       
hcheck2 i;
                }
                else
                {
                    
hcheck i;
                }
            }
        }
        if(
hcheck != INVALID_HOUSE_ID)
           {
             
PlayerInfo[playerid][pPhousekey] = hcheck;
        }
        if(
hcheck2 != INVALID_HOUSE_ID)
           {
             
PlayerInfo[playerid][pPhousekey2] = hcheck2;
        }
        if(
hcheck == INVALID_HOUSE_ID)
        {
            
PlayerInfo[playerid][pPhousekey] = INVALID_HOUSE_ID;
            return 
1;
        }
        if(
hcheck2 == INVALID_HOUSE_ID)
        {
            
PlayerInfo[playerid][pPhousekey2] = INVALID_HOUSE_ID;
            return 
1;
        }
    }
    else
    {
        
db_free_result(Result);
        
ShowMainMenuDialog(playerid3);
        
gPlayerLogTries[playerid] += 1;
        if(
gPlayerLogTries[playerid] == 3) {
            
ShowPlayerDialog(playeridDIALOG_SHOW_INFODIALOG_STYLE_MSGBOX"{008000}You've been Auto-Kicked from the Server""{FF0000}You've typed the wrong password too many times.""Ok""Cancel");
            
SetTimerEx("SendToKick"15000"i"playerid);
        }
     }
    return 
1;
}

stock LoadCharToys(playerid)
{
    new 
DBResult:Resultsz_Query[128], var[32];
    
format(sz_Querysizeof(sz_Query), "SELECT * FROM `char_toys` WHERE `charid` = %d"PlayerInfo[playerid][pCharID]);
    
Result db_query(Databasesz_Query);
    if(
db_num_rows(Result))
    {
        for(new 
0MAX_PLAYERTOYSv++)
        {
            
format(var, 32"pt%dModelID",v);
            
PlayerToyInfo[playerid][v][ptModelID] = db_get_field_assoc_int(Result, var);
            
format(var, 32"pt%dBone",v);
            
PlayerToyInfo[playerid][v][ptBone] = db_get_field_assoc_int(Result, var);
            
format(var, 32"pt%dPosX",v);
            
PlayerToyInfo[playerid][v][ptPosX] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dPosY",v);
            
PlayerToyInfo[playerid][v][ptPosY] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dPosZ",v);
            
PlayerToyInfo[playerid][v][ptPosZ] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dRotX",v);
            
PlayerToyInfo[playerid][v][ptRotX] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dRotY",v);
            
PlayerToyInfo[playerid][v][ptRotY] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dRotZ",v);
            
PlayerToyInfo[playerid][v][ptRotZ] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dScaleX",v);
            
PlayerToyInfo[playerid][v][ptScaleX] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dScaleY",v);
            
PlayerToyInfo[playerid][v][ptScaleY] = db_get_field_assoc_float(Result, var);
            
format(var, 32"pt%dScaleZ",v);
            
PlayerToyInfo[playerid][v][ptScaleZ] = db_get_field_assoc_float(Result, var);
        }
    }
    
db_free_result(Result);
    return 
1;
}

stock LoadCharacter(playerid)
{
    new 
DBResult:Resultsz_Query[128];
    
format(sz_Querysizeof(sz_Query), "SELECT * FROM `characters` WHERE `userid` = %d"PlayerInfo[playerid][pUserID]);
    
Result db_query(Databasesz_Query);
    if(
db_num_rows(Result))
    {
        
PlayerInfo[playerid][pCharID] = db_get_field_assoc_int(Result"charid");
        
db_get_field_assoc(Result"rp_name"PlayerInfo[playerid][pRPName], MAX_PLAYER_NAME);
        
PlayerInfo[playerid][pTut] = db_get_field_assoc_int(Result"tutorial");
        
PlayerInfo[playerid][pLevel] = db_get_field_assoc_int(Result"level");
        
PlayerInfo[playerid][pSex] = db_get_field_assoc_int(Result"sex");
        
PlayerInfo[playerid][pAge] = db_get_field_assoc_int(Result"age");
        
PlayerInfo[playerid][pExp] = db_get_field_assoc_int(Result"respect");
        
SetPVarInt(playerid"Cash"db_get_field_assoc_int(Result"money"));
        
PlayerInfo[playerid][pAccount] = db_get_field_assoc_int(Result"bank");
        
PlayerInfo[playerid][pCrimes] = db_get_field_assoc_int(Result"crimes");
        
db_get_field_assoc(Result"accent"PlayerInfo[playerid][pAccent], 32);
        
PlayerInfo[playerid][pArrested] = db_get_field_assoc_int(Result"arrested");
        
PlayerInfo[playerid][pJob] = db_get_field_assoc_int(Result"job");
        
PlayerInfo[playerid][pJob2] = db_get_field_assoc_int(Result"job2");
        
PlayerInfo[playerid][pPayCheck] = db_get_field_assoc_int(Result"paycheck");
        
PlayerInfo[playerid][pJailed] = db_get_field_assoc_int(Result"jailed");
        
PlayerInfo[playerid][pLeader] = db_get_field_assoc_int(Result"leader");
        
PlayerInfo[playerid][pMember] = db_get_field_assoc_int(Result"member");
        
PlayerInfo[playerid][pDivision] = db_get_field_assoc_int(Result"division");
        
PlayerInfo[playerid][pFMember] = db_get_field_assoc_int(Result"family");
        
PlayerInfo[playerid][pRank] = db_get_field_assoc_int(Result"rank");
        
PlayerInfo[playerid][pFightStyle] = db_get_field_assoc_int(Result"fightstyle");
        
PlayerInfo[playerid][pHealth] = db_get_field_assoc_float(Result"health");
        
PlayerInfo[playerid][pArmor] = db_get_field_assoc_float(Result"armor");
        
PlayerInfo[playerid][pSHealth] = db_get_field_assoc_float(Result"spawn_armor");
        
PlayerInfo[playerid][pInt] = db_get_field_assoc_int(Result"interior");
        
PlayerInfo[playerid][pLocal] = db_get_field_assoc_int(Result"local");
        
PlayerInfo[playerid][pVW] = db_get_field_assoc_int(Result"virtualworld");
        
PlayerInfo[playerid][pPos_x] = db_get_field_assoc_float(Result"x");
        
PlayerInfo[playerid][pPos_y] = db_get_field_assoc_float(Result"y");
        
PlayerInfo[playerid][pPos_z] = db_get_field_assoc_float(Result"z");
        
PlayerInfo[playerid][pPos_r] = db_get_field_assoc_float(Result"r");
        
PlayerInfo[playerid][pModel] = db_get_field_assoc_int(Result"model");
        
PlayerInfo[playerid][pPhousekey] = db_get_field_assoc_int(Result"house");
        
PlayerInfo[playerid][pPhousekey2] = db_get_field_assoc_int(Result"house2");
        
PlayerInfo[playerid][pRenting] = db_get_field_assoc_int(Result"renting");
        
PlayerInfo[playerid][pWins] = db_get_field_assoc_int(Result"wins");
        
PlayerInfo[playerid][pLoses] = db_get_field_assoc_int(Result"loses");
        
PlayerInfo[playerid][pDuty] = db_get_field_assoc_int(Result"duty");
        
SetPVarInt(playerid"Hospital"db_get_field_assoc_int(Result"hospital"));
        
PlayerInfo[playerid][pMarried] = db_get_field_assoc_int(Result"married");
        
PlayerInfo[playerid][pWantedLevel] = db_get_field_assoc_int(Result"wanted");
        
PlayerInfo[playerid][pInsurance] = db_get_field_assoc_int(Result"insurance");
        
PlayerInfo[playerid][pPayDay] = db_get_field_assoc_int(Result"payday");
        
PlayerInfo[playerid][pPayDayHad] = db_get_field_assoc_int(Result"paydayhad");
        
PlayerInfo[playerid][pNoble] = db_get_field_assoc_int(Result"noble");
        
PlayerInfo[playerid][pNoble2] = db_get_field_assoc_int(Result"noble2");
        
PlayerInfo[playerid][pNoble3] = db_get_field_assoc_int(Result"noble3");
        
PlayerInfo[playerid][pNoble4] = db_get_field_assoc_int(Result"noble4");
        
PlayerInfo[playerid][pCitizen] = db_get_field_assoc_int(Result"citizen");
        
PlayerInfo[playerid][pDispatch] = db_get_field_assoc_int(Result"dispatch");
        
PlayerInfo[playerid][pHospital] = db_get_field_assoc_int(Result"sendtohospital");
        
PlayerInfo[playerid][pSpeedTix] = db_get_field_assoc_int(Result"speedtickets");
        
db_get_field_assoc(Result"warrants"PlayerInfo[playerid][pWarrant], 128);
        
PlayerInfo[playerid][pJudgeJailType] = db_get_field_assoc_int(Result"judgejail");
        
PlayerInfo[playerid][pBeingSentenced] = db_get_field_assoc_int(Result"sentenced");
        
PlayerInfo[playerid][pCallsAccepted] = db_get_field_assoc_int(Result"callsaccepted");
        
PlayerInfo[playerid][pPatientsDelivered] = db_get_field_assoc_int(Result"ptdelivered");
        
PlayerInfo[playerid][pLiveBanned] = db_get_field_assoc_int(Result"livebanned");
        
PlayerInfo[playerid][pFreezeBank] = db_get_field_assoc_int(Result"bankfroze");
        
PlayerInfo[playerid][pTogRadio] = db_get_field_assoc_int(Result"togradio");
        
PlayerInfo[playerid][pTruckingLevel] = db_get_field_assoc_int(Result"truckinglevel");
        
PlayerInfo[playerid][pTruckingXP] = db_get_field_assoc_int(Result"truckingxp");
        
PlayerInfo[playerid][pJackAttempts] = db_get_field_assoc_int(Result"jackattempts");
        
PlayerInfo[playerid][pBadgeNum] = db_get_field_assoc_int(Result"badgenumber");
        
PlayerInfo[playerid][p911sAccepted] = db_get_field_assoc_int(Result"911accepted");
        
PlayerInfo[playerid][pArrestsMade] = db_get_field_assoc_int(Result"arrestmade");
        
PlayerInfo[playerid][pInfractionsIssued] = db_get_field_assoc_int(Result"infractionissued");
        
PlayerInfo[playerid][pEnrolledEZPass] = db_get_field_assoc_int(Result"ezpass");
        
PlayerInfo[playerid][pChopShopped] = db_get_field_assoc_int(Result"chopshopped");
        
PlayerInfo[playerid][pHouseSpawn] = db_get_field_assoc_int(Result"housespawn");
        
PlayerInfo[playerid][pTimedOut] = db_get_field_assoc_int(Result"timedout");
    }
    
db_free_result(Result);
    return 
1;

and so on
JaKe Elite is offline   Reply With Quote
Old 12/02/2018, 11:44 AM   #10
iKarim
Gangsta
 
iKarim's Avatar
 
Join Date: Oct 2015
Posts: 586
Reputation: 132
Default Re: SQLite: Database is locked

I don't see any problem with reading too much data since that doesn't write lock the database, it's most likely due to the fact that you open the database handle in OnGameModeInit and keep it open to be used every where in the gamemode, which usually cases problems like that, I'd rather open the database (and probably print a debug message) > execute the query (and free the result) > close the database.

The debug messages could be placed before every db_open call so it could be easier to track where exactly the problem occurs, for example:

PHP Code:
print("OnPlayerConnect: db_open"); 
iKarim is offline   Reply With Quote
Reply

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
SQLite not writing to database Mattakil Scripting Help 6 29/09/2013 10:13 PM
sqlite database mixmadamich Scripting Help 1 29/08/2013 01:56 PM
SQLite database Seregamil Русский/Russian 8 01/10/2012 06:40 PM
SQLite database Seregamil Scripting Help 0 30/09/2012 10:12 AM


All times are GMT. The time now is 04:13 AM.


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