Jump to content

How to Blow Up player?


LooooP

Recommended Posts

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

Link to comment

Oh, ty :D

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?

Link to comment

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)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...