Raised This Month: $32 Target: $400
 8% 

[ H3LP ] Load data failure


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-22-2018 , 13:13   [ H3LP ] Load data failure
Reply With Quote #1

Hello, I made a simple money save/load system with SQL by player authid, but sometimes doesn't load the player money when he join in server. I'm using the following code.

Spoiler


Spoiler


Spoiler
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 06-22-2018 , 14:49   Re: [ H3LP ] SQLx load data
Reply With Quote #2

Don't use LIKE Unless you want Check if the string contain something use = operator

auth='%s'

Im still not sure why it some times doesnt get the player ammop, btw why are you using so much delay(set_task)

Use semicolon in end of each sql statement.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 06-22-2018 at 14:52.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-22-2018 , 15:04   Re: [ H3LP ] SQLx load data
Reply With Quote #3

I did some tests in phpMyAdmin and looks like doesn't matter, be with LIKE, be with = operator, with semicolon or without, but thanks anyway for the suggestion.

I will test with vault and see if the problem still is occurring.
__________________








CrazY. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-23-2018 , 09:46   Re: [ H3LP ] SQLx load data
Reply With Quote #4

I tried with vault but players still lose ammop sometimes. Any idea?
__________________








CrazY. is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 06-23-2018 , 09:53   Re: [ H3LP ] SQLx load data
Reply With Quote #5

Check if you aren't overwriting a current value with a null one somewhere along the way. It's not an sql/vault related issue if it happens with both.
__________________
stuff
maqi is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-23-2018 , 11:24   Re: [ H3LP ] SQLx load data
Reply With Quote #6

I have the below observations, let me know if I am not understanding the flow correctly. You did not post your full plugin so I am making assumptions based on what you posted.

1. You attempt to retrieve the data from the db and if no rows are returned you write a row for the player.
2. Data for a player does not get updated on each disconnect since you are only inserting if the player had no data saved which will only happen on his first time on the server.

You should be using INSERT only if it's the players first time on the server, from then on you should be using UPDATE. You can use REPLACE INTO if you set auth as primary key which will overwrite the same row each time.
Code:
CREATE TABLE IF NOT EXISTS player (auth varchar(32) PRIMARY KEY, ammop int(11));

REPLACE INTO player (auth, ammop) VALUES ('STEAM_0:0:12345',77);
Not thoroughly tested
Spoiler
__________________

Last edited by Bugsy; 06-23-2018 at 15:03.
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 06-24-2018 , 16:47   Re: [ H3LP ] SQLx load data
Reply With Quote #7

I tried with this simple code, but players still lose APs.
@Bugsy, thanks for the suggestion but my client doesn't want database anymore.

Spoiler
__________________









Last edited by CrazY.; 06-24-2018 at 19:31.
CrazY. is offline
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

Forum Jump


All times are GMT -4. The time now is 22:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode