Jump to content

mysql save and load


Qfury

Recommended Posts

hi i need help^^

i use this script to generate points for Players in a DM race. now i want to save the collectet points in a mysql database but i dont know how. can you help me please?

Pointscript:

addEvent("onPlayerWasted") 
function player_Wasted() 
    for i,v in ipairs(getElementsByType('player')) do 
        local rank = exports.race:getPlayerRank(player) 
        if(rank == 2) then 
            givePlayerMoney(v, 1500) 
            outputChatBox('Rank 2:' .. getPlayerName(v).. '') 
        end 
        if(rank == 1) then 
            givePlayerMoney(v, 1500) 
            outputChatBox('Rank 1:' .. getPlayerName(v).. '') 
        end 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), player_Wasted) 
  
function playerCount ( ) 
    local dead = getPlayerCount() 
        if (dead == 1) then 
            outputChatBox('1st dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+1) 
        end 
        if (dead == 2) then 
            outputChatBox('2nd dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+1) 
        end 
        if (dead == 3) then 
            outputChatBox('3rd dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+2) 
        end 
        if (dead == 4) then 
            outputChatBox('4th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+3) 
        end 
        if (dead == 5) then 
            outputChatBox('5th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+4) 
        end 
        if (dead == 6) then 
            outputChatBox('6th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+5) 
        end 
        if (dead == 7) then 
            outputChatBox('7th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+6) 
        end 
        if (dead == -- s8) --> then 
            outputChatBox('8th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+7) 
        end 
        if (dead == 9) then 
            outputChatBox('9th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+8) 
        end 
        if (dead == 10) then 
            outputChatBox('10th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+9) 
        end 
        if (dead == 11) then 
            outputChatBox('11th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+10) 
        end 
        if (dead == 12) then 
            outputChatBox('12th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+11) 
        end 
        if (dead == 13) then 
            outputChatBox('13th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+12) 
        end 
        if (dead == 14) then 
            outputChatBox('14th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+13) 
        end 
        if (dead == 15) then 
            outputChatBox('15th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+14) 
        end 
        if (dead == 16) then 
            outputChatBox('16th dead') 
            setElementData(source,"Points",tonumber(getElementData(source,"Points"))+15) 
        end 
end 
addEventHandler("onPlayerWasted", getRootElement(), playerCount) 
  
addEventHandler("onPlayerQuit", getRootElement(), 
  function() 
    local playeraccount = getPlayerAccount(source) 
    if playeraccount then 
      local Points = getElementData(source, "Points")    
      if Points then setAccountData(playeraccount, "Points", Points) end 
    end 
  end   
) 
  
  
addEventHandler("onPlayerLogin", getRootElement(), 
  function() 
    local playeraccount = getPlayerAccount(source) 
    if playeraccount then 
      local Points = getAccountData(playeraccount, "Points") 
      if Points then setElementData(source, "Points", Points) end   
    end 
  end   
) 
  

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...