Jump to content

drive over peds


Recommended Posts

  • Moderators
15 minutes ago, Tekken said:

How can I do that they tumbles down?

You could disable the collision between the car and ped for 1 or 2 frames after you ram it.

https://wiki.multitheftauto.com/wiki/OnClientVehicleCollision

https://wiki.multitheftauto.com/wiki/SetElementCollidableWith

 

This way it could be more easy to ran them over.

Edited by IIYAMA
Link to comment
  • Scripting Moderators
47 minutes ago, Tekken said:

So in my server I have a lots of peds but when I try to drive them over they do nothing but blocking the car.

How can I do that they tumbles down?

Other solution, you might try to use animation when they got hit by car. (onClientPedDamage)

Link to comment

@majqq What about the peds that are managed by slothbot? As those ones have continuos animations and those interpolates.

@IIYAMA I don't see how this will work? I tried like this but that does nothing besides letting the ped pass through the vehicle for a fraction of a second.

addEventHandler("onClientVehicleCollision", root, function(hitElement)
	if hitElement and getElementType(hitElement) == "ped" then
		setElementCollidableWith(source, hitElement, false);
		setTimer(setElementCollidableWith, 1000, 1, source, hitElement, true);
	end
end);

 

Hold on, it may be because I have canceled the event onClientPedDamage could it?

Yes indeed this was a misconception of onClientPedDamage thank you guys anyway!

Link to comment
  • Moderators
1 hour ago, Tekken said:

I don't see how this will work? I tried like this but that does nothing besides letting the ped pass through the vehicle for a fraction of a second.

1 second is a lot of frames. Too many to be honest, it loses it's purpose if you do that. The whole purpose is to slowly push those peds aside, instead of blocking.

NOTE: This is still a concept, there are no guarantees that it will work.

 

You can use my callNextFrame function if you want. source


--[[
	-- callNextFrame function
]]
local tableRemove = table.remove
local serverSide = triggerClientEvent and true or false

do
	
	local nextFrameCalls = {}
	
	local serverSideTimer
	

	local processing = false
	
	local function process ()
		
		--[[ 
			Do an empty check at the beginning of the function, this will make sure to make an extra run in case of heavy work load. 
			If the timer is killed or the addEventHandler is removed, then this has to be re-attached again every frame. This is not very healthy...
		]]
		
		if #nextFrameCalls == 0 then
			if serverSide then
				if serverSideTimer then
					
					if isTimer(serverSideTimer) then
						killTimer(serverSideTimer)
					end
					serverSideTimer = nil
					
				end
			else
				removeEventHandler("onClientRender", root, process)
			end
			
			processing = false
			return
		end
		
		
		-- In case of calling the function callNextFrame within the process, the loop type `repeat until` is required.
		repeat
			local item = nextFrameCalls[1]
			item.callback(unpack(item.content))
			tableRemove(nextFrameCalls, 1)
		until #nextFrameCalls == 0

	end
	
	
	
	function callNextFrame (callback, ...)
		if type(callback) == "function" then
			local newIndex = #nextFrameCalls + 1
			nextFrameCalls[newIndex] = {callback = callback, content = {...}}
			if not processing then
				if serverSide then
					serverSideTimer = setTimer(process, 50, 0)
				else
					addEventHandler("onClientRender", root, process)
				end
				processing = true
			end
			return true
		end
		return false
	end
end

 

 

 

 

 

 

Edited by IIYAMA
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...