Extinction Posted March 26, 2017 Share Posted March 26, 2017 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
_DrXenon Posted March 26, 2017 Share Posted March 26, 2017 I think that the triggerServerEvent should be inside (within the range) of the if statement and not beneath it since you are sending vars that were only idenitfied within the If statement. Link to comment
Extinction Posted March 26, 2017 Author Share Posted March 26, 2017 Still doesnt make a difference, i tried this Link to comment
_DrXenon Posted March 26, 2017 Share Posted March 26, 2017 Umm, then maybe the second argument on triggerServerEvent is 'source' which refers to the button not the player? Link to comment
Anubhav Posted March 27, 2017 Share Posted March 27, 2017 ------------------------ --- 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
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Do you load the server sided script first in your meta.xml? Link to comment
Anubhav Posted March 27, 2017 Share Posted March 27, 2017 server sided scripts load first no matter what, its because they are on server, and server starts, and client joins and then the client sided are downloaded and read by the MTA client. so it doesnt matter if you put server type script first or not Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Nvm, it's one client sided, and one server sided script. Didnt check if it was or not. Try triggering without any args. Or maybe check debugscript? Link to comment
pa3ck Posted March 27, 2017 Share Posted March 27, 2017 You're triggering for source, change it to localPlayer Link to comment
Extinction Posted March 27, 2017 Author Share Posted March 27, 2017 (edited) @Anubhav Source won't work in client sided script? Edited March 27, 2017 by Extinction Link to comment
Anubhav Posted March 27, 2017 Share Posted March 27, 2017 Lol, source in that event is actually the button clicked. I'm suprised I forgot to fix that or did not even see it e.e localPlayer should be used (the player who clicked it). Link to comment
_DrXenon Posted March 27, 2017 Share Posted March 27, 2017 9 hours ago, SuperCroz said: Umm, then maybe the second argument on triggerServerEvent is 'source' which refers to the button not the player? . Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now