Jump to content

Prender jogador ao matar


Recommended Posts

O Mod funcionava assim, se o jogador que o policial matou tive-se 5 estrelas de procurado ou mais, ele seria preso, até ai o mod funciona normalmente, agora estou tentando configurar pra quando um policial matar um jogador e se ele estiver com o ElementData 'emTrabalhoIlegal' ser preso tambem. Ai esta meu codigo:

Spoiler

function player_Wasted ( ammo, attacker, bodypart )
	if ( attacker ) then
		local tempString
		if ( getElementType ( attacker ) == "player" ) then
			if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(attacker)), aclGetGroup("Policia")) then
				if getPlayerWantedLevel(source) >= 5 then
					if isPedInVehicle(source) then
						removePedFromVehicle(source)
					end
					setElementDimension(source, 45)
					setElementInterior(source, unpack(Cadeias[math.random(#Cadeias)]) )
					setElementData(source, "preso", true)
					setElementData(rRoot,""..getPlayerSerial(source).."-j",true)
					setPedAnimation(source,"SMOKING", anims[math.random(#anims)])
					setElementData(source,"rendido", false)
					givePlayerMoney(attacker, 12500)
					outputChatBox("[#0000FF PM #000000]#FFFFFF Voce foi morto por um policial e foi preso, estava com mais de 5 estrelas e foi preso!", source, 0, 0, 0, true)
					outputChatBox("[#0000FF PM #000000]#FFFFFF Quando todas suas estrelas de procurados sumirem, voce saira da prisao, cada uma vale por 1 minuto!", source, 0, 0, 0, true)
					outputChatBox("[#0000FF PM #000000]#FFFFFF O Jogador "..getPlayerName(source).."#FFFFFF morreu, estava com o level de procurado muito alto e foi preso!", root, 0, 0, 0, true)
					outputChatBox("[#0000FF PM #000000]#FFFFFF Voce recebeu #00FF00R$12.500#FFFFFF por matar um jogador com 5 ou mais estrelas, e ele foi preso!", attacker, 0, 0, 0, true)
				elseif getElementData(source,"emTrabalhoIlegal") then
					if isPedInVehicle(source) then
						removePedFromVehicle(source)
					end
					setElementDimension(source, 45)
					setElementInterior(source, unpack(Cadeias[math.random(#Cadeias)]) )
					setElementData(source, "preso", true)
					setElementData(rRoot,""..getPlayerSerial(source).."-j",true)
					setPedAnimation(source,"SMOKING", anims[math.random(#anims)])
					setElementData(source,"rendido", false)
					givePlayerMoney(attacker, 15000)
					outputChatBox("[#0000FF PM #000000]#FFFFFF Voce foi morto por um policial, estava trabalhando ilegalmente e foi preso!", source, 0, 0, 0, true)
					outputChatBox("[#0000FF PM #000000]#FFFFFF Quando todas suas estrelas de procurados sumirem, voce saira da prisao, cada uma vale por 1 minuto!", source, 0, 0, 0, true)
					outputChatBox("[#0000FF PM #000000]#FFFFFF O Jogador "..getPlayerName(source).."#FFFFFF morreu, estava trabalhando ilegalmente e foi preso!", root, 0, 0, 0, true)
					outputChatBox("[#0000FF PM #000000]#FFFFFF Voce recebeu #00FF00R$15.000#FFFFFF por matar um jogador que estava trabalhando ilegalmente!", attacker, 0, 0, 0, true)
				end
			end
		end
	end
end
addEventHandler ( "onPlayerWasted", root, player_Wasted )

 

N acontece nenhum erro ou warning no debugscript, pra mim parece que o codigo esta certo, mas n esta funcionando

Link to comment
  • Other Languages Moderators

Olá.

Veja se funciona. Fiz uma função para evitar código duplicado e também uma lógica para mostrar qual foi o motivo da prisão.

Spoiler

function sendPlayerToJail(officer, bandit, reason)
    if isPedInVehicle(bandit) then
        removePedFromVehicle(bandit)
    end

    givePlayerMoney(officer, 12500)

    setElementDimension(bandit, 45)
    setElementInterior(bandit, unpack(Cadeias[math.random(#Cadeias)]) )
    setElementData(bandit, "preso", true)
    setElementData(rRoot,""..getPlayerSerial(bandit).."-j",true)
    setPedAnimation(bandit,"SMOKING", anims[math.random(#anims)])
    setElementData(bandit,"rendido", false)

    outputChatBox("[#0000FF PM #000000]#FFFFFF Voce foi morto por um policial, " .. reason, bandit, 0, 0, 0, true)
    outputChatBox("[#0000FF PM #000000]#FFFFFF Quando todas suas estrelas de procurados sumirem, voce saira da prisao, cada uma vale por 1 minuto!", bandit, 0, 0, 0, true)
    outputChatBox("[#0000FF PM #000000]#FFFFFF O Jogador "..getPlayerName(bandit).."#FFFFFF morreu, " .. reason, root, 0, 0, 0, true)
    outputChatBox("[#0000FF PM #000000]#FFFFFF Voce recebeu #00FF00R$12.500#FFFFFF por matar um jogador que " .. reason, officer, 0, 0, 0, true)
end

function player_Wasted ( ammo, attacker, bodypart )
    if ( attacker ) then
        local tempString
        if ( getElementType ( attacker ) == "player" ) then
            if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(attacker)), aclGetGroup("Policia")) then
                local wantedLevel = getPlayerWantedLevel(source)
                local illegalJob = getElementData(source, "emTrabalhoIlegal")
                if wantedLevel < 5 and illegalJob == false then return false end

                --[[
                    Aqui é o seguinte:
                    Caso (wantedLevel >= 5 and illegalJob == false) for verdadeiro, isto é, se o jogador estiver com 5 estrelas e NÃO estiver no trabalho ilegal,
                    então iremos mostrar a mensagem "estava com mais de 5 estrelas e foi preso!".

                    Caso seja falso, isto é, se o jogador estiver com 5 estrelas, mas também ESTIVER NUM TRABALHO ILEGAL, então mostraremos "estava em trabalho ilegal e foi preso!"
                ]]
                local reason = (wantedLevel >= 5 and illegalJob == false) and
                "estava com mais de 5 estrelas e foi preso!" or
                "estava em trabalho ilegal e foi preso!"

                sendPlayerToJail(attacker, source, reason)
            end
        end
    end
end
addEventHandler ( "onPlayerWasted", root, player_Wasted )

 

 

Edited by andr0xy
  • Like 1
Link to comment
54 minutes ago, andr0xy said:

Olá.

Veja se funciona. Fiz uma função para evitar código duplicado e também uma lógica para mostrar qual foi o motivo da prisão.

  Hide contents




function sendPlayerToJail(officer, bandit, reason)
    if isPedInVehicle(bandit) then
        removePedFromVehicle(bandit)
    end

    givePlayerMoney(officer, 12500)

    setElementDimension(bandit, 45)
    setElementInterior(bandit, unpack(Cadeias[math.random(#Cadeias)]) )
    setElementData(bandit, "preso", true)
    setElementData(rRoot,""..getPlayerSerial(bandit).."-j",true)
    setPedAnimation(bandit,"SMOKING", anims[math.random(#anims)])
    setElementData(bandit,"rendido", false)

    outputChatBox("[#0000FF PM #000000]#FFFFFF Voce foi morto por um policial, " .. reason, bandit, 0, 0, 0, true)
    outputChatBox("[#0000FF PM #000000]#FFFFFF Quando todas suas estrelas de procurados sumirem, voce saira da prisao, cada uma vale por 1 minuto!", bandit, 0, 0, 0, true)
    outputChatBox("[#0000FF PM #000000]#FFFFFF O Jogador "..getPlayerName(bandit).."#FFFFFF morreu, " .. reason, root, 0, 0, 0, true)
    outputChatBox("[#0000FF PM #000000]#FFFFFF Voce recebeu #00FF00R$12.500#FFFFFF por matar um jogador que " .. reason, officer, 0, 0, 0, true)
end

function player_Wasted ( ammo, attacker, bodypart )
    if ( attacker ) then
        local tempString
        if ( getElementType ( attacker ) == "player" ) then
            if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(attacker)), aclGetGroup("Policia")) then
                local wantedLevel = getPlayerWantedLevel(source)
                local illegalJob = getElementData(source, "emTrabalhoIlegal")

                --[[
                    Aqui é o seguinte:
                    Caso (wantedLevel >= 5 and illegalJob == false) for verdadeiro, isto é, se o jogador estiver com 5 estrelas e NÃO estiver no trabalho ilegal,
                    então iremos mostrar a mensagem "estava com mais de 5 estrelas e foi preso!".

                    Caso seja falso, isto é, se o jogador estiver com 5 estrelas, mas também ESTIVER NUM TRABALHO ILEGAL, então mostraremos "estava em trabalho ilegal e foi preso!"
                ]]
                local reason = (wantedLevel >= 5 and illegalJob == false) and
                "estava com mais de 5 estrelas e foi preso!" or
                "estava em trabalho ilegal e foi preso!"

                sendPlayerToJail(attacker, source, reason)
            end
        end
    end
end
addEventHandler ( "onPlayerWasted", root, player_Wasted )

 

 

Não deu certo, mesmo se o jogador estiver com 0 estrelas e fora do trabalho, ao morrer ele é preso

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