Jump to content

help with triggering script


Extinction

Recommended Posts

CLIENT SIDE

------------------------

--- Create Character ---

submitCreate = guiCreateButton(0.38, 0.57, 0.30, 0.05, "Create Character", true)
lblCharName = guiCreateLabel(0.47, 0.33, 0.08, 0.04, "Charactername", true)
charHeight = guiCreateLabel(0.47, 0.40, 0.08, 0.04, "Height: 150 CM", true)
charWeight = guiCreateLabel(0.56, 0.40, 0.08, 0.04, "Weight: 50 KG", true)
charGender = guiCreateLabel(0.47, 0.47, 0.04, 0.02, "Gender:", true)
charMale = guiCreateCheckBox(0.47, 0.49, 0.04, 0.02, "Male", false, true)
charFemale = guiCreateCheckBox(0.52, 0.49, 0.05, 0.02, "Female", false, true)
charEdit = guiCreateEdit(0.47, 0.36, 0.15, 0.03, "", true)

skinGrid = guiCreateGridList(0.38, 0.33, 0.08, 0.18, true)
guiGridListAddColumn(skinGrid, "Skins", 0.9)
  for i = 1, 3 do
     guiGridListAddRow(skinGrid)
  end
guiGridListSetItemText(skinGrid, 0, 1, "1", false, false)
guiGridListSetItemText(skinGrid, 1, 1, "2", false, false)
guiGridListSetItemText(skinGrid, 2, 1, "3", false, false)

heightScroll = guiCreateScrollBar(0.47, 0.43, 0.07, 0.02, true, true)
weigthScroll = guiCreateScrollBar(0.56, 0.43, 0.07, 0.02, true, true)    

guiSetVisible(skinGrid,false)
guiSetVisible(submitCreate,false)
guiSetVisible(lblCharName,false)
guiSetVisible(charHeight,false)
guiSetVisible(charWeight,false)
guiSetVisible(charGender,false)
guiSetVisible(charMale,false)
guiSetVisible(charFemale,false)
guiSetVisible(charEdit,false)
guiSetVisible(heightScroll,false)
guiSetVisible(weigthScroll,false)

------------------------

function createCharacterFunction()
if source == submitCreate then
  local charname = guiGetText(charEdit)
if guiCheckBoxGetSelected (charMale) then
  local gender = "male"
elseif guiCheckBoxGetSelected (charFemale) then
  local gender = "female"
local skin = guiGridListGetItemText ( skinGrid , guiGridListGetSelectedItem ( skinGrid  ), 1 )
end
  end
  triggerServerEvent("createCharacter", source, charname, gender, skin)
end
addEventHandler("onClientGUIClick", root, createCharacterFunction)

 

SERVER SIDE


function createCharacter(charname, gender, skin)
if charname and gender and skin then
local query = dbQuery(db, "INSERT INTO characters (name, gender, skin, account) VALUES(?, ?, ?, ?)", charname, gender, skin, getPlayerUsername(client))
if query then 
outputDebugString("Updates characters.")
else
outputDebugString("Updating charactes failed.")
  end
end
end
addEvent("createCharacter", true)
addEventHandler("createCharacter", root, createCharacter)

 

Nothing is outputted in debug when I click the button createCharacter, nothing in debug, no error

Link to comment
------------------------

--- Create Character ---

submitCreate = guiCreateButton(0.38, 0.57, 0.30, 0.05, "Create Character", true)
lblCharName = guiCreateLabel(0.47, 0.33, 0.08, 0.04, "Charactername", true)
charHeight = guiCreateLabel(0.47, 0.40, 0.08, 0.04, "Height: 150 CM", true)
charWeight = guiCreateLabel(0.56, 0.40, 0.08, 0.04, "Weight: 50 KG", true)
charGender = guiCreateLabel(0.47, 0.47, 0.04, 0.02, "Gender:", true)
charMale = guiCreateCheckBox(0.47, 0.49, 0.04, 0.02, "Male", false, true)
charFemale = guiCreateCheckBox(0.52, 0.49, 0.05, 0.02, "Female", false, true)
charEdit = guiCreateEdit(0.47, 0.36, 0.15, 0.03, "", true)

skinGrid = guiCreateGridList(0.38, 0.33, 0.08, 0.18, true)
guiGridListAddColumn(skinGrid, "Skins", 0.9)
  for i = 1, 3 do
     guiGridListAddRow(skinGrid)
  end
guiGridListSetItemText(skinGrid, 0, 1, "1", false, false)
guiGridListSetItemText(skinGrid, 1, 1, "2", false, false)
guiGridListSetItemText(skinGrid, 2, 1, "3", false, false)

heightScroll = guiCreateScrollBar(0.47, 0.43, 0.07, 0.02, true, true)
weigthScroll = guiCreateScrollBar(0.56, 0.43, 0.07, 0.02, true, true)    

guiSetVisible(skinGrid,false)
guiSetVisible(submitCreate,false)
guiSetVisible(lblCharName,false)
guiSetVisible(charHeight,false)
guiSetVisible(charWeight,false)
guiSetVisible(charGender,false)
guiSetVisible(charMale,false)
guiSetVisible(charFemale,false)
guiSetVisible(charEdit,false)
guiSetVisible(heightScroll,false)
guiSetVisible(weigthScroll,false)

------------------------

function createCharacterFunction()
	if source == submitCreate then
		local charname = guiGetText(charEdit)
		if guiCheckBoxGetSelected (charMale) then
  			local gender = "male"
  			local skin = guiGridListGetItemText ( skinGrid , guiGridListGetSelectedItem ( skinGrid  ), 1 )
  			triggerServerEvent("createCharacter", source, charname, gender, skin)
		elseif guiCheckBoxGetSelected (charFemale) then
  			local gender = "female"
			local skin = guiGridListGetItemText ( skinGrid , guiGridListGetSelectedItem ( skinGrid  ), 1 )
			triggerServerEvent("createCharacter", source, charname, gender, skin)
		end
  	end
  
end
addEventHandler("onClientGUIClick", root, createCharacterFunction)

 

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