AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [ H3LP ] Load data failure (https://forums.alliedmods.net/showthread.php?t=308501)

CrazY. 06-22-2018 13:13

[ H3LP ] Load data failure
 
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

Natsheh 06-22-2018 14:49

Re: [ H3LP ] SQLx load data
 
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.

CrazY. 06-22-2018 15:04

Re: [ H3LP ] SQLx load data
 
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. 06-23-2018 09:46

Re: [ H3LP ] SQLx load data
 
I tried with vault but players still lose ammop sometimes. Any idea?

maqi 06-23-2018 09:53

Re: [ H3LP ] SQLx load data
 
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.

Bugsy 06-23-2018 11:24

Re: [ H3LP ] SQLx load data
 
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

CrazY. 06-24-2018 16:47

Re: [ H3LP ] SQLx load data
 
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


All times are GMT -4. The time now is 12:39.

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