Jump to content

REG. New field


Recommended Posts

  • Scripting Moderators
25 minutes ago, slapz0r said:

I use standard internal.db

When a player registers, how to add a new field to the database? a new field there with the name TEST and have the properties of true and false

 

Maybe?

https://wiki.multitheftauto.com/wiki/SetAccountData

 

Link to comment

Can you write an example?

I have a window with Edit and button

I will write in edit(example: Hello) and in the file internal.db will be create a new field(field name = test) for player(who enters the text in edit)

I mean, when a player enters the text in edit and press button then field will be create.

--client

DGS = exports.dgs

function initGUI( )
	showCursor(true)
    btnOutput = DGS:dgsCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )
    addEventHandler ( "onDgsMouseClick", btnOutput, outputEditBox )
    editBox = DGS:dgsCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )
end
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), initGUI )


function outputEditBox ( button, state )
    if button == "left" and state == "down" then
	
    end
end

Can you help me?

Link to comment
  • Scripting Moderators
11 minutes ago, slapz0r said:

Can you write an example?

I have a window with Edit and button

I will write in edit(example: Hello) and in the file internal.db will be create a new field(field name = test) for player(who enters the text in edit)

I mean, when a player enters the text in edit and press button then field will be create.


--client

DGS = exports.dgs

function initGUI( )
	showCursor(true)
    btnOutput = DGS:dgsCreateButton( 0.7, 0.1, 0.2, 0.1, "Output!", true )
    addEventHandler ( "onDgsMouseClick", btnOutput, outputEditBox )
    editBox = DGS:dgsCreateEdit( 0.3, 0.1, 0.4, 0.1, "Type your message here!", true )
end
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), initGUI )


function outputEditBox ( button, state )
    if button == "left" and state == "down" then
	
    end
end

Can you help me?

You need to use triggerServerEvent. Check my example for it here:

 

  • Like 1
Link to comment
9 minutes ago, majqq said:

You need to use triggerServerEvent. Check my example for it here:

 

Thanks for the reply, but

I understand what I need to use "triggerServerEvent" but I need an example that I asked.

Because I'm still too no experience. Just learning and your example in another topic I can not understand now.

 

 

Link to comment
  • Scripting Moderators
41 minutes ago, slapz0r said:

Thanks for the reply, but

I understand what I need to use "triggerServerEvent" but I need an example that I asked.

Because I'm still too no experience. Just learning and your example in another topic I can not understand now.

 

 

I'm not good at explaining but let me try.

-- client

local variable = "Test"
triggerServerEvent("sendDataToServer", getLocalPlayer(), variable)

-- server

function sendDataToServer_handler(first_arg)
	local player = source
	local account = getPlayerAccount(player)
	if account then
		setAccountData(account, first_arg, true)
		outputChatBox(tostring(getAccountData(account, first_arg)))
	end
end
addEvent("sendDataToServer", true)
addEventHandler("sendDataToServer", getRootElement(), sendDataToServer_handler)

Adjust it to your needs.

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