Jump to content
  • 0

Ped's behavior strange bug


JeViCo

Question

I found a strange bug. I created ped server-side. It starts to shoot me but i don't get any bullet damage. Well, that's okay. The main problem is here: i created ped again and minimised MTA. Ped killed me like GTA:SA single player ped. Sooo what is that? I get damage only if i close to ped or MTA client minimised

Link to comment

4 answers to this question

Recommended Posts

  • 0

client:

local ped_ = {} 
local peds = { 
{0, 2, 2}, 
{0, 4, 2}, 
{0, 6, 2}, 
} 

function findRotation( x1, y1, x2, y2 ) 
    local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) )
    return t < 0 and t + 360 or t
end

function spawnPed(i)
	ped_[i] = triggerServerEvent("createPed",localPlayer,math.random(26,41),peds[i][1],peds[i][2],peds[i][3],i)
end

addEventHandler("onClientResourceStart",resourceRoot,function()
	for i=1,#peds do 
		spawnPed(i)
	end
end)

function atirar ()
	if source then
		if getElementData(source,"ped:custom_ped") then
			ped = source
			givePedWeapon(ped, 31, 500, true) 
			setPedControlState(ped, "fire", true)
		end
	end
end
addEvent ("pedAtira", true)
addEventHandler("onClientPedDamage", root, atirar)
--addEventHandler ("pedAtira", getRootElement(), atirar)

function stopatirar ()
	for _, ped in ipairs(getElementsByType("ped")) do
		if getElementData(ped,"ped:custom_ped") then
			if isElementStreamedIn (ped) then
				givePedWeapon(ped, 31, 500, false) 
				setPedControlState(ped, "fire", false)
			end
		end
	end
end
addEvent ("stopPedatira", true)
addEventHandler ("stopPedatira", getRootElement(), stopatirar)

function handleRespawn()
	if getElementData(source,"ped:custom_ped") then
		index = getElementData(source,"ped:index")
		setTimer(destroyElement, 1000, 1, source) 
		setTimer(spawnPed, 1500, 1, index)
	end
end
addEventHandler("onClientPedWasted", getRootElement(), handleRespawn)

function rota ()
	for _, ped in pairs(getElementsByType("ped")) do
		if getElementData(ped,"ped:custom_ped") then
			if isElementStreamedIn (ped) then
				local x1 ,y1, z1 = getElementPosition(ped) 
				local x2, y2, z2 = getElementPosition(localPlayer)
				setPedAimTarget(ped, x2, y2, z2)
				setElementRotation(ped, 0,0,180+findRotation( x2, y2, x1, y1 ))
			end
		end
	end
end
addEventHandler("onClientRender", root, rota)

server:

addEvent("createPed",true)
addEventHandler("createPed",getRootElement(),function(skin,x,y,z,i)
	ped = createPed(skin,x,y,z,0,true)
	setElementData(ped,"ped:custom_ped",true)
  	setElementData(ped,"ped:index",i)
end)

you can this code test too. Just

 

21 hours ago, myonlake said:

I am not able to reproduce this in Multi Theft Auto v1.5.5-release-13804. What is your MTA version and have you tried running the latest nightly? Perhaps it's a bug in your code.

i don't know where to see my version, but i know that server and client have 1.5.5 version (after animations release)

Link to comment
  • 0
4 minutes ago, myonlake said:

You can see your MTA:SA client version by typing the "ver" command into the F8 console. Same goes for the server console.

client: Multi Theft Auto v1.5.5-release-12411

server: Multi Theft Auto v1.5.5-release-12240

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...