Xabi Posted March 3, 2015 Share Posted March 3, 2015 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
DNL291 Posted March 3, 2015 Share Posted March 3, 2015 addEventHandler("onToggleVehicleCatalog", localPlayer, toggleVehicleCatalog) It should be: addEventHandler("onToggleVehicleCatalog", root, toggleVehicleCatalog) Link to comment
Xabi Posted March 3, 2015 Author Share Posted March 3, 2015 It worked, thanks for all Link to comment
Moderators IIYAMA Posted March 3, 2015 Moderators Share Posted March 3, 2015 Both ways are correct, since the player(the source) you are sending through will become the localPlayer. 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