Deniel Posted September 25, 2019 Share Posted September 25, 2019 function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) if not( isGuestAccount (getPlayerAccount(source)) ) then local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) fadeCamera (source, false) setTimer (spawnPlayer, 1000, 1, source, 1158.344, -1293.679, 16.445, 0, getPedSkin (source), 0, 0, getPlayerTeam(source)) setTimer (setCameraTarget, 1250, 1, source, source) setTimer (fadeCamera, 2000, 1, source, true) setTimer (takeAllWeapons, source, true) setTimer (setPlayerWantedLevel, thePlayer,0, true) end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) Link to comment
Gaimo Posted September 25, 2019 Share Posted September 25, 2019 linha 10 troca thePlayer para source. Link to comment
DNL291 Posted September 25, 2019 Share Posted September 25, 2019 Use /debugscript para mostrar os erros, thePlayer não está definido. Movido para Portuguese / Português @Deniel (postá lá da próxima vez) 1 Link to comment
Other Languages Moderators Lord Henry Posted September 25, 2019 Other Languages Moderators Share Posted September 25, 2019 (edited) Linhas 9 e 10 estão erradas. Vc está pulando os parâmetros do setTimer. Você fez certo nas linhas 6, 7 e 8. Faça como fez nelas. Edited September 25, 2019 by Lord Henry 1 Link to comment
joao2235 Posted September 25, 2019 Share Posted September 25, 2019 (edited) function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) local ContaDoPlayer = getPlayerAccount ( source ) if not (isGuestAccount ( ContaDoPlayer ) then local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) takeAllWeapons(source) setPlayerWantedLevel(source, 0) setTimer (spawnPlayer, 1000, 1, source, 1158.344, -1293.679, 16.445, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) fadeCamera ( source, false, 0, 0, 0, 0 ) setTimer ( fadeCamera, 2000, 1, source , true, 0.5 ) setTimer ( setCameraTarget, 1250, 1, source ) end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) Acho que isso resolve seus problemas irmão! (Não testei) Edited September 25, 2019 by joao2235 Link to comment
kevincouto6 Posted September 25, 2019 Share Posted September 25, 2019 function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) local ContaDoPlayer = getPlayerAccount ( source ) if (isGuestAccount ( ContaDoPlayer ) then --deixe em branco else local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) takeAllWeapons(source) setPlayerWantedLevel(source, 0) setTimer (spawnPlayer, 1000, 1, source, 1158.344, -1293.679, 16.445, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) fadeCamera ( source, false, 0, 0, 0, 0 ) setTimer ( fadeCamera, 2000, 1, source , true, 0.5 ) setTimer ( setCameraTarget, 1250, 1, source ) end end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) Olá, costumo sempre pedir ajuda aqui, e em um dos meus posts, me recomendaram evitar o uso de if not, então use else assim quando não estiver, vai funcionar. Ouvi isso faz algum tempo espero que tenha ajudado. Alguem com mais experiência pode confirmar oq eu falei para ter certeza.... 1 Link to comment
Other Languages Moderators Lord Henry Posted September 25, 2019 Other Languages Moderators Share Posted September 25, 2019 (edited) @kevincouto6 Vc interpretou errado. Você deve ter ouvido "evite condição de negação no if" isto é, evitar quando possível. Neste caso isolado, a diferença de processamento é irrelevante. Você deve manter do jeito que estava. Por exemplo: function isEvenNumber (thePlayer, cmd, number) local number = tonumber (number) local par = number/2 if (math.floor (par) == par) then outputChatBox ("Número par.", thePlayer) elseif not (math.floor (par) == par) then -- Poderia ser somente else, ou então usar ~= (diferente de) no lugar do == (igual a) outputChatBox ("Número ímpar.", thePlayer) end end addCommandHandler ("par", isEvenNumber) Edited September 25, 2019 by Lord Henry 1 Link to comment
Other Languages Moderators Lord Henry Posted September 25, 2019 Other Languages Moderators Share Posted September 25, 2019 (edited) Neste caso, para otimizar daria pra fazer ele simplesmente cancelar tudo antes da parte que interessa, dessa forma: function onWasted (totalAmmo, killer, killerWeapon, bodypart, stealth) local ContaDoPlayer = getPlayerAccount (source) if (isGuestAccount (ContaDoPlayer)) then return end -- Se for guest, cancela a função e não passa daqui. local theWeapon = getPedWeapon (source) local weaponAmmo = getPedTotalAmmo (source) takeAllWeapons (source) setPlayerWantedLevel (source, 0) setTimer (spawnPlayer, 1000, 1, source, 1158.344, -1293.679, 16.445, 0, getElementModel (source), 0, 0, getPlayerTeam(source)) fadeCamera (source, false, 0, 0, 0, 0) setTimer (fadeCamera, 2000, 1, source , true, 0.5) setTimer (setCameraTarget, 1250, 1, source) end addEventHandler ("onPlayerWasted", root, onWasted) Edited September 25, 2019 by Lord Henry 1 Link to comment
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