Jump to content

SQL


Blinker.

Recommended Posts

Hello folks ,

i've made a stats panel for dd , i've got a problem , sometimes all the people get the same stats , i mean if i had 6,000 $ and someone joined then he played for 5 mins he got 300 $ , after some secs he will have same stats as me.

also sometimes when someone joins , his stats doesn't save it needs time to appear again .. it shows 0 at first then after he wins his real stats will appear again.

that's what i am using:

  
function insertInDatabase(serial , ban ,kick ,joins ,mute ,nick ,mesg ,maps ,ratio ,wins ,kills ,deaths ,kpm ,points ,money) 
if serial and ban and kick and joins and mute and nick and mesg and maps and ratio and wins and kills and deaths and kpm and points and money then 
  
  local select = executeSQLQuery("SELECT * FROM up_stats WHERE serial=?", serial) 
        if #select == 0 then 
            executeSQLQuery("INSERT INTO up_stats (serial , ban ,kick ,joins ,mute ,nick ,mesg ,maps ,ratio ,wins ,kills ,deaths ,kpm ,points ,money) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",serial , ban ,kick ,joins ,mute ,nick ,mesg ,maps ,ratio ,wins ,kills ,deaths ,kpm ,points ,money) 
            --          outputChatBox("[iNSERT] Serial: "..serial) 
            return true 
        else 
        --          outputChatBox("[uPDATE] Serial: "..serial) 
            executeSQLQuery("UPDATE up_stats SET  ban=? ,kick=? ,joins=? ,mute=? ,nick=? ,mesg=? ,maps=? ,ratio=? ,wins=? ,kills=? ,deaths=? ,kpm=? ,points=? ,money=? WHERE serial=?",  ban ,kick ,joins ,mute ,nick ,mesg ,maps ,ratio ,wins ,kills ,deaths ,kpm ,points ,money, serial) 
  
        end 
        end 
  
  
end 
  
  

and when a player wins i am using this

  
local select = executeSQLQuery("SELECT * FROM up_stats WHERE serial=?", serial) 
if #select == 0 then 
   insertInDatabase(serial , 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0,0 ,experience ,amount) 
   else 
 insertInDatabase(serial , select[1].ban  ,select[1].kick ,select[1].joins ,select[1].mute ,select[1].nick ,select[1].mesg ,select[1].maps ,select[1].ratio ,select[1].wins +1,select[1].kills ,select[1].deaths ,select[1].kpm ,select[1].points + experience ,select[1].money +amount) 
end 
  
  

any help would be greatly appreciated.

Thanks.

EDIT: nvm i fixed it , i had something wrong.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...