jeremaniak Posted March 21, 2012 Share Posted March 21, 2012 Is it possible too onClientTrigger --When the client event is triggerd is it possible to trigger the server, something like onClientTrigger , triggerServerEvent. --If so please tell me how? Link to comment
drk Posted March 21, 2012 Share Posted March 21, 2012 Server: addEventHandler ( "onResourceStart", resourceRoot, function ( ) triggerClientEvent ( "LOL", root ) end ) addEvent ( "LOL2", true ) addEventHandler ( "LOL2", root, function ( ) print ( "LOL" ) end ) Client: addEvent ( "LOL", true ) addEventHandler ( "LOL", root, function ( ) triggerClientEvent ( "LOL2", root ) end ) ?? As far as I know, event "onClientTrigger" or something like that exists. Link to comment
jeremaniak Posted March 21, 2012 Author Share Posted March 21, 2012 We want to do it with a picture Link to comment
jeremaniak Posted March 21, 2012 Author Share Posted March 21, 2012 I will send some lines in a sec Link to comment
jeremaniak Posted March 21, 2012 Author Share Posted March 21, 2012 I have already started my addeventhandler onresourcestart and resourceroot so how can i do it without the resourcestart for example the second function Link to comment
drk Posted March 21, 2012 Share Posted March 21, 2012 I don't understand, maybe you can explain better? Link to comment
Absence2 Posted March 21, 2012 Share Posted March 21, 2012 explain better https://wiki.multitheftauto.com/wiki/AddCommandHandler https://wiki.multitheftauto.com/wiki/Gui ... taticImage https://wiki.multitheftauto.com/wiki/DxDrawImage Link to comment
Grimaexreaper Posted March 21, 2012 Share Posted March 21, 2012 Well what he is trying to ask is for example we are rescripting the speed cam my homeboy made so heres the server side and i'll get to the point addEventHandler("onResourceStart",resourceRoot, function () for index, camera in ipairs(cameraTable) do local marker = createMarker(camera.x, camera.y, camera.z, "cylinder", camera.size, 255, 200, 0, 0, root) cameras[marker] = {speed=camera.speed} addEventHandler("onMarkerHit", marker, onCameraMarkerHit) if (enableBlips) then local blip = createBlip(camera.x, camera.y, camera.z, 0, 1, 255, 0, 0, 255, 0, 70, getRootElement()) setBlipVisibleDistance(blip, 200) end end end) function onCameraMarkerHit(hitElement) if (getElementType(hitElement) ~= "player" ) then return end if (not isPedInVehicle(hitElement)) then return end local vehicle = getPedOccupiedVehicle(hitElement) if not vehicle then return end local driver = getVehicleOccupant ( vehicle, 0 ) if (not driver) then return end if (not getVehicleSirensOn(vehicle)) then local speedx, speedy, speedz = getElementVelocity(vehicle) local cX, cY, cZ = getElementPosition(vehicle) local speed = cameras[source].speed local actualSpeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) local mph = math.floor(actualSpeed * 111.847) if (mph >= speed ) then local overSpeed = mph - speed local money = overSpeed * 10 outputChatBox("* You've got flashed! (Reason: Driving over ".. speed .." mph)", hitElement, 255, 200, 0, false) outputChatBox("* Your speed: ".. mph .."!", hitElement, 255, 200, 0, false) outputChatBox("* The Police have been Alerted of your Violation!", hitElement, 255, 200, 0, false) triggerClientEvent ( "showPicture", hitElement ) fadeCamera(hitElement, false, 0.5, 255, 255, 255) setTimer(fadeCamera, 100, 1, hitElement, true, 1.0, 255, 255, 255) warningTimers[hitElement] = setTimer(sendWarningToCops, 100, 1, vehicle, hitElement, mph, getElementPosition(hitElement)) toPay[hitElement] = money end end end ok that was the server side which my point im getting to well we are is we are trying to add it like when it pops up for example it shows up our pic on the speed cam if we speed so what we are trying to do is add it to where it also shows up for the police faction which is called Los Santo's Police Department so heres what we are getting messed up on we done this but it doest work eather way we put it first let me show u the client side so you understand function daPic() dxUpdateScreenSource(screen); addEventHandler("onClientRender", root, showSpeedPic) setTimer(removeDaAnnoyingThingy, 5500, 1); end addEvent("showPicture", true) addEventHandler("showPicture", getLocalPlayer(), daPic) ok now we go back to our server side once more and this is what we put function sendWarningToCops(theVehicle, thePlayer, speed, x, y, z) if isTimer(warningTimers[thePlayer]) then toPay[thePlayer] = nil if isTimer(warningTimers[thePlayer]) then killTimer(warningTimers[thePlayer]) end local direction = "in an unknown direction" local areaName = getZoneName(x, y, z) local nx, ny, nz = getElementPosition(thePlayer) local vehicleName = getVehicleName(theVehicle) local color1, color2 = getVehicleColor(theVehicle) local dx = nx - x local dy = ny - y if dy > math.abs(dx) then direction = "northbound" elseif dy < -math.abs(dx) then direction = "southbound" elseif dx > math.abs(dy) then direction = "eastbound" elseif dx < -math.abs(dy) then direction = "westbound" end if not (vehicleName == "Police LS") then local theTeam = getTeamFromName("Los Santo's Police Department") local teamPlayers = getPlayersInTeam(theTeam) for key, value in ipairs(teamPlayers) do local duty = tonumber(getElementData(value, "duty")) if (duty>0) then outputChatBox("[RADIO] All units, Traffic violation at " .. areaName .. ".", value, 255, 194, 14) outputChatBox("[RADIO] Vehicle was a " .. vehicleColor(color1, color2) .. " " .. vehicleName .. " travelling at " .. tostring(math.ceil(speed)) .. " KPH.", value, 255, 194, 14) outputChatBox("[RADIO] Suggested Fine,10 Dollars per KM/ Over The plate is '".. getVehiclePlateText ( theVehicle ) .."' and heading " .. direction .. ".", value, 255, 194, 14) triggerClientEvent(source, "showPicture2", theVehicle, thePlayer, speed, x, y, z) end end end end end now we go to add showPicture2 like we did on the first one in client to try and trigger the client event for example function daPic2() dxUpdateScreenSource(screen); addEventHandler("onClientRender", root, showSpeedPic) setTimer(removeDaAnnoyingThingy, 5501, 1); end addEvent("showPicture2", true) addEventHandler("showPicture2", getLocalPlayer(), daPic2) oh and one thing i forgot to show you is we also added this which is also client involving the events function showSpeedPic() rect = dxDrawRectangle(20.0,209.0,295.0,255.0,tocolor(0,0,0,140),false) dxDrawImage( 28.0,217.0,279.0,238.0, screen) end function removeDaAnnoyingThingy() removeEventHandler("onClientRender", root, showSpeedPic) end so my qustion is what is it we are not adding or what is it we are doing wrong ive tryed to add events trigger events even back door to call to server then call back to client on a diff so im stuck here any help on what we doing wrong would be apreshated -- Link to comment
Absence2 Posted March 21, 2012 Share Posted March 21, 2012 you might want to re-read your last script there. function showSpeedPic() rect = dxDrawRectangle(20.0,209.0,295.0,255.0,tocolor(0,0,0,140),false) dxDrawImage( 28.0,217.0,279.0,238.0, screen) --this part end function removeDaAnnoyingThingy() removeEventHandler("onClientRender", root, showSpeedPic) end Link to comment
drk Posted March 21, 2012 Share Posted March 21, 2012 triggerClientEvent(source, "showPicture2", theVehicle, thePlayer, speed, x, y, z) showPicture2 don't have any arguments. Link to comment
Grimaexreaper Posted March 21, 2012 Share Posted March 21, 2012 function daPic2() dxUpdateScreenSource(screen); addEventHandler("onClientTrigger", picRoot, showSpeedPic2) setTimer(removeDaAnnoyingThingy, 5501, 1); end addEvent("showPicture2", true) addEventHandler("showPicture2", getLocalPlayer(), daPic2) function removeDaAnnoyingThingy2() removeEventHandler("onClientTrigger", picRoot, showSpeedPic2) end ok so now i added that client side and this server function sendWarningToCops(theVehicle, thePlayer, speed, x, y, z) if isTimer(warningTimers[thePlayer]) then toPay[thePlayer] = nil if isTimer(warningTimers[thePlayer]) then killTimer(warningTimers[thePlayer]) end local direction = "in an unknown direction" local areaName = getZoneName(x, y, z) local nx, ny, nz = getElementPosition(thePlayer) local vehicleName = getVehicleName(theVehicle) local color1, color2 = getVehicleColor(theVehicle) local dx = nx - x local dy = ny - y if dy > math.abs(dx) then direction = "northbound" elseif dy < -math.abs(dx) then direction = "southbound" elseif dx > math.abs(dy) then direction = "eastbound" elseif dx < -math.abs(dy) then direction = "westbound" end if not (vehicleName == "Police LS") then local theTeam = getTeamFromName("Los Santo's Police Department") local teamPlayers = getPlayersInTeam(theTeam) for key, value in ipairs(teamPlayers) do local duty = tonumber(getElementData(value, "duty")) if (duty>0) then outputChatBox("[RADIO] All units, Traffic violation at " .. areaName .. ".", value, 255, 194, 14) outputChatBox("[RADIO] Vehicle was a " .. vehicleColor(color1, color2) .. " " .. vehicleName .. " travelling at " .. tostring(math.ceil(speed)) .. " KPH.", value, 255, 194, 14) outputChatBox("[RADIO] Suggested Fine,10 Dollars per KM/ Over The plate is '".. getVehiclePlateText ( theVehicle ) .."' and heading " .. direction .. ".", value, 255, 194, 14) triggerClientEvent ( "showPicture2", theVehicle, thePlayer, speed, x, y, z ) end end end end end it now shows up 0 errors and works like it would before we added anything lol exatly what are we doing wrong so i can fix it? Link to comment
drk Posted March 21, 2012 Share Posted March 21, 2012 What's wrong: - onClientTrigger event not exists. - showPicture2 event don't have any arguments so you can't trigger the event with arguments "theVehicle, thePlayer, speed, x, y, z" Link to comment
jeremaniak Posted March 21, 2012 Author Share Posted March 21, 2012 Why isnt there any onClienTrigger Link to comment
Grimaexreaper Posted March 27, 2012 Share Posted March 27, 2012 Why isnt there any onClienTrigger i think he means it don't exist in the scripting launguage i'll be on today if u wanna finish scripting this mite as well release it when we done uncompiled 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