Sign in to follow this  
Gabriel1375

[HELP]Cannot return Killer's name

Recommended Posts

Hello, i was making a blip event system, where the staff give a /eventoblip command, then a blip will be created above him on the MAP (F11), and when anonyone kills him it returns a message, then show the killer name for everyone in the server by outputchatbox, and give the killer items...

I'm currently using mta dayz gamemode, the most part of the script is working perfectly fine, my error is:

The script identify if the admin killed himself or if anyone killed the admin, but it doesn't identify the killer's name / account...

It doesn't give the killer items and doesn't give the killer's name...

 

The script:

--function blip has paremeter: theplayer
function blip (thePlayer)
--variable accountname receive the value of the getaccountname of the player, to see the player login
accountname = getAccountName(getPlayerAccount(thePlayer))
--if the player who triggered the blip function is a supermoderator or an admin then
if isObjectInACLGroup("user." .. accountname, aclGetGroup("SuperModerator")) or isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then
	--output the message "special event - kill the adm identified as a $ on the map, the winner will get random items"
	outputChatBox ('#00BFFF==============================================================',getRootElement(),255,255,255,true)
    outputChatBox ('#00BFFF【 EVENTO ESPECIAL! 】#FFFFFF Mate o ADM identificado com o #098700cifrão ($) verde no mapa',getRootElement(),255,255,255,true)
	outputChatBox ('#FFFFFFO vencedor ganhará itens aleátorios!',getRootElement(),255,255,255,true)
	outputChatBox ('#00BFFF==============================================================',getRootElement(),255,255,255,true)
	--attach a "$" blip to the admin or supermod who started the event 
	blip = createBlipAttachedTo (thePlayer,52,10)
	--set the admin data blood to 100
	setElementData(thePlayer, "blood",100)
	--set the admin data blip event to true
	setElementData(thePlayer, "eventoblip",true)
	--set the max slots of the admin backpack to 350
	setElementData(thePlayer, "MAX_Slots",350)
end
end
--add the command /eventoblip that triggers the function blip
addCommandHandler("eventoblip", blip)

--table that determine what items the player will be given
local itens = {
{"Banana"},
{"Kiwi"},
{"Pizza"}
}

--function that calculates the size of the table itens above
function tamanho( tabela )
  local count = 0
  for a in pairs( tabela ) do 
    count = count + 1 
  end
  return count 
end

-- function endevent has parameters: ammo, attacker, weapon, bodypart
function fimdoevento(ammo, killer, weapon, bodypart)
	local getData = getElementData ( source, "eventoblip" )
	
	-- quando o cara morrer , se o cara for o que tiver iniciado o evento, e  o evento ainda tiver rolando
	if getData then
	
		-- se tiver um assassino entao
		if killer then
		local item = itens[math.random(tamanho(itens))][1]
		local quantidade = 1
		destroyElement(blip)
		setElementData(source, "eventoblip",false)
		setElementData(killer, item , quantidade)
		setElementData(source, item, quantidade)
		outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
		outputChatBox ('#00a5ff GETDATA TRUE',getRootElement(),255,255,255,true)
        outputChatBox ("#00a5ff Parabéns [#FF0000" .. getPlayerName(killer) .. "#00a5ff] matou o Staff e ganhou [#ff0000 "..quantidade.."x "..item.."#00a5ff]!",getRootElement(),255,255,255,true)
		outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
			else
			destroyElement(blip)
			setElementData(source, "eventoblip",false)
			outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
			outputChatBox ('#00a5ff O Staff #FF0000' .. getPlayerName(source) .. ' #00a5ff se matou, o evento irá reiniciar',getRootElement(),255,255,255,true)
			outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
		end
		
	
		
	end
end

--add an event handler of type onplayerwasted, that triggers the fimdoevento (translating: endevent) function
addEventHandler("onPlayerWasted", getRootElement(), fimdoevento)

function finalizarevento(thePlayer)
local pegaData = getElementData ( thePlayer, "eventoblip" )
accountname = getAccountName(getPlayerAccount(thePlayer))

	if isObjectInACLGroup("user." .. accountname, aclGetGroup("SuperModerator")) or isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then
		if pegaData then
			destroyElement(blip)
			setElementData(thePlayer, "eventoblip",false)
			removeElementData(thePlayer,"eventoblip")
			outputChatBox ('#00BFFF==============================================================',getRootElement(),255,255,255,true)
			outputChatBox ('#FF0000【 ATENÇÃO! 】#FFFFFF O Staff finalizou o evento.',getRootElement(),255,255,255,true)
			outputChatBox ('#FFFFFFO ele explicará o motivo em breve!',getRootElement(),255,255,255,true)
			outputChatBox ('#00BFFF==============================================================',getRootElement(),255,255,255,true)
			setElementData(thePlayer, "blood",12000)
			setElementData(thePlayer, "MAX_Slots",350)
		else
			outputChatBox ('#FFFFFFO Evento não está acontecendo !!!',thePlayer,255,255,255,true)
		end
	end
end

addCommandHandler("finalizareventoblip", finalizarevento)

 

The meta.xml:

<meta>
    <info author="Gabriel Bigardi" version="1.0" type="script" name="BLIP event"/>
    <script src="blip.lua" type="server" />
</meta>

 

 

Thanks !!!

Share this post


Link to post

1. consider vehicles:

  • killer: an element representing the player or vehicle who was the killer. If there was no killer this is false.

2. Any errors? How do you know that the scripts doesn't identify the killers name?

Share this post


Link to post

Replace the function 'fimdoevento' with this:


function fimdoevento(ammo, killer, weapon, bodypart)
	local getData = getElementData ( source, "eventoblip" )
	
	-- quando o cara morrer , se o cara for o que tiver iniciado o evento, e  o evento ainda tiver rolando
	if getData and killer and killer ~= source then
		local killerName = getElementType(killer) == "player" and getPlayerName(killer) or false
		if not ( killerName ) then
			killerName = getElementType(killer) == "vehicle" and getVehicleController(killer) or false
		end
		if type(killerName) ~= "string" then stopEvent( source ) return end
		
		local item = itens[math.random(tamanho(itens))][1]
		local quantidade = 1
		destroyElement(blip)
		setElementData(source, "eventoblip",false)
		setElementData(killer, item , quantidade)
		setElementData(source, item, quantidade)
		outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
		outputChatBox ('#00a5ff GETDATA TRUE',getRootElement(),255,255,255,true)
		outputChatBox ("#00a5ff Parabéns [#FF0000" .. getPlayerName(killer) .. "#00a5ff] matou o Staff e ganhou [#ff0000 "..quantidade.."x "..item.."#00a5ff]!",getRootElement(),255,255,255,true)
		outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
	else
		stopEvent( source )
	end
end

function stopEvent( p )
	destroyElement(blip)
	setElementData(p, "eventoblip",false)
	outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
	outputChatBox ('#00a5ff O Staff #FF0000' .. getPlayerName(p) .. ' #00a5ff se matou, o evento irá reiniciar',getRootElement(),255,255,255,true)
	outputChatBox ('#00a5ff==============================================================',getRootElement(),255,255,255,true)
end

If it didn't work, type /debugscript 3 to make sure there are no errors in the code. Also, debug each value from your code, like killer, item and getData.

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.