aintaro Posted April 15, 2014 Share Posted April 15, 2014 Hello guys, The problem is I want my server sided function to finish before it executes the triggerClientEvent. Here is the code server sided: local vc1, vc2, vc3, vc4 function spawnOwnedVehicle(source, commandName, vehicleType) for y = 1, table.getn(playerVehicle) do outputChatBox(vehicleType) --if (playerVehicle[y] == tonumber(vehicleType)) then --found vehicle now load colors plx for x = 1, 5 do --outputChatBox(tostring(playerVehicle[y][x])) if (x == 2) then vc1 = playerVehicle[y][x] --loading colors outputChatBox(vc1) elseif (x == 3) then vc2 = playerVehicle[y][x] --loading colors elseif( x== 4) then vc3 = playerVehicle[y][x] --loading colors elseif (x== 5) then vc4 = playerVehicle[y][x] --loading colors end end --end end outputChatBox("Server send the trigger") triggerClientEvent ( "spawnPersonalVehicle", getRootElement(), spawnPersonalVehicle, vehicleType, vc1, vc2, vc3, vc4) --send the configs to the client so we can spawn this vehicle end addCommandHandler("spawnvehicles", spawnOwnedVehicle, source) code client sided : function spawnPersonalVehicle(localPlayer, pvehicleId, pvc1, pvc2 ,pvc3, pvc4) outputChatBox("Client got the server trigger") outputChatBox(pvehicleId) outputChatBox("pvc1"..pvc1) outputChatBox("pvc2"..pvc2) outputChatBox("pvc3"..pvc3) outputChatBox("pvc4"..pvc4) local x, y , z = getElementPosition(source) local personalVehicle = createVehicle ( getVehicleNameFromModel ( tonumber(pvehicleId) ), x + 5, y, z) setVehicleColor ( personalVehicle, tonumber(pvc1), tonumber(pvc2), tonumber(pvc3), tonumber(pvc4)) end addEvent("spawnPersonalVehicle", true) addEventHandler("spawnPersonalVehicle", root, spawnPersonalVehicle) output : Client got the server trigger [some parameters] Server send the trigger ps : No idea why lua tags are not working Thanks in advance, Greetz Aintaro Link to comment
.:HyPeX:. Posted April 15, 2014 Share Posted April 15, 2014 If you really want to do this, you could delay it with a timer, but its still weird. (i think it is outputChatBox who delays to reach client more than the trigger, wich its output is instant cuz of local-side.) Link to comment
arezu Posted April 15, 2014 Share Posted April 15, 2014 The server side script does load before triggering client event, it's just that outputChatBox server side seems to have lower priority than triggerClientEvent or something so triggerClientEvent is processed before outputChatBox. So you dont have to worry about it. Link to comment
.:HyPeX:. Posted April 15, 2014 Share Posted April 15, 2014 The server side script does load before triggering client event, it's just that outputChatBox server side seems to have lower priority than triggerClientEvent or something so triggerClientEvent is processed before outputChatBox.So you dont have to worry about it. It also does something to do with your connection, and its related to this. you will see almost the same effect going from client to server side. Link to comment
Bonsai Posted April 15, 2014 Share Posted April 15, 2014 I'm not sure, but I have seen the Chat being really laggy on certain servers because of blocked traffic. I don't know how their scripts look like but triggerLatentClientEvent got this written down in wiki: "...other network traffic is not blocked while the data is being transferred." Maybe you should try that. Link to comment
aintaro Posted April 16, 2014 Author Share Posted April 16, 2014 I'm not sure, but I have seen the Chat being really laggy on certain servers because of blocked traffic.I don't know how their scripts look like but triggerLatentClientEvent got this written down in wiki: "...other network traffic is not blocked while the data is being transferred." Maybe you should try that. thanks man ,I didn't know that 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