Dimos7 Posted July 16, 2017 Share Posted July 16, 2017 (edited) function toggleWindows() for _, v in ipairs(getElementsByType("player")) do local car = getPedOccupiedVehicle(v) local seat = getPedOccupiedVehicleSeat(v) if isPedInVehicle(v) then if getPedOccupiedVehicleSeat(localPlayer) == 0 then if seatWindows[seat] then if not isVehicleWindowOpen(car, 4) and not isVehicleWindowOpen(car, 2) and not isVehicleWindowOpen(car, 5) and not isVehicleWindowOpen(car, 3) then setVehicleWindowOpen(car, 4, true) setVehicleWindowOpen(car, 2, true) setVehicleWindowOpen(car, 5, true) setVehicleWindowOpen(car, 3, true) exports["chat-system"]:meChat(localPlayer, "rolls down the windows of the ".. getVehicleName(car)..".") else setVehicleWindowOpen(car, 4, false) setVehicleWindowOpen(car, 2, false) setVehicleWindowOpen(car, 5, false) setVehicleWindowOpen(car, 3, false) exports["chat-system"]:meChat(localPlayer, "rolls up the windows of the "..getVehicleName(car)..".") end else outputChatBox("This vehicle is not have window.", 255, 0, 0) end end end end end addCommandHandler("wdall", toggleWindows) local seatWindows = { [0] = 4, [1] = 2, [2] = 5, [3] = 3 } function toggleWindow() for _, v in ipairs(getElementsByType("player")) do local car = getPedOccupiedVehicle(v) local seat = getPedOccupiedVehicleSeat(v) if isPedInVehicle(v) then if seatWindows[seat] then if not isVehicleWindowOpen(car, seatWindows[seat]) then setVehicleWindowOpen(car, seatWindows[seat], true) exports["chat-system"]:meChat(localPlayer, " rolls down their window.") else setVehicleWindowOpen(car, seatWindows[seat], false) exports["chat-system"]:meChat(localPlayer, " rolls up their window.") end else outputChatBox("This vehicle is not have window.", 255, 0, 0) end end end end addCommandHandler("wd", toggleWindow) setBlurLevel(0) failed to call chat-system:meChat [ string"?"] i try call same error help in server side works fine function meChat(thePlayer, ...) local px, py, pz = getElementPosition(thePlayer) local message = table.concat({...}, " ") local players = getPlayerName(thePlayer) local nick = tostring(players):gsub("_", " ") for _, v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v, px, py, pz, 10) then if message ~="" then outputChatBox("* "..nick.." "..message, v, 194, 162, 218) end end end outputServerLog("[IC-ME] "..nick.." "..message) end <meta> <script src="s_chat.lua"/> <export function="meChat" type="shared"/> </meta> Edited July 16, 2017 by Dimos7 Link to comment
kikos500 Posted July 17, 2017 Share Posted July 17, 2017 <meta> <script src="s_chat.lua" type="server"/> <export function="meChat" type="server"/> </meta> -- instead of this exports["chat-system"]:meChat(localPlayer, "rolls up the windows of the "..getVehicleName(car)..".") -- use this in client triggerServerEvent("updateChat", localPlayer, "rolls up the windows of the "..getVehicleName(car)..".") -- this in server addEvent("updateChat", true) addEventHandler("updateChat", root, function(msg) exports["chat-system"]:meChat(source, msg) end ) try this im not sure tho Link to comment
keymetaphore Posted July 17, 2017 Share Posted July 17, 2017 Is the window toggling a serverside script? 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