MAB Posted August 28, 2015 Share Posted August 28, 2015 this is a medic job codes 1. the old blips, markers etc... don't get destroyed if you exit and got in the ambulance again 2. i can't see the peds i see only the markers 3. how to make that serverside ped visible to the player who is working only and also can't be killed 4. how to display a timer on the player's screen when he get on in the ambulance .. make it 30 sec for example 5. please hurry up server local medic = createMarker (-2685.57227,638.31696,13.45313,"cylinder",2,255,255,0,255) local medic_blip = createBlipAttachedTo (medic,60) setElementData(medic,"JobHandler","medic") ambs = {} ambs_blips = {} ambs_spawns = { {-2705.15186, 608.86151, 14.45313}, {-2661.22217, 611.69843, 14.45313}, {-2634.44507, 611.14960, 14.45313} } addCommandHandler("rot",function(p) local rotx,roty,rotz = getElementRotation (p) outputChatBox("x = "..rotx..", y = "..roty..", z = "..rotz,p) end ) addEvent("start",true) function start (player) local x,y,z = unpack(ambs_spawns[math.random(#ambs_spawns)]) ambs[player] = createVehicle(416,x,y,z,0,0,180) ambs_blips[player] = createBlipAttachedTo(ambs[player],56) setElementData(ambs[player],"owner",getAccountName(getPlayerAccount(player))) setElementData(ambs[player],"jv",true) setElementVisibleTo(ambs_blips[player],root,false) setElementVisibleTo(ambs_blips[player],player,true) end addEventHandler("start",root,start) peds = {} peds_spawns = { {-2626.49707, 208.97466, 4.59974, 3.0075378417969, -2626.71362, 211.40800, 3.59591}, {-2596.55273, 9.26447, 4.32813, 91.366455078125, -2598.76660, 9.18804, 3.32813}, {-2430.27051, -93.64320, 35.32031, 268.06225585938, -2427.76245, -93.62108, 34.32031}, {-2107.03760, -196.01930, 36.32031, 183.82331848145, -2106.85205, -197.84091, 34.32031}, {-2025.07690, 67.10520, 28.43436, 268.46875, -2022.33093, 66.90797, 27.47522}, {-1896.05225, 276.31894, 41.04688, 182.97734069824, -1896.36011, 273.55161, 40.04688}, {-1942.93811, 517.28296, 35.17188, 184.27923583984, -1942.94666, 514.39331, 34.17188}, {-1881.05774, 822.72467, 35.17733, 44.552978515625, -1882.40417, 824.30682, 34.17519}, {-1754.20752, 962.91943, 24.88281, 183.67497253418, -1754.19238, 959.97577, 23.88281}, {-1639.83740, 1199.97375, 7.19314, 183.42778015137, -1639.77673, 1197.71912, 6.18750}, {-2018.75378, 1192.67859, 45.45645, 180.29663085938, -2018.69739, 1190.42798, 44.44531}, {-2278.68262, 767.94128, 47.44531, 279.93316650391, -2276.09521, 767.86768, 48.44531}, {-2075.05811, 899.69049, 64.13281, 1.6397399902344, -2075.05811, 902.69049, 63.13281}, {-2043.64758, 1261.60303, 9.17966, 0.21697998046875, -2043.64880, 1264.93750, 7.81435} } peds_blips = {} peds_markers = {} function begin (player) if getElementModel(source) == 416 then if getElementData(source,"jv") == true then if getElementData(source,"owner") == getAccountName(getPlayerAccount(player)) then if isElement(peds[player]) then destroyElement(peds[player]) end if isElement(peds_blips[players]) then destroyElement(peds_blips[players]) end if isElement(peds_markers[players]) then destroyElement(peds_markers[player]) end local x,y,z,r,a,b,c = unpack(peds_spawns[math.random(#peds_spawns)]) peds[player] = createPed (math.random(1,312),x,y,z,r) peds_markers[player] = createMarker(a,b,c,"cylinder",3,255,255,0,255) peds_blips[player] = createBlipAttachedTo(peds_markers[player],0,2,255,255,0,255) setElementVisibleTo(peds_markers[player],root,false) setElementVisibleTo(peds_blips[player],root,false) setElementVisibleTo(peds_blips[player],player,true) setElementVisibleTo(peds_markers[player],player,true) end end end end addEventHandler ( "onVehicleEnter", getRootElement(), begin ) function stop (player) if getElementModel(source) == 416 then if getElementData(source,"jv") == true then if getElementData(source,"owner") ~= getAccountName(getPlayerAccount(player)) then cancelEvent() if getElementData(player,"told") == false then outputChatBox("You can't enter this vehicle.",player,255,255,0) setElementData(player,"told",true) setTimer(setElementData,5000,1,player,"told",false) end end end end end addEventHandler("onVehicleStartEnter",root,stop) client : function MarkerHit(hitPlayer, matchingDimension) if (getElementData(source, "JobHandler") == "medic") then if (hitPlayer==getLocalPlayer()) then if not(isPedInVehicle(getLocalPlayer())) then if (not(getElementData(getLocalPlayer(), "Job") == "medic")) then outputChatBox("You are not a Medic.",255,0,0,true) else if getElementData(hitPlayer,"started") == false then setElementData(hitPlayer,"medic",true) showCursor(true) else outputChatBox("You have started this job before.",255,255,0) end end end end end end addEventHandler("onClientMarkerHit", getRootElement(), MarkerHit) local x,y = guiGetScreenSize() function draw () if getElementData(localPlayer,"medic") == true and getElementData(localPlayer,"started") == false then dxDrawRectangle((x - 306) / 2, (y - 124) / 2, (x - 678) / 2, (y - 520) / 2, tocolor(0, 0, 0, 100), false) dxDrawText("Medic", (x - 100) / 2, (y - 123) / 2, ((x - 100) / 2)+93, ((y - 123) / 2)+29, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Accept", (x - 304) / 2, (y + 70) / 2, ((x - 304) / 2)+88, ((y + 70) / 2)+23, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Close", (x + 130) / 2, ((y + 70) / 2), ((x + 130) / 2)+76, ((y + 70) / 2)+23, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) end end addEventHandler("onClientRender",root,draw) function click (b,s,r,z) if (b == "left" and s == "up") then if getElementData(localPlayer,"medic") == true then if (r > (x - 304) / 2 and r < ((x - 304) / 2)+88 and z > (y + 70) / 2 and z < ((y + 70) / 2)+23) then -- accept setElementData(localPlayer,"medic",false) showCursor(false) setElementData(localPlayer,"started",true) triggerServerEvent ("start",localPlayer,localPlayer) end if (r > (x + 130) / 2 and r < ((x + 130) / 2)+76 and z > (y + 70) / 2 and z < ((y + 70) / 2)+23) then -- close setElementData(localPlayer,"medic",false) showCursor(false) end end end end addEventHandler("onClientClick",root,click) Link to comment
pa3ck Posted August 28, 2015 Share Posted August 28, 2015 Q1. Use setTimer with a decreasing number or just get the remaining time of the timer and display that on the screen Q2. Create the ped client side so only the client can see it Q3. Was the "hurry up" mark really needed? Link to comment
MAB Posted August 28, 2015 Author Share Posted August 28, 2015 Q1. Use setTimer with a decreasing number or just get the remaining time of the timer and display that on the screenQ2. Create the ped client side so only the client can see it Q3. Was the "hurry up" mark really needed? 1. i didn't understand that 2. i tried but didn't work.. couldn't even see the ped 3. it was Link to comment
pa3ck Posted August 28, 2015 Share Posted August 28, 2015 1. What part did you not understand? * GUI: Create a timer and a variable which is equal to the timers length in seconds. Decrease that number by one inside the function and use a simple guiSetText to update the time * DX: create a variable with 30 and decrease this number inside a timer and when the timer ends remove the event handler or use getTickCount 2. Post your code and maybe we can help you with that. Link to comment
MAB Posted August 28, 2015 Author Share Posted August 28, 2015 1. What part did you not understand? * GUI: Create a timer and a variable which is equal to the timers length in seconds. Decrease that number by one inside the function and use a simple guiSetText to update the time * DX: create a variable with 30 and decrease this number inside a timer and when the timer ends remove the event handler or use getTickCount 2. Post your code and maybe we can help you with that. 1. understood.. it will take the dx one 2. all my codes are here 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