Jump to content

Where i place onClientClicked event (ped)?


FeatCode

Recommended Posts

Hey i want to ask where do i place the onClientClicked event for ped if my script is like this

local Johnson = createPed(71, 251.2587890625, 69.673828125, 1003.640625) 
setPedRotation(Johnson,92.558471679688) 
setElementDimension(Johnson, 1) 
setElementInterior(Johnson, 6) 
setElementData( Johnson, "talk", 1 ) 
setElementData( Johnson, "name", "Officer Johnson" ) 
setElementFrozen( Johnson, true) 
  
local localPlayer = getLocalPlayer() 
  
function showLicenseWindow( ) 
    triggerServerEvent("onLicenseServer", getLocalPlayer()) 
     
    local vehiclelicense = getElementData(getLocalPlayer(), "license.car") 
    local gunlicense = getElementData(getLocalPlayer(), "license.gun") 
  
    local width, height = 300, 400 
    local scrWidth, scrHeight = guiGetScreenSize() 
    local x = scrWidth/2 - (width/2) 
    local y = scrHeight/2 - (height/2) 
     
    wLicense= guiCreateWindow(x, y, width, height, "Los Santos Licensing Department", false) 
     
    licenseList = guiCreateGridList(0.05, 0.05, 0.9, 0.8, true, wLicense) 
    local column = guiGridListAddColumn(licenseList, "License", 0.7) 
    local column2 = guiGridListAddColumn(licenseList, "Cost", 0.2) 
     
    if (vehiclelicense~=1) then 
        local row = guiGridListAddRow(licenseList) 
        guiGridListSetItemText(licenseList, row, column, "Car License", false, false) 
        guiGridListSetItemText(licenseList, row, column2, "450", true, false) 
    end 
    if (gunlicense~=1) then 
        local row2 = guiGridListAddRow(licenseList) 
        guiGridListSetItemText(licenseList, row2, column, "Weapon License", false, false) 
        guiGridListSetItemText(licenseList, row2, column2, "4500", true, false) 
    end 
             
                 
    bAcceptLicense = guiCreateButton(0.05, 0.85, 0.45, 0.1, "Buy License", true, wLicense) 
    bCancel = guiCreateButton(0.5, 0.85, 0.45, 0.1, "Cancel", true, wLicense) 
     
    showCursor(true) 
     
    addEventHandler("onClientGUIClick", bAcceptLicense, acceptLicense) 
    addEventHandler("onClientGUIClick", bCancel, cancelLicense) 
end 
addEvent("onLicense", true) 
addEventHandler("onLicense", getRootElement(), showLicenseWindow) 

Link to comment
wLicense, licenseList, bAcceptLicense, bCancel = nil 
local Johnson = createPed(71, 251.2587890625, 69.673828125, 1003.640625) 
setPedRotation(Johnson,92.558471679688) 
setElementDimension(Johnson, 1) 
setElementInterior(Johnson, 6) 
setElementData( Johnson, "talk", 1 ) 
setElementData( Johnson, "name", "Officer Johnson" ) 
setElementFrozen( Johnson, true) 
  
local localPlayer = getLocalPlayer() 
  
function showLicenseWindow( ) 
    triggerServerEvent("onLicenseServer", getLocalPlayer()) 
     
    local vehiclelicense = getElementData(getLocalPlayer(), "license.car") 
    local gunlicense = getElementData(getLocalPlayer(), "license.gun") 
  
    local width, height = 300, 400 
    local scrWidth, scrHeight = guiGetScreenSize() 
    local x = scrWidth/2 - (width/2) 
    local y = scrHeight/2 - (height/2) 
     
    wLicense= guiCreateWindow(x, y, width, height, "Los Santos Licensing Department", false) 
     
    licenseList = guiCreateGridList(0.05, 0.05, 0.9, 0.8, true, wLicense) 
    local column = guiGridListAddColumn(licenseList, "License", 0.7) 
    local column2 = guiGridListAddColumn(licenseList, "Cost", 0.2) 
     
    if (vehiclelicense~=1) then 
        local row = guiGridListAddRow(licenseList) 
        guiGridListSetItemText(licenseList, row, column, "Car License", false, false) 
        guiGridListSetItemText(licenseList, row, column2, "450", true, false) 
    end 
    if (gunlicense~=1) then 
        local row2 = guiGridListAddRow(licenseList) 
        guiGridListSetItemText(licenseList, row2, column, "Weapon License", false, false) 
        guiGridListSetItemText(licenseList, row2, column2, "4500", true, false) 
    end 
             
                 
    bAcceptLicense = guiCreateButton(0.05, 0.85, 0.45, 0.1, "Buy License", true, wLicense) 
    bCancel = guiCreateButton(0.5, 0.85, 0.45, 0.1, "Cancel", true, wLicense) 
     
    showCursor(true) 
     
    addEventHandler("onClientGUIClick", bAcceptLicense, acceptLicense) 
    addEventHandler("onClientGUIClick", bCancel, cancelLicense) 
end 
addEvent("onLicense", true) 
addEventHandler("onLicense", getRootElement(), showLicenseWindow) 
addEventHandler("onClientClick", getRootElement(), showLicenseWindow) 

Like this? If yes, it's not working cause it's just spaming triggerServerEvent

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