Baseplate Posted June 14, 2013 Share Posted June 14, 2013 I'm trying to make a medic job, however I got stuck within this, for the event and the takeButton they are already defined but I don't want to put my script here. WARNING: [CPG]emergency\medic_client.lua:105: Bad arguement @ 'addEventHandler' [Expected element at arguement 2, got nil] addEventHandler("onClientGUIClick", takeButton, function() if (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin1) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs274", localPlayer) triggerEvent("closeMedicWindow", root) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) elseif (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin2) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs275", localPlayer) triggerEvent("closeMedicWindow", root) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) elseif (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin3) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs276", localPlayer) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) triggerEvent("closeMedicWindow", root) elseif source == takeButton and getElementData(localPlayer, "Occupation") == "Paramedic" then exports.DxChat:sayClientMessage("Your job is already paramedic!", 255, 0, 0) end end ) Link to comment
denny199 Posted June 14, 2013 Share Posted June 14, 2013 How are you making your GUI on onClientResourceStart, or without, or does it create when a player hits the col/marker? Link to comment
Baseplate Posted June 14, 2013 Author Share Posted June 14, 2013 but I don't want to put my script here. I can give you the full script on private. Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 addEventHandler("onClientGUIClick",getRootElement ( ), function ( ) if source == takeButton then if (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin1) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs274", localPlayer) triggerEvent("closeMedicWindow", root) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) elseif (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin2) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs275", localPlayer) triggerEvent("closeMedicWindow", root) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) elseif (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin3) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs276", localPlayer) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) triggerEvent("closeMedicWindow", root) elseif source == takeButton and getElementData(localPlayer, "Occupation") == "Paramedic" then exports.DxChat:sayClientMessage("Your job is already paramedic!", 255, 0, 0) end end end ) Try this maybe because the button created with on start event. Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 impossible can you post the gui function without arguments . Link to comment
Baseplate Posted June 14, 2013 Author Share Posted June 14, 2013 function createJobGui() if not isElement ( MainWnd ) then MainWnd = guiCreateWindow guiSetVisible centerWindow guiWindowSetMovable guiWindowSetSizable closeButton = guiCreateButton guiSetFont takeButton = guiCreateButton guiSetFont GUIEditor.memo[1] = guiCreateMemo guiMemoSetReadOnly GUIEditor.gridlist[1] = guiCreateGridList column = guiGridListAddColumn skin1 = guiGridListAddRow skin2 = guiGridListAddRow skin3 = guiGridListAddRow guiGridListSetItemText guiGridListSetItemText guiGridListSetItemText end showCursor end Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 OK Add the event when you handle ( createJobGui ) Function . And re-name the function. Link to comment
Baseplate Posted June 14, 2013 Author Share Posted June 14, 2013 Still, same problems, Closing the window works, but the accept button doesn't. Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 Hmm..What's the error now? It's impossible to be the event . Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 Not sure if it'll works but i hope that : addEventHandler("onClientGUIClick", takeButton, function ( ) if getElementData(localPlayer, "Occupation") == "Paramedic" then exports.DxChat:sayClientMessage("Your job is already paramedic!", 255, 0, 0) return end if (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin1) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs274", localPlayer) triggerEvent("closeMedicWindow", root) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) elseif (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin2) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs275", localPlayer) triggerEvent("closeMedicWindow", root) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) elseif (guiGridListGetSelectedItem(GUIEditor.gridlist[1]) == skin3) and not getElementData(localPlayer, "Occupation") == "Paramedic" then triggerServerEvent("takeJobAs276", localPlayer) exports.DxChat:sayClientMessage("You're now employed as paramedic!", 0, 255, 0) triggerEvent("closeMedicWindow", root) end end,false ) Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 Lol sorry abxf i don't have any idea about that. Leave it for other's sorry. Link to comment
iPrestege Posted June 14, 2013 Share Posted June 14, 2013 Just noticed about it now you can't get selected item as a text . Use : guiGridListGetItemText And change the skin1 to the text from the grid i would recommend you to use table's more easier for you . Link to comment
Baseplate Posted June 14, 2013 Author Share Posted June 14, 2013 It shouldn't make any difference. Link to comment
PaiN^ Posted June 14, 2013 Share Posted June 14, 2013 Try this : addEventHandler( "onClientGUIClick", root, function( ) if source == takeButton then if getElementData( localPlayer, "Occupation" ) == "Paramedic" then exports.DxChat:sayClientMessage( "Your job is already paramedic!", 255, 0, 0 ) return end local row = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) if row and row ~= -1 then if row == skin1 and not getElementData( localPlayer, "Occupation" ) == "Paramedic" then triggerServerEvent( "takeJobAs274", localPlayer ) triggerEvent( "closeMedicWindow", root ) exports.DxChat:sayClientMessage( "You're now employed as paramedic!", 0, 255, 0 ) elseif row == skin2 and not getElementData( localPlayer, "Occupation" ) == "Paramedic" then triggerServerEvent( "takeJobAs275", localPlayer ) triggerEvent( "closeMedicWindow", root ) exports.DxChat:sayClientMessage( "You're now employed as paramedic!", 0, 255, 0 ) elseif row == skin3 and not getElementData( localPlayer, "Occupation" ) == "Paramedic" then triggerServerEvent( "takeJobAs276", localPlayer ) exports.DxChat:sayClientMessage( "You're now employed as paramedic!", 0, 255, 0 ) triggerEvent( "closeMedicWindow", root ) end end end end ) Link to comment
PaiN^ Posted June 14, 2013 Share Posted June 14, 2013 Debug errors ? If not, Post/PM the hole code . Link to comment
Baseplate Posted June 14, 2013 Author Share Posted June 14, 2013 Problem fixed, a check was needed. 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