TrickyTommy Posted August 23, 2017 Posted August 23, 2017 I am making a job-system script, and it simply just won't work."server triggered clientside event drawBusMarker, but event is not added clientside." local markerData = {} markerData["busMarkerX"] = 2481.96753 markerData["busMarkerY"] = -1670.67761 markerData["busMarkerZ"] = 13.34018 markerData["busMarkerSize"] = 2 markerData["busMarkerAlpha"] = 100 markerData["busMarkerR"] = 149 markerData["busMarkerG"] = 215 markerData["busMarkerB"] = 116 function createBusMarker() if isElement (busMarker) then destroyElement (busMarker) end triggerClientEvent ("drawBusMarker", getRootElement(), markerData["busMarkerX"], markerData["busMarkerY"], markerData["busMarkerZ"]) busMarker = createMarker (markerData["busMarkerX"], markerData["busMarkerY"], markerData["busMarkerZ"]-1, "cylinder", markerData["busMarkerSize"], markerData["busMarkerR"], markerData["busMarkerG"], markerData["busMarkerR"], markerData["busMarkerAlpha"]) return busMarker end Client: local white = tocolor(255,255,255,255) function dxDrawImage3D(x,y,z,w,h,m,c,r,...) local lx, ly, lz = x+w, y+h, (z+tonumber(r or 0)) or z return dxDrawMaterialLine3D(x,y,z, lx, ly, lz, m, h, c or white, ...) end function drawBusMarker(busX, busY, busZ) function renderBusMarker() local busIcon = dxCreateTexture("files/images/buszIkon.png") dxDrawImage3D (busX, busY, busZ, 200, 200) end addEventHandler ("onClientRender", getRootElement(), renderBusMarker) end addEvent ("drawBusMarker", true) addEventHandler ("drawBusMarker", getRootElement(), drawBusMarker) Sorry if i am not findig a simple mistake, but i am awake for a day now, and i am really tired. meta: clientside starts first <meta> <script src="codeCG.Job.lua" type="client"/> <script src="codeC.Job.lua" type="client"/> <script src="codeSG.Job.lua" type="server"/> <script src="codeS.Job.lua" type="server"/> <file src="files/images/buszIkon.png"/> </meta>
Rockyz Posted August 23, 2017 Posted August 23, 2017 if you used onResourceStart at the serverside you need a timer TrickyTommy 1
MTA Team Lpsd Posted August 23, 2017 MTA Team Posted August 23, 2017 @#,+( _xiRoc[K]; > That's bad practice. If you use onResourceStart to trigger it, should create an onClientResourceStart event on the clientside which then calls to the serverside. This ensures the clientside is loaded properly. TrickyTommy 1
TrickyTommy Posted August 23, 2017 Author Posted August 23, 2017 i made a timer that delays it by 2500ms. works fine by now.
MTA Team Lpsd Posted August 23, 2017 MTA Team Posted August 23, 2017 @TrickyTommy as I explained in reply, that's bad practice and you shouldn't do it. What if on the off-chance the clientside didn't load in 2500ms? Then you're screwed. Do it the way I suggested by having an onClientResourceStart which makes a call to the serverside - then you know that the clientside is definitely loaded. TrickyTommy 1
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