Jump to content

Problems


Recommended Posts

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

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

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

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