LooooP Posted June 23, 2010 Posted June 23, 2010 well, I'm making a Race map, and I have a Client.lua file in my map folder with this: function ClientStarted () setWaterLevel(-150) end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), ClientStarted ) And I want to know: How can I make a code for to the server blow up the vehicle if that is less than -23 in the position Z
MaddDogg Posted June 23, 2010 Posted June 23, 2010 You have to create a serverside script file with a timer in it, which gets started at resource start. This timer checks every car for its position. If it is at -23 or less, then --> blowVehicle. To get all cars, you can use getElementsByType.
LooooP Posted June 23, 2010 Author Posted June 23, 2010 This would be much easier if the MTA had a system like this: getVehiclePosition
LooooP Posted June 23, 2010 Author Posted June 23, 2010 Oh, ty EDIT: This is what I got to do: function Source setTimer(Check, 5000) function Check () float x, y UnderWater = getElementPosition(vehicle model="411" posX="x" posY="y" posZ="-23") setTimer(BlowUp, 1) function BlowUp () blowVehicle(UnderWater) setTimer(Source, 1) Is it correct?
Maccer. Posted June 23, 2010 Posted June 23, 2010 Just stopping by here: getElementPosition(vehicle model="411" posX="x" posY="y" posZ="-23") is wrong. getElementPosition ( vehicle ) -- vehicle can be retrieved using any getVehicleFrom... or getElement... commands. Is proper.
dzek (varez) Posted June 25, 2010 Posted June 25, 2010 what a mess.. copying-pasting few snippets, few random words and joining them together WON'T work. NEVER. if you want to make anything - sit down, read, spend on it few hours.
SHC//Sniper Posted June 27, 2010 Posted June 27, 2010 Here the code for you NOTE: It's not debugged because I'm too lazy EDIT: If you really want to learn lua download some resources from mtasa.com, try to understand them and read the lua tutorial! EDIT2: There was a mistake @ line 8 getElementPosition but it's fixed now function startBlowTimer() setTimer(checkForPosition, 5000, 0) --set the timer to the interval you want! Now it's 5 sec end function checkForPosition() players = getElementsByType("player") for i, player in ipairs(players) do x, y, killz = getElementPosition(player) if (killz < -23) then veh = getPedOccupiedVehicle(player) blowVehicle(veh) outputChatBox("Your vehicle was blown!", player, 255, 0, 0) end end end addEventHandler("onResourceStart", getRootElement(), startBlowTimer)
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