Jump to content

Not detecting localPlayer


Xabi

Recommended Posts

Hi all, when I trigger a client event, it doesn't detect the localPlayer, so if i don't pass enteredCarshop as parameter, and do getElementData(localPlayer, "rpPlayerEnteredCarshop) in clientside, the script doesn't work:

Server:

function vehicleCatalogCommand(playerSource, commandName) 
    if playerSource then 
        local enteredCarshop = getElementData(playerSource, "rpPlayerCarshopEntered") 
        if enteredCarshop > -1 then 
            triggerClientEvent(playerSource, "onToggleVehicleCatalog", playerSource, enteredCarshop) 
        end 
    end 
end 

Client:

function toggleVehicleCatalog(enteredCarshop) 
    local carList = xmlLoadFile("carlist.xml") 
    if carList then 
        for _, group in ipairs(xmlNodeGetChildren(carList)) do 
            local carshop = tonumber(xmlNodeGetAttribute(group, "carshop")) 
            if carshop == enteredCarshop then 
                for _, vehicle in ipairs(xmlNodeGetChildren(group)) do 
                    local row = guiGridListAddRow(vehicleList) 
                    local model = xmlNodeGetAttribute(vehicle, "model") 
                    local name = xmlNodeGetAttribute(vehicle, "name") 
                    guiGridListSetItemText(vehicleList, row, modelColumn, model, false, true) 
                    guiGridListSetItemText(vehicleList, row, vehicleNameColumn, name, false, false) 
                end 
                addEventHandler("onClientGUIClick", vehicleList, showVehicleStats) 
                break 
            end 
        end 
        xmlUnloadFile(carList) 
        guiSetVisible(vehicleCatalog, true) 
        guiSetVisible(vehicleNameLabel, false) 
        guiSetVisible(vehiclePriceLabel, false) 
        guiSetVisible(vehicleRimsLabel, false) 
        guiSetVisible(vehicleRimsCombo, false) 
        guiSetInputEnabled(true) 
        showCursor(true) 
    end 
end 
addEvent("onToggleVehicleCatalog", true) 
addEventHandler("onToggleVehicleCatalog", localPlayer, toggleVehicleCatalog) 

Any help on this, please?

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