Jump to content

[Help] executeCommandHandler


mint3d

Recommended Posts

Can someone help me ? The Pickup isn't working I am really confused

function carGrid( thePlayer ) 
        triggerClientEvent(thePlayer, "carshop:cargrid", thePlayer, shops) 
    end 
  
addCommandHandler("listcarprices", carGrid) 
  
function CarPrices ( thePlayer )  
    createPickup ( 2114.1337890625, -2128.2666015625, 13.6328125, 3, 1239, 1 ) 
executeCommandHandler ( "listcarprices", thePlayer ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), CarPrices )  

Link to comment
function carGrid( thePlayer ) 
        triggerClientEvent(thePlayer, "carshop:cargrid", thePlayer, shops) 
    end 
  
addCommandHandler("listcarprices", carGrid) 
  
function CarPrices ( thePlayer ) 
    createPickup ( 2114.1337890625, -2128.2666015625, 13.6328125, 3, 1239, 1000 ) 
executeCommandHandler ( "listcarprices", thePlayer ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), CarPrices ) 

Edited by Guest
Link to comment
  
function carGrid( thePlayer ) 
        triggerClientEvent(thePlayer, "carshop:cargrid", thePlayer, shops) 
    end 
  
addCommandHandler("listcarprices", carGrid) 
  
function CarPrices ( thePlayer ) 
    createPickup ( 2114.1337890625, -2128.2666015625, 13.6328125, 3, 1239, 1 ) 
         triggerClientEvent(thePlayer, "carshop:cargrid", thePlayer, shops) 
end 
addEventHandler ( "onResourceStart", getRootElement(), CarPrices ) 
  

-,- :?

u defind shops ? ..

function carGrid ( thePlayer ) 
    triggerClientEvent ( thePlayer, "carshop:cargrid", thePlayer, shops ) 
end 
addCommandHandler( "listcarprices", carGrid ) 
  
function CarPrices (  ) 
    createPickup ( 2114.1337890625, -2128.2666015625, 13.6328125, 3, 1239, 1 ) 
    for _,p in ipairs ( getElementsByType ( "player" ) ) do  
     triggerClientEvent ( p, "carshop:cargrid", p, shops ) 
  end 
end 
addEventHandler ( "onResourceStart", resourceRoot, CarPrices ) 
Link to comment

None of them worked.

Client Side..

local myadminWindow = nil 
  
function carGrid (shops) 
    if (myadminWindow == nil) then 
        guiSetInputEnabled(true) 
        local screenx, screeny = guiGetScreenSize() 
        myadminWindow = guiCreateWindow ((screenx-700)/2, (screeny-500)/3, 700, 500, "Index of car prices", false) 
        local tabPanel = guiCreateTabPanel (0, 0.1, 1, 1, true, myadminWindow) 
        local lists = {} 
        local tlBackButton = guiCreateButton(0.8, 0.05, 0.2, 0.07, "Close", true, myadminWindow) -- close button 
         
        for int, carshop in ipairs(shops) do 
            local modelsSpawned = { } 
            for spotIndex, spawnPoint in ipairs(carshop["spawnpoints"]) do 
                if spawnPoint["vehicle"] and isElement(spawnPoint["vehicle"]) then 
                    table.insert( modelsSpawned,  getElementModel(spawnPoint["vehicle"]), true) 
                end 
            end 
            local tab = guiCreateTab(carshop["name"], tabPanel) 
            lists[int] = guiCreateGridList(0.02, 0.02, 0.96, 0.96, true, tab) -- commands for level one admins  
            guiGridListAddColumn (lists[int], "Name", 0.15) 
            guiGridListAddColumn (lists[int], "Price", 0.35) 
            guiGridListAddColumn (lists[int], "Remarks", 1.3) 
             
            for id, carDetails in ipairs(carshop["prices"]) do 
                local row = guiGridListAddRow ( lists[int] ) 
                local remark = "" 
                local carModel = getVehicleModelFromName(carDetails[1]) or -1 
                if (modelsSpawned[carModel]) then 
                    remark = " - Spawned" 
                end 
                guiGridListSetItemText ( lists[int], row, 1, carDetails[1] .. "(" .. tostring(carModel) .. ")", false, false) 
                guiGridListSetItemText ( lists[int], row, 2, carDetails[2], false, false) 
                guiGridListSetItemText ( lists[int], row, 3, carDetails[3] and "Secondhand" or "Brand new"..remark, false, false) 
            end 
        end 
        addEventHandler ("onClientGUIClick", tlBackButton, function(button, state) 
            if (button == "left") then 
                if (state == "up") then 
                    guiSetVisible(myadminWindow, false) 
                    showCursor (false) 
                    guiSetInputEnabled(false) 
                    myadminWindow = nil 
                end 
            end 
        end, false) 
         
        guiBringToFront (tlBackButton) 
        guiSetVisible (myadminWindow, true) 
    else 
        local visible = guiGetVisible (myadminWindow) 
        if (visible == false) then 
            guiSetVisible( myadminWindow, true) 
            showCursor (true) 
        else 
            showCursor(false) 
        end 
    end 
end 
addEvent("carshop:cargrid", true) 
addEventHandler("carshop:cargrid", getRootElement(), carGrid) 
  

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