lucasds Posted July 31, 2019 Share Posted July 31, 2019 (edited) function Assaltar(source) weapon = getPedWeaponSlot(source) mira = getPlayerTarget ( source ) if isElementWithinMarker(source, mAssaltar) then if (weapon == 0) then return Assaltar end if not (getControlState(source, "aim_weapon")) then return Assaltar end if not getElementData(source, "LojaSendoAssaltada") then if ( mira ) then if ( mira ) == pedLojista then setElementData(source, "LojaSendoAssaltada", true) triggerClientEvent(source, "Som", source) triggerClientEvent(root, "notifiAssal", root) setPedAnimation(pedLojista, "shop", "SHP_Rob_HandsUp", 30000, true, true, true ) setElementFrozen(source, true) toggleAllControls(source, false) setPedAnimation(source, "shop", "shp_gun_aim", 30000, true, true, true ) setElementVisibleTo(assalto1PG, root, true) setTimer( function(source) setElementFrozen(source, false) toggleAllControls(source, true) givePlayerMoney(source, 4000) setPedAnimation(source, 0) outputChatBox("#727272Você terminou o assalto e ganhou #ffff00R$4000", source, 255, 255, 255, true) end, 30000, 1) setTimer( function(source) setElementData(source, "LojaSendoAssaltada", false) setElementVisibleTo(assalto1PG, root, false) end, 60000, 1) end end end end end setTimer ( Assaltar, 1, 0 ) Me ajudem a resolver estes erros[20:05:49] WARNING: AssaltoLoja\assaltoS.Lua:62: Bad argument @ 'getPedWeaponSlot' [Expected ped at argument 1, got nil] [20:05:49] WARNING: AssaltoLoja\assaltoS.Lua:63: Bad argument @ 'getPlayerTarget' [Expected ped at argument 1, got nil] [20:05:49] WARNING: AssaltoLoja\assaltoS.Lua:64: Bad argument @ 'isElementWithinMarker' [Expected element at argument 1, got nil] Edited August 1, 2019 by Lord Henry Código adicionado com a formatação Lua Link to comment
DNL291 Posted August 1, 2019 Share Posted August 1, 2019 Movido para Portuguese / Português > Programação em Lua @LucasDSNL Link to comment
Other Languages Moderators Lord Henry Posted August 1, 2019 Other Languages Moderators Share Posted August 1, 2019 source não existe dentro de um setTimer. Ou você salva ele em outra variável ou então você passa ele por parâmetro de função do setTimer. Está faltando o resto do código. Mas vou supor que esse setTimer esteja dentro de outra função onde o source exista. Se não estiver dentro de outra função com source, então seu código nunca vai funcionar e não faz sentido nenhum. function Assaltar (theSource) weapon = getPedWeaponSlot (theSource) mira = getPlayerTarget (theSource) if (isElementWithinMarker (theSource, mAssaltar)) then if (weapon == 0) then return Assaltar end if not (getControlState (theSource, "aim_weapon")) then return Assaltar end if not (getElementData (theSource, "LojaSendoAssaltada")) then if (mira) then if ((mira) == pedLojista) then setElementData (theSource, "LojaSendoAssaltada", true) triggerClientEvent (theSource, "Som", theSource) triggerClientEvent (root, "notifiAssal", root) setPedAnimation (pedLojista, "shop", "SHP_Rob_HandsUp", 30000, true, true, true) setElementFrozen (theSource, true) toggleAllControls (theSource, false) setPedAnimation (theSource, "shop", "shp_gun_aim", 30000, true, true, true) setElementVisibleTo (assalto1PG, root, true) setTimer (function (otherSource) setElementFrozen (otherSource, false) toggleAllControls (otherSource, true) givePlayerMoney (otherSource, 4000) setPedAnimation (otherSource, 0) outputChatBox ("Você terminou o assalto e ganhou #ffff00R$4000", otherSource, 114, 114, 114, true) end, 30000, 1, theSource) setTimer (function (otherSource) setElementData (otherSource, "LojaSendoAssaltada", false) setElementVisibleTo (assalto1PG, root, false) end, 60000, 1, theSource) end end end end end setTimer (Assaltar, 1, 0, source) 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