MAB Posted August 25, 2015 Share Posted August 25, 2015 help me here... i am making a medic job that to start it you should press E... what ever...the problem here is that on logout function destroys the last ambulance not the player who logged out one and i think the onexplode function does that as well (note : this on logout function is not the original one... that is one i was trying to make it destroy the player's ambulance only but it isn't working) i need you please to tell what is the best way to make a job.. client or server .. and what functions to use .. etc this is the all i reached with the job and all is client side... local medic = createMarker (-2685.57227,638.31696,13.45313,"cylinder",2,255,255,0,255) local medic_blip = createBlipAttachedTo (medic,60) function output (hit,mat) if ( getElementType(hit) == "player" ) and mat then if getElementData(hit,"Job") ~= "medic" then outputChatBox ( "Press E to start the medic job.", hit, 255, 255, 0, true ) else outputChatBox ( "You are a medic arleady.", hit, 255, 255, 0, true ) end end end addEventHandler("onMarkerHit",medic,output) function start (p,k,s) setElementData(p,"Job","medic") unbindKey(p,"e","down",start) amb = createVehicle(416,-2706.53613,615.68994,14.45313,0,0,180) amb_blip = createBlipAttachedTo(amb,56) setElementVisibleTo(amb_blip,root,false) setElementVisibleTo(amb_blip,p,true) setElementData(amb,"owner",getAccountName(getPlayerAccount(p))) setElementData(amb,"jobVehicle",true) addEventHandler("onVehicleExplode",amb,onexpolde) end function bind (hit,mat) if getElementData(hit,"Job") ~= "medic" and mat then bindKey (hit,"e","down",start) end end addEventHandler("onMarkerHit",medic,bind) function unbind (hit) if isKeyBound (hit,"e","down",start) then unbindKey (hit,"e","down",start) end end addEventHandler("onMarkerLeave",medic,unbind) function onenter (pla) if getElementData(source,"jobVehicle") == true then if getElementData(source,"owner") ~= getAccountName(getPlayerAccount(pla)) then cancelEvent() if getElementData(pla,"told") == false then outputChatBox("This isn't your vehicle.",pla,255,255,0) setElementData(pla,"told",true) setTimer(setElementData,5000,1,pla,"told",false) end end end end addEventHandler("onVehicleStartEnter",root,onenter) function destroyBlipsAttachedTo(player) local attached = getAttachedElements ( player ) if ( attached ) then for k,element in ipairs(attached) do if getElementType ( element ) == "blip" then destroyElement ( element ) end end end end function onLogout () local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do if getElementData(v,"jobVehicle") == true then local data = getElementData(v,"owner") local account = getAccountFromName(data) if account == getPlayerAccount(source) then destroyBlipsAttachedTo(v) destroyElement(v) end end end end addEventHandler("onPlayerLogout",root,onLogout) function getAccountFromName ( name ) return getAccount ( name ) or false end function onexpolde () if isElement(amb_blip) then destroyElement(amb_blip) end local data = getElementData(source,"owner") local account = getAccountFromName(data) local player = getAccountPlayer(account) if player and isElement(player) then setElementData(player,"Job",false) end end 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