Pedro Silveira Posted December 3, 2017 Share Posted December 3, 2017 Hello, i'm new in MTA Scripts and i trying to make something like this: function verificar2 () if ( getElementPosition( robmarker1 ) == 3099.97, -3281.69, -0.5 ) then outputChatBox("Esta loja ainda está recuperando-se de um assalto!", l_5_0, 0, 255, 0) else outputChatBox("Digite /roubar para furtar a loja!", l_5_0, 0, 255, 255) end end But this don't work. I use the "verificar2" in this part of code: setTimer(verificar2, 2000, 1, l_7_0) And here the full code for more informations: -------------------- Loja AmmuNation de São Paulo -------------------- local Exitdoorrob1 = createMarker(285.84375, -86.7724609375, 1002.2, "arrow", 1.5, 255, 255, 0, 255) setElementInterior(Exitdoorrob1, 4) setElementDimension(Exitdoorrob1, 1) local Doorentryrob1 = createMarker(1368.890625, -1279.787109375, 14.546875, "arrow", 1.5, 255, 255, 0, 255) createBlipAttachedTo(Doorentryrob1, 17, 2, 0, 255, 0, 0, 0, 7000) local robmarker1 = createMarker(295.5595703125, -80.40859375, 1000.515625, "cylinder", 1.2, 255, 10, 10, 255) setElementInterior(robmarker1, 4) setElementDimension(robmarker1, 1) function verificar ( thePlayer ) if ( getElementInterior( thePlayer ) == 4 ) then givePlayerMoney( thePlayer, 10000 ) else outputChatBox("Você saiu da loja e o dinheiro foi devolvido!", l_5_0, 255, 0, 0) end end function verificar2 () if ( getElementPosition( robmarker1 ) == 3099.97, -3281.69, -0.5 ) then outputChatBox("Esta loja ainda está recuperando-se de um assalto!", l_5_0, 0, 255, 0) else outputChatBox("Digite /roubar para furtar a loja!", l_5_0, 0, 255, 255) end end duty1 = function(l_5_0, l_5_1) if isElementWithinMarker(l_5_0, robmarker1) then setPlayerWantedLevel(l_5_0, 6) triggerClientEvent(root, "playTheSound1", root, l_5_0) outputChatBox("O caixa está colocando o dinheiro na sacola! Aguarde até ele terminar!", l_5_0, 0, 255, 0) outputChatBox("#DF0101[Alarme]: #FF8C00O Meliante " .. getPlayerName(l_5_0) .. " #FF8C00está assaltando a #DF0101Ammu Nation!", root, 255, 255, 255, true) setElementPosition(robmarker1, 3099.97, -3281.69, -0.5) setMarkerSize(Exitdoorrob1, 0) local blip2 = createBlipAttachedTo(Doorentryrob1, 20, 2, 0, 255, 0, 0, 0, 7000) setTimer(triggerClientEvent, 21000, 1, root, "playTheSound1", root, l_5_0) setTimer(triggerClientEvent, 42000, 1, root, "playTheSound1", root, l_5_0) setTimer(triggerClientEvent, 63000, 1, root, "playTheSound1", root, l_5_0) setTimer(setElementPosition, 300000, 1, robmarker1, 295.5595703125, -80.40859375, 1000.515625) setTimer(setMarkerSize, 90000, 1, Exitdoorrob1, 1.5) setTimer(verificar, 90000, 1, l_5_0) setTimer(destroyElement, 300000, 1, blip2) else outputChatBox("", source, 255, 0, 0) end end addCommandHandler("roubar", duty1) Exitdrob1 = function(l_6_0) if source == Exitdoorrob1 and getElementType(l_6_0) == "player" then fadeCamera(l_6_0, false, 1, 0, 0, 0) setTimer(fadeCamera, 1000, 1, l_6_0, true, 1) setTimer(setElementRotation, 1000, 1, l_6_0, 0, 0, 90) setTimer(setElementInterior, 1000, 1, l_6_0, 0, 1366.744140625, -1279.75, 13.546875) setTimer(setElementDimension, 1000, 1, l_6_0, 0) end end addEventHandler("onMarkerHit", getRootElement(), Exitdrob1) Doorerob1 = function(l_7_0) if source == Doorentryrob1 and getElementType(l_7_0) == "player" then fadeCamera(l_7_0, false, 1, 0, 0, 0) setTimer(setElementRotation, 1000, 1, l_7_0, 0, 0, 90) setTimer(fadeCamera, 1000, 1, l_7_0, true, 1) setTimer(setElementInterior, 1000, 1, l_7_0, 4, 285.689453125, -84.826171875, 1001.515625) setTimer(setElementDimension, 1000, 1, l_7_0, 1) setTimer(verificar2, 2000, 1, l_7_0) end end addEventHandler("onMarkerHit", getRootElement(), Doorerob1) Please help me! Thanks for everybody! Link to comment
Bonus Posted December 3, 2017 Share Posted December 3, 2017 (edited) 1. You should use good names for the variables. I see 1_7_0 etc. everywhere, isn't that confusing? 2. You can compare getElementPosition (which returns 3 values) with numbers like that. If you want to compare them, you have to do it one by one. 3. Don't check the position like that, cause if the player is 0.01 x away from the position, it won't work. Use getDistanceBetweenPoints3D instead.https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPoints3D The distance should be smaller than 2+, whatever you want. But not too less. Edited December 3, 2017 by Bonus Link to comment
Moderators IIYAMA Posted December 3, 2017 Moderators Share Posted December 3, 2017 (edited) 1. @Bonus Names like 1_7_0 are a remaining of a decompiled script. Because when a script is compiled all variables names are lost. A decompiler will assign names like that to make it work again. Edited December 3, 2017 by IIYAMA 1 Link to comment
Pedro Silveira Posted December 3, 2017 Author Share Posted December 3, 2017 Sorry but i don't understand what you said Bonus. As i said before, i new in mta scripts. Quote You should use good names for the variables.I see 1_7_0 etc. everywhere, isn't that confusing? That script i catched from the internet. But is a bad script and i trying to upgrade her, so i don't care for the variables. Quote 2. You can compare getElementPosition (which returns 3 values) with numbers like that.If you want to compare them, you have to do it one by one. I really don't know how to do this. You can make for me please? Quote 3. Don't check the position like that, cause if the player is 0.01 x away from the position, it won't work. Use getDistanceBetweenPoints3D instead.https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPoints3D The distance should be smaller than 2+, whatever you want. But not too less. That script is made for players can robb the shops i selected in the map, so the position can be checked this way because i testing the position of a marker and don't a position of a player, and this marker only stay in two positions: 1 - On the position for player can robb the shop. 2 - A position when the player robbed the shop. So i guess its not necessary use the getDistanceBetweenPoints3D. Thank you. Link to comment
Bonus Posted December 3, 2017 Share Posted December 3, 2017 Still use getDistanceBetweenPoints3D. 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