Raised This Month: $ Target: $400
 0% 

MySQL problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 08-11-2014 , 18:31   MySQL problem
Reply With Quote #1

Hi!

In my server, I have a Point System in Mysql, everything works fine but sometimes a new player join the server and gets the same points as the top player who have more points.

Can someone tell me if this is a problem in mysql or in my plugin?
__________________
skz is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 08-11-2014 , 18:33   Re: MySQL problem
Reply With Quote #2

How are you saving players points, by Name, IP, or SteamID?
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 08-11-2014 , 18:43   Re: MySQL problem
Reply With Quote #3

SteamID
__________________
skz is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-11-2014 , 19:02   Re: MySQL problem
Reply With Quote #4

What point system? This is way too little information. It sounds like you forget to reset something on connect/disconnect but we can't help you like this.
__________________
In Flames we trust!
Nextra is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 08-11-2014 , 19:47   Re: MySQL problem
Reply With Quote #5

It's a point system that I created...

PHP Code:
public client_putinserver(id)
{
    
Load_MySql(id)
    
points_in_name(id
    
set_task(5.0"PontosHud"id__"b")
}

public 
client_disconnect(id)
{
    
Save_MySql(id)

__________________

Last edited by skz; 08-11-2014 at 19:47.
skz is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-11-2014 , 19:49   Re: MySQL problem
Reply With Quote #6

That is an awfully short plugin you have there. I'm impressed if that does anything at all.
__________________
In Flames we trust!
Nextra is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 08-11-2014 , 20:47   Re: MySQL problem
Reply With Quote #7

Lol man, I just posted the connect and disconnect functions, as you wanted...
__________________
skz is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-11-2014 , 20:57   Re: MySQL problem
Reply With Quote #8

Quote:
Originally Posted by skz View Post
Lol man, I just posted the connect and disconnect functions, as you wanted...
No you didn't. You are missing the Load_MySql, points_in_name, PontosHud and Save_MySql functions
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 08-11-2014 , 21:27   Re: MySQL problem
Reply With Quote #9

PHP Code:
public Load_MySql(id)
{
    new 
szSteamId[32], szTemp[512]
    
get_user_authid(idszSteamIdcharsmax(szSteamId))
    
    new 
Data[1]
    
Data[0] = id
    
    format
(szTemp,charsmax(szTemp),"SELECT * FROM `pontos` WHERE (`pontos`.`steamid` = '%s')"szSteamId)
    
SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
}
public 
Save_MySql(id)
{
    new 
szSteamId[32], szTemp[512]
    
get_user_authid(idszSteamIdcharsmax(szSteamId))
    
    
format(szTemp,charsmax(szTemp),"UPDATE `pontos` SET `exp` = '%i' WHERE `pontos`.`steamid` = '%s';"iJBPacks[id], szSteamId)
    
SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
}
stock points_in_name(id)

    new 
szName[32
    
get_user_name(idszNamecharsmax(szName)) 
    new 
iLen strlen(szName
     
    new 
iPos iLen 
    
if( szName[iPos] == ']' 
    { 
        for( new 
16i++) 
        { 
            if( 
szName[iPos i] == '[' 
            { 
                
iLen iPos 
                szName
[iLen] = '^0' 
                
break 
            } 
        } 
    } 
    
    
format(szName[iLen], charsmax(szName) - iLenszName[iLen-1] == ' ' "[%d]" " [%d]"iJBPacks[id]) 
    
set_user_info(id"name"szName

public 
PontosHud(id)
{
    
set_hudmessage(6464640.750.8206.02.5)
    
show_hudmessage(id,"Pontos: %i"iJBPacks[id])

__________________
skz is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 08-11-2014 , 22:31   Re: MySQL problem
Reply With Quote #10

While this is still missing code pieces (register_client) we have somewhere to start.
  • Use the client_authorized forward instead of client_putinserver. You are not guaranteed to have the SteamID available when client_putinserver fires
  • Related to the above you're not actually verifying you have a valid steamid on your hands.
  • You're using threaded queries but you're doing nothing to prevent data races. You need to ensure that you can't have two setup processes running for the same client id.
__________________
In Flames we trust!
Nextra 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 13:17.


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