Jump to content

Problems to save the player data (phpMyAdmin)


Cronoss

Recommended Posts

I saw tutorials how to use a database for players, so I tried to save the player's character (Not only the account, I want to create a RP server) and this is what I see in PhpMyAdmin -> click

This is the code i'm trying to make it work:

function datosAgregar(thePlayer, nombre, sexo, edadPJ2)
	local addCharacter = exports.mysql:_Exec("insert into characters (name, gender, age) values (?,?,?)", nombre, sexo, edadPJ2)
	if (addCharacter) then
		iprint(" data saved ")
	else
		iprint(" error ")
	end
end
addEvent("datosAgregar", true)
addEventHandler("datosAgregar", getRootElement(), datosAgregar)

And the console prints me "data saved" with no error...

This is the code that calls the event:

		addEventHandler("onClientGUIClick", btnContinuar, function()
		local nombre = guiGetText(name)
		local sexo = guiRadioButtonGetSelected(gender)
		local edadPJ = guiComboBoxGetSelected(edades)
        local edadPJ2 = guiComboBoxGetItemText(edades, edadPJ)
            if (edadPJ2=="") then
                outputChatBox("---", 255, 0, 0)
            else
                triggerServerEvent("datosAgregar", getLocalPlayer(), getLocalPlayer(), nombre, sexo, edadPJ2)
                guiSetVisible(ventanaPanelPJ, false)
            end
		end, false)

What I'm doing wrong?

 

Also, here is the parameters I'm using for the table in PhpMyAdmin: click me

Edited by Cronoss
Link to comment

Uptade: I solved it by my own, but now I want to transfer the information from a table to another one, how could it be possible? I know i have to use dbquery but I can't figore out how to call the data from one side to the other side...

(I want to save the account registered name as the owner of the character)

 

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