MySQL Issue
#1

Hey there, I made this post because there is a issue which I cant really solve, I was wondering if there was other ways of saving 278 var's into MySQL when a player crashes fast enough, I mean, everytime a player crashes they seem to lose all their stats, and I think its the MySQL taking a long time but can someone help me out?
Reply
#2

Код:
stock SavePlayerData(playerid)
{
	if(IsPlayerConnected(playerid) == 1 && gPlayerLogged[playerid] == 1) {
	new IP[16],Name[MAX_PLAYER_NAME];
	GetPlayerIp(playerid, IP, sizeof(IP));
	GetPlayerName(playerid,Name,sizeof(Name));
	new query[3800];
	format(query,sizeof(query),

	"UPDATE accounts SET Cash=%d,AdminJailCount=%d,Account=%d,HouseRent=%d,ChatAnim=%d,Seeds=%d,OldCar=%d,AdminLevel=%d,Level=%d,Exp=%d,Arrive=%d,UpgradePoints=%d,Kills=%d,Gun1=%d, \
	Gun2=%d,Gun3=%d,Gun4=%d,Gun5=%d,Gun6=%d,Gun7=%d,Gun8=%d,Gun9=%d,Gun10=%d,Gun11=%d,Gun12=%d,Gun13=%d,Ammo1=%d,Ammo2=%d,Ammo3=%d,",
	GetPlayerPCash(playerid),PlayerInfo[playerid][pAjailc],PlayerInfo[playerid][pAccount],HouseRent[playerid],cAnim[playerid],PlayerInfo[playerid][pSeeds],OldCar[playerid],PlayerInfo[playerid][pAdmin],
	PlayerInfo[playerid][pLevel],PlayerInfo[playerid][pExp],PlayerInfo[playerid][pArrive],PlayerInfo[playerid][gPupgrade],PlayerInfo[playerid][pKills],
	PlayerInfo[playerid][pGun1],PlayerInfo[playerid][pGun2],PlayerInfo[playerid][pGun3],PlayerInfo[playerid][pGun4],PlayerInfo[playerid][pGun5],PlayerInfo[playerid][pGun6],
	PlayerInfo[playerid][pGun7],PlayerInfo[playerid][pGun8],PlayerInfo[playerid][pGun9],PlayerInfo[playerid][pGun10],PlayerInfo[playerid][pGun11],PlayerInfo[playerid][pGun12],PlayerInfo[playerid][pGun13],
	PlayerInfo[playerid][pAmmo1],PlayerInfo[playerid][pAmmo2],PlayerInfo[playerid][pAmmo3]); // Done

	format(query,sizeof(query),"%s Ammo4=%d,Ammo5=%d,Ammo6=%d,Ammo7=%d,Ammo8=%d,Ammo9=%d,Ammo10=%d,Ammo11=%d,Ammo12=%d,Ammo13=%d,",query,
	PlayerInfo[playerid][pAmmo4],PlayerInfo[playerid][pAmmo5],PlayerInfo[playerid][pAmmo6],PlayerInfo[playerid][pAmmo7],PlayerInfo[playerid][pAmmo8],PlayerInfo[playerid][pAmmo9],
    PlayerInfo[playerid][pAmmo10],PlayerInfo[playerid][pAmmo11],PlayerInfo[playerid][pAmmo12],PlayerInfo[playerid][pAmmo13]); // Done
    
	format(query,sizeof(query),"%s Weapon0=%d,Weapon1=%d,Weapon2=%d,Weapon3=%d,Weapon4=%d,Weapon5=%d,Weapon6=%d,",query,
    PlayerInfo[playerid][pFinWeapon][0],PlayerInfo[playerid][pFinWeapon][1],PlayerInfo[playerid][pFinWeapon][2],PlayerInfo[playerid][pFinWeapon][3],
	PlayerInfo[playerid][pFinWeapon][4],PlayerInfo[playerid][pFinWeapon][5],PlayerInfo[playerid][pFinWeapon][6]); // Done
	
	format(query,sizeof(query),"%s Weapon7=%d,Weapon8=%d,Weapon9=%d,Weapon10=%d,Weapon11=%d,Ammos0=%d,Ammos1=%d,Ammos2=%d,Ammos3=%d,Ammos4=%d,Ammos5=%d,Ammos6=%d,",query,
	PlayerInfo[playerid][pFinWeapon][7],PlayerInfo[playerid][pFinWeapon][8],PlayerInfo[playerid][pFinWeapon][9],PlayerInfo[playerid][pFinWeapon][10],
	PlayerInfo[playerid][pFinWeapon][11],PlayerInfo[playerid][pFinAmmo][0],PlayerInfo[playerid][pFinAmmo][1],PlayerInfo[playerid][pFinAmmo][2],PlayerInfo[playerid][pFinAmmo][3],
	PlayerInfo[playerid][pFinAmmo][4],PlayerInfo[playerid][pFinAmmo][5],PlayerInfo[playerid][pFinAmmo][6]); // Done

	format(query,sizeof(query),"%s Ammos7=%d,Ammos8=%d,Ammos9=%d,Ammos10=%d,Ammos11=%d,BoxItem1=%d,BoxItem2=%d,BoxItem3=%d,BoxItem4=%d,BoxItem5=%d,BoxItem7=%d,BoxItem8=%d,BoxItem9=%d,BoxItem10=%d,BoxItem11=%d,BoxAmmount0=%d, \
	BoxAmmount1=%d,BoxAmmount2=%d,BoxAmmount3=%d,BoxAmmount4=%d,",query,
	PlayerInfo[playerid][pFinAmmo][7],PlayerInfo[playerid][pFinAmmo][8],PlayerInfo[playerid][pFinAmmo][9],PlayerInfo[playerid][pFinAmmo][10],PlayerInfo[playerid][pFinAmmo][11],
	PlayerInfo[playerid][pBox][0],PlayerInfo[playerid][pBox][0],PlayerInfo[playerid][pBox][1],PlayerInfo[playerid][pBox][2],PlayerInfo[playerid][pBox][3],PlayerInfo[playerid][pBox][4],
	PlayerInfo[playerid][pBox][5],PlayerInfo[playerid][pBox][6],PlayerInfo[playerid][pBox][7],PlayerInfo[playerid][pBox][8],PlayerInfo[playerid][pBox][9],
	PlayerInfo[playerid][pBox][10],PlayerInfo[playerid][pBoxAmmo][0],PlayerInfo[playerid][pBoxAmmo][1],PlayerInfo[playerid][pBoxAmmo][2],PlayerInfo[playerid][pBoxAmmo][3]); // Done

	format(query,sizeof(query),"%s BoxAmmount5=%d,BoxAmmount6=%d,BoxAmmount7=%d,BoxAmmount8=%d,BoxAmmount9=%d,BoxAmmount10=%d,BoxAmmount11=%d, \
	pSHealth=%f,Health=%f,Pos_x=%f,Pos_y=%f,Pos_z=%f,Interior=%d,DebitCard=%d,",query,PlayerInfo[playerid][pBoxAmmo][4],PlayerInfo[playerid][pBoxAmmo][5],PlayerInfo[playerid][pBoxAmmo][6],PlayerInfo[playerid][pBoxAmmo][7],PlayerInfo[playerid][pBoxAmmo][8],PlayerInfo[playerid][pBoxAmmo][9],
    PlayerInfo[playerid][pBoxAmmo][10],PlayerInfo[playerid][pSHealth],PlayerInfo[playerid][pHealth],PlayerInfo[playerid][pPos_x],PlayerInfo[playerid][pPos_y],
	PlayerInfo[playerid][pPos_z],PlayerInfo[playerid][pInt],PlayerInfo[playerid][pCard]); // Done

	format(query,sizeof(query),"%s BankPIN=%d,pChequeID=%d,pChequeCode=%d,Local=%d,Team=%d,CarOwner=%d,InteriorEntered=%d,CarOwned=%d,Cheque=%d,",query,
    PlayerInfo[playerid][pPin],PlayerInfo[playerid][pChequeId],PlayerInfo[playerid][pChequeCode],PlayerInfo[playerid][pLocal],
    PlayerInfo[playerid][pTeam],CarOwner[playerid],IntEntered[playerid],Owner[playerid],PlayerInfo[playerid][pCheck]); // Done

	format(query,sizeof(query),"%s ChequeReceived=%d,Savings=%d,CharID=%d,PhoneNr=%d,Complex=%d,House=%d,Joined=%d,ContactNr1=%d,ContactNr2=%d,",query,
	PlayerInfo[playerid][pCheckr],PlayerInfo[playerid][pSavings],PlayerInfo[playerid][pModel],PlayerInfo[playerid][pPnumber],PlayerInfo[playerid][pComplexkey],PlayerInfo[playerid][pHousekey],
	PlayerInfo[playerid][pJoined],PlayerInfo[playerid][pPhoneContact1],PlayerInfo[playerid][pPhoneContact2]); // Done

	format(query,sizeof(query),"%s ContactNr3=%d,ContactNr4=%d,ContactNr5=%d,ContactNr6=%d,ContactNr7=%d,\
	Bizz=%d,MaxContact=%d,MaxContact1=%d,MaxContact2=%d,MaxContact3=%d,MaxContact4=%d,MaxContact5=%d,",query,PlayerInfo[playerid][pPhoneContact3],PlayerInfo[playerid][pPhoneContact4],PlayerInfo[playerid][pPhoneContact5],PlayerInfo[playerid][pPhoneContact6],
	PlayerInfo[playerid][pPhoneContact7],PlayerInfo[playerid][pPbiskey],MaxC[playerid],MaxC2[playerid],MaxC3[playerid],MaxC4[playerid],MaxC5[playerid],MaxC6[playerid]); // Done

	format(query,sizeof(query),"%s MaxContact6=%d,Banned=%d,FightSkill=%d,Sex=%d,Age=%d,Member=%d,Rank=%d,Crashed=%d,Job=%d, \
	HouseEntered=%d,CrashHealth=%f,CrashArmour=%f,World=%d,",query,
	MaxC7[playerid],PlayerInfo[playerid][pBanned],PlayerInfo[playerid][pFightSkill],PlayerInfo[playerid][pSex],PlayerInfo[playerid][pAge],PlayerInfo[playerid][pMember],PlayerInfo[playerid][pRank],PlayerInfo[playerid][pCrashed],PlayerInfo[playerid][pJob],
	HouseEntered[playerid],PlayerInfo[playerid][pCrashHealth],PlayerInfo[playerid][pCrashArmour],PlayerInfo[playerid][pWorld]); // Not Done

	format(query,sizeof(query),"%s PayCheque=%d,PayDay=%d,DonateRank=%d,ConnectTime=%d,DonateTime=%d,Jailed=%d,JailTime=%d,Drugs=%d,Materials=%d,VaultOwned=%d,",query,
	PlayerInfo[playerid][pPayCheck],PlayerInfo[playerid][pPayDay],PlayerInfo[playerid][pDonateRank],PlayerInfo[playerid][pConnectTime],PlayerInfo[playerid][pDonateTime],
	PlayerInfo[playerid][pJailed],PlayerInfo[playerid][pJailTime],PlayerInfo[playerid][pDrugs],PlayerInfo[playerid][pMats],PlayerInfo[playerid][pVaultOwned]); // Done

	format(query,sizeof(query),"%s VaultDrugs=%d,VaultMats=%d,Watch=%d,PhoneBook=%d,PrisonGuard=%d,Prisoner=%d,Mask=%d,CarLic=%d,Car1=%d,Car2=%d,Car3=%d, \
	SocialSecurity=%d,Toolkit=%d,RadioID=%d,Married=%d,WantedLevel=%d, \
	GunLic=%d,Crimes=%d,Arrested=%d,Taunt=%d,Warrant=%d,FactionIdent=%d,LockTime=%d,Origin=%d,Helper=%d,Tutorial=%d,",query,
    PlayerInfo[playerid][pVaultDrugs],PlayerInfo[playerid][pVaultMats],PlayerInfo[playerid][pWatch],PlayerInfo[playerid][pPhoneBook],PlayerInfo[playerid][pGuard],PlayerInfo[playerid][pPrisoner],
    PlayerInfo[playerid][pMask],PlayerInfo[playerid][pDrivLic],PlayerInfo[playerid][pCarkey],PlayerInfo[playerid][pCarkey2],PlayerInfo[playerid][pCarkey3],
	PlayerInfo[playerid][pSocial],PlayerInfo[playerid][pToolkit],PlayerInfo[playerid][pRadioHandle],PlayerInfo[playerid][pMarried],WantedLevel[playerid],
	PlayerInfo[playerid][pGunLic],PlayerInfo[playerid][pCrimes],PlayerInfo[playerid][pArrested],PlayerInfo[playerid][pTaunt],
	PlayerInfo[playerid][pWarrant],PlayerInfo[playerid][pFactionIden],PlayerInfo[playerid][pLockTime],PlayerInfo[playerid][pOrigin],
	PlayerInfo[playerid][pHelpers],PlayerInfo[playerid][pTut]); // Done
	
	//printf("Saved Data 50%");
	
	format(query,sizeof(query),"%s InvWeapon=%d,InvAmmo=%d,InvWeapon2=%d,InvAmmo2=%d,InvWeapon3=%d,InvAmmo3=%d,InvWeapon4=%d,InvAmmo4=%d, \
	InvCash=%d,InvBeer=%d,InvWine=%d,InvCiggy=%d,Hidden=%d,Walkie=%d,WalkieFreq=%d,Cigs=%d,Lighter=%d,PhoneNumber1=%d,",query,
    PlayerInfo[playerid][pInvWeapon],PlayerInfo[playerid][pInvAmmo],PlayerInfo[playerid][pInvWeapon2],PlayerInfo[playerid][pInvAmmo2],PlayerInfo[playerid][pInvWeapon3],
	PlayerInfo[playerid][pInvAmmo3],PlayerInfo[playerid][pInvWeapon4],PlayerInfo[playerid][pInvAmmo4],PlayerInfo[playerid][pInvCash],
    PlayerInfo[playerid][pInvBeer],PlayerInfo[playerid][pInvWine],PlayerInfo[playerid][pInvCiggy],PlayerInfo[playerid][pHidden],
	PlayerInfo[playerid][pWalkie],PlayerInfo[playerid][pWalkieFreq],PlayerInfo[playerid][pCigs],PlayerInfo[playerid][pLighter],
	PlayerInfo[playerid][pPhoneNumber1]);
	
	format(query,sizeof(query),"%s PhoneNumber2=%d,PhoneNumber3=%d,PhoneNumber4=%d,PhoneNumber5=%d,PhoneNumber6=%d,PhoneNumber7=%d, \
	Fishes1=%d,Fishes2=%d,Fishes3=%d,Fishes4=%d,Fishes5=%d,Fishes6=%d,Fishes7=%d,Fishes8=%d,Fishes9=%d,Fishes10=%d,",query,
	PlayerInfo[playerid][pPhoneNumber2],PlayerInfo[playerid][pPhoneNumber3],PlayerInfo[playerid][pPhoneNumber4],PlayerInfo[playerid][pPhoneNumber5],
	PlayerInfo[playerid][pPhoneNumber6],PlayerInfo[playerid][pPhoneNumber7],PlayerInfo[playerid][pFishes1],PlayerInfo[playerid][pFishes2],
	PlayerInfo[playerid][pFishes3],PlayerInfo[playerid][pFishes4],PlayerInfo[playerid][pFishes5],PlayerInfo[playerid][pFishes6],
	PlayerInfo[playerid][pFishes7],PlayerInfo[playerid][pFishes8],PlayerInfo[playerid][pFishes9],PlayerInfo[playerid][pFishes10]);
    
	format(query,sizeof(query),"%s Fishes11=%d,Fishes12=%d,Fishes=%d,Fish1=%d,Fish2=%d,Fish3=%d,Fish4=%d,Fish5=%d, \
	Fish6=%d,Fish7=%d,Fish8=%d,Fish9=%d,Fish10=%d,Fish11=%d,Fish12=%d,JobDelay=%d,MaskUse=%d,Accent=%d,Voted2=%d,\
	HeadValue=%d,HiddenNum=%d,Skate=%d,Radio=%d,Ticket0=%d,Ticket1=%d,Ticket2=%d,Ticket3=%d,Ticket4=%d,",query,
    PlayerInfo[playerid][pFishes11],PlayerInfo[playerid][pFishes12],PlayerInfo[playerid][pFishes],PlayerInfo[playerid][pFish][0],
	PlayerInfo[playerid][pFish][1],PlayerInfo[playerid][pFish][2],PlayerInfo[playerid][pFish][3],PlayerInfo[playerid][pFish][4],
	PlayerInfo[playerid][pFish][5],PlayerInfo[playerid][pFish][6],PlayerInfo[playerid][pFish][7],PlayerInfo[playerid][pFish][8],
	PlayerInfo[playerid][pFish][9],PlayerInfo[playerid][pFish][10],PlayerInfo[playerid][pFish][11],
	JobDelay[playerid],PlayerInfo[playerid][pMaskUse],PlayerInfo[playerid][pAccent],PlayerInfo[playerid][pVoted],
	PlayerInfo[playerid][pHeadValue],PlayerInfo[playerid][pHiddenNum],PlayerInfo[playerid][pSkate],PlayerInfo[playerid][pRadio],
	PlayerInfo[playerid][pTicket][0],PlayerInfo[playerid][pTicket][1],PlayerInfo[playerid][pTicket][2],PlayerInfo[playerid][pTicket][3],
	PlayerInfo[playerid][pTicket][4]);

	/*format(query,sizeof(query),"%s MarriedTo=%s,WarrantReason=%s,DonateCarDate=%s,LogoutTime=%s,BanReason=%s, \
	Note1s=%s,Note2s=%s,Note3s=%s,Note4s=%s,Note5s=%s,Note1=%s,Note2=%s,Note3=%s,Note4=%s,Note5=%s, \
	TicketReason0=%s,TicketReason1=%s,TicketReason2=%s,TicketReason3=%s,TicketReason4=%s",query,
    PlayerInfo[playerid][pMarriedTo],PlayerInfo[playerid][pWarrantReason],PlayerInfo[playerid][pDonatorCarDate],
	PlayerInfo[playerid][pLogOutTime],PlayerInfo[playerid][pBanReason],PlayerInfo[playerid][pNote1s],
	PlayerInfo[playerid][pNote2s],PlayerInfo[playerid][pNote3s],PlayerInfo[playerid][pNote4s],PlayerInfo[playerid][pNote5s],
    PlayerInfo[playerid][pNote1],PlayerInfo[playerid][pNote2],PlayerInfo[playerid][pNote3],PlayerInfo[playerid][pNote4],PlayerInfo[playerid][pNote5],
	PlayerInfo[playerid][pTicketReason0],PlayerInfo[playerid][pTicketReason1],PlayerInfo[playerid][pTicketReason2],
	PlayerInfo[playerid][pTicketReason3],PlayerInfo[playerid][pTicketReason4]); // Not done*/
	/*AdmName=%s,PlayerInfo[playerid][pAdmName],
	email=%s,PlayerInfo[playerid][email],*/
	
	format(query,sizeof(query),"%s App=%d,Changes=%d,FamNum=%d,Tattoo=%d,Cellphone=%d,Celltime=%d,Cellplan=%d, \
	DonerGate1=%d,BreakAllow=%d,FurnLocked=%d, \
	Month=%d,Day=%d,Min=%d,Hour=%d, DisabledChat=%d WHERE Username = '%s'",query,
    PlayerInfo[playerid][pApp],PlayerInfo[playerid][pChanges],PlayerInfo[playerid][pFamNum],
	PlayerInfo[playerid][pTattoo],PlayerInfo[playerid][pCellphone],PlayerInfo[playerid][pCelltime],
	PlayerInfo[playerid][pCellplan],PlayerInfo[playerid][pDonerGate1],BreakAllow[playerid],
	PlayerInfo[playerid][pFurnLocked],PlayerInfo[playerid][pMonth],PlayerInfo[playerid][pDay],PlayerInfo[playerid][pMin],
	PlayerInfo[playerid][pHour], PlayerInfo[playerid][pDisabledChat], Name);

	mysql_query(query);
	}
	//printf("Saved Data 100%");
	//return 1;
}
This is how it saves.
Reply
#3

,,,,,
Reply
#4

mmmmmm
Reply
#5

I vote this gets locked and the user gets a temp ban

Unable to wait for someone to reply and then spamming with garbage to bump it to the top is NOT the sign of a good sa-mp scripter!
Reply
#6

HOLY CRAP.
Reply
#7

Quote:
Originally Posted by iToast
Посмотреть сообщение
I vote this gets locked and the user gets a temp ban

Unable to wait for someone to reply and then spamming with garbage to bump it to the top is NOT the sign of a good sa-mp scripter!
There is no such thing as voting to get something, also it doesnt mean I am a good scripter am I now? so you can fuck off from my topic, I can bump if I want, but wait, I guess its a bad idea to come to SA-MP forums for help, as no one can help me when I need help but when someone needs help I help them. fucking pointless..

@Stewie, Yes, holy crap
Reply
#8

Your playerInfo is saved server side. There is no issue when a player crashes, the playerinfo is still on your server.
Stop bumping, look in your GM where you modify your playerInfo/reset your playerinfo to its default values and make sure that happens AFTER you send it to the database. Also use the OnMysqlError() callback-thingy to ensure there aren't any mysql errors which ends up in unsaved data.
Reply
#9

Am using R5 <- Not r7, so is there any other way of finding the problem? and also I've actually check on /q everything is saving, but on crash the player comes back with their old stats (if they did have any before crashing).
Reply
#10

Check if it actually gets called when they crash perhaps using prints, check if the variables are right by printing them out, as ikkentim (nice name) said they do not automatically get wiped so it must be something in your script. I also suggest you update to R7.

And on a side note, no you cannot decide when to bump, theres a 48h rule, just stick with it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)