Maaster Posted March 20, 2021 Posted March 20, 2021 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
Other Languages Moderators androksi Posted March 20, 2021 Other Languages Moderators Posted March 20, 2021 (edited) 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 March 20, 2021 by andr0xy 1
Maaster Posted March 20, 2021 Author Posted March 20, 2021 (edited) 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 March 20, 2021 by Maaster
Other Languages Moderators androksi Posted March 20, 2021 Other Languages Moderators Posted March 20, 2021 Editei o código da minha resposta. 1
Maaster Posted March 20, 2021 Author Posted March 20, 2021 Ainda não esta dando, bom o problema de antes se foi, mas esta igual o script que mandei, só prende se tiver com mais de 5 estrelas, n prende se estiver apenas com o ElementData 'emTrabalhoIlegal'
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now