Jump to content

Element Data Setting


Karuzo

Recommended Posts

    function onQuit () 
        local data = getElementData(source,"LoggedIN") 
        outputDebugString ( tostring ( data ) ) 
        if ( data ) then 
            local money = getPlayerMoney ( source ) 
            local skin = getPedSkin ( source ) 
            local health = getElementHealth ( source ) 
            local int,dim = getElementInterior ( source ), getElementDimension ( source ) 
            local x,y,z = getElementPosition (source) 
            local inserting = dbExec ( connect, "INSERT INTO accounts ( money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,? )", money, skin, healt, x, y, z, int, dim ) 
            if inserting then 
                outputDebugString("Inserting successfull") 
            else 
                outputDebugString("Inserting failed.") 
            end 
        end 
    end 
    addEventHandler ("onPlayerQuit", root, onQuit) 

Check this out.

Link to comment
  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

WTF.

Now it outputted in the debug, INSERT SUCCESSFULL.

So i think you solved the problem WhoAmI :P

Thank you for that.

Another Question.

I have to specify a player , where he should insert the datas , right ?

Can i make it like this : INSER INTO accounts (.....) VALUES(.....) WHERE (username) ?

Link to comment

Last Question,

how should i get the username ?

I know with triggering but can i trigger to a function where an event is already handled?

Like

  
triggerServerEvent("OnQuitPlayer", getLocalPlayer(),username) 

?

And than in Serverside:

  
        addEvent("OnQuitPlayer", true) 
        addEventHandler("OnQuitPlayer", root, onQuit) 

?

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