Jump to content

Element Data Setting


Karuzo

Recommended Posts

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

  • Replies 77
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted

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) ?

Posted

Oh, so

dbExec ( connect, "INSERT INTO accounts ( username, money,skin,health,x,y,z,int,dim ) VALUES (?,?,?,?,?,?,?,?,? )", username, money, skin, healt, x, y, z, int, dim ) 

Posted

Nah,

i mean lets say i have a guy who is registered and has now a Column with username and password.

And i want to insert those datas into this specific player.

How could i do that ?

Posted

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) 

?

Posted

Well, I dont really know what you mean. You want get username from what? From database? You can get it in login function and saves into element data.

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