ViRuZGamiing Posted February 1, 2013 Posted February 1, 2013 Hi, Here's my script; function startup() local file = xmlLoadFile("pns.xml") for k, v in ipairs(xmlNodeGetChildren(file)) do local pos = split(xmlNodeGetAttribute(v,"pos"),string.byte(",")) local marker = createMarker(pos[1],pos[2],pos[3],"cylinder") createBlipAttachedTo(marker,63,2,255,0,0,255,0,250) setElementData(marker,"pnsMarker",true) setGarageOpen(tonumber(xmlNodeGetAttribute(v,"garage")),true) end xmlUnloadFile(file) end addEventHandler("onResourceStart",getResourceRootElement(),startup) function payNSpray(hitElement) if (getElementData(source,"pnsMarker") == true) then if (getElementType(hitElement) == "vehicle") then if (getElementHealth(hitElement) < 1000) then if (getVehicleOccupant(hitElement)) then local driver = getVehicleOccupant(hitElement) local charge = math.floor(1000-getElementHealth(hitElement)) if (getPlayerMoney(driver) >= charge) then outputChatBox("Your vehicle has been repaired for $"..charge..".",driver,255,255,0) fixVehicle(hitElement) takePlayerMoney(driver,charge) for k, v in ipairs({"accelerate","enter_exit","handbrake"}) do toggleControl(driver,v,false) end setControlState(driver,"handbrake",true) fadeCamera(driver,false,1) setTimer(restoreControl,1000,1,driver) else local extraCost = math.floor(charge-getPlayerMoney(driver)) outputChatBox("You need an additional $"..extraCost.." for a repair.",driver,255,0,0) end end end end end end addEventHandler("onMarkerHit",getRootElement(),payNSpray) function restoreControl(driver) for k, v in ipairs({"accelerate","enter_exit","handbrake"}) do toggleControl(driver,v,true) end setControlState(driver,"handbrake",false) fadeCamera(driver,true) end What I want? - When Element (Player) Hits the Marker (onMarkerHit) the car is frozen till the the car is repaired. What I think, which is the right script; function freeze if onClientMarkerHit (Player) then elementFreeze if getVehicleHealth = 100 then elementUnfreeze addEventHandler ( "onClientMarkerHit", freeze) "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Castillo Posted February 1, 2013 Posted February 1, 2013 No offense, but that doesn't make any sense, try this: function startup() local file = xmlLoadFile("pns.xml") for k, v in ipairs(xmlNodeGetChildren(file)) do local pos = split(xmlNodeGetAttribute(v,"pos"),string.byte(",")) local marker = createMarker(pos[1],pos[2],pos[3],"cylinder") createBlipAttachedTo(marker,63,2,255,0,0,255,0,250) setElementData(marker,"pnsMarker",true) setGarageOpen(tonumber(xmlNodeGetAttribute(v,"garage")),true) end xmlUnloadFile(file) end addEventHandler("onResourceStart",getResourceRootElement(),startup) function payNSpray(hitElement) if (getElementData(source,"pnsMarker") == true) then if (getElementType(hitElement) == "vehicle") then if (getElementHealth(hitElement) < 1000) then if (getVehicleOccupant(hitElement)) then local driver = getVehicleOccupant(hitElement) local charge = math.floor(1000-getElementHealth(hitElement)) if (getPlayerMoney(driver) >= charge) then setElementFrozen ( hitElement, true ) outputChatBox("Your vehicle has been repaired for $"..charge..".",driver,255,255,0) fixVehicle(hitElement) takePlayerMoney(driver,charge) for k, v in ipairs({"accelerate","enter_exit","handbrake"}) do toggleControl(driver,v,false) end setControlState(driver,"handbrake",true) fadeCamera(driver,false,1) setTimer(restoreControl,1000,1,driver) else local extraCost = math.floor(charge-getPlayerMoney(driver)) outputChatBox("You need an additional $"..extraCost.." for a repair.",driver,255,0,0) end end end end end end addEventHandler("onMarkerHit",getRootElement(),payNSpray) function restoreControl(driver) for k, v in ipairs({"accelerate","enter_exit","handbrake"}) do toggleControl(driver,v,true) end local vehicle = getPedOccupiedVehicle ( driver ) if ( vehicle ) then setElementFrozen ( vehicle, false ) end setControlState(driver,"handbrake",false) fadeCamera(driver,true) end San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ViRuZGamiing Posted February 1, 2013 Author Posted February 1, 2013 Car doesn't unfreeze after Car repaired "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Castillo Posted February 1, 2013 Posted February 1, 2013 Oh yeah, I set it to freeze it again instead of unfreeze, copy it again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
ViRuZGamiing Posted February 1, 2013 Author Posted February 1, 2013 Ok thank you very much "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Castillo Posted February 1, 2013 Posted February 1, 2013 You're welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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