itHyperoX Posted September 29, 2017 Share Posted September 29, 2017 (edited) Hello. When i click on the "atm", its starting robbing another atm if is not the first. I mean when i clicked on the 3rd ATM, for some reason the player is starting robbing the first one. Whats the problem? local ATMTable = { { ATMName = "1", ATMPosX = 2160.3579101563, ATMPosY = 1685.6997070313, ATMPosZ = 10.69529914856, ATMRotX = 0, ATMRotY = 0, ATMRotZ = 90}, { ATMName = "2", ATMPosX = 2156.099609375, ATMPosY = 1677.83203125, ATMPosZ = 10.6875, ATMRotX = 0, ATMRotY = 0, ATMRotZ = 90}, { ATMName = "3", ATMPosX = 2150.6774902344, ATMPosY = 1683.7536621094, ATMPosZ = 10.8203125, ATMRotX = 0, ATMRotY = 0, ATMRotZ = 90}, } function onStart() for i = 1, #ATMTable do local atmObject = ATMTable[ i ] atmObject["object"] = createObject(2942, atmObject.ATMPosX, atmObject.ATMPosY, atmObject.ATMPosZ, atmObject.ATMRotX, atmObject.ATMRotY, atmObject.ATMRotZ) end end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onStart) playerClicked = 0 addEventHandler("onElementClicked",getRootElement(), function(button, state, player) if button == "left" and state == "down" then for i = 1, #ATMTable do local atmObject = ATMTable[ i ] if (atmObject["object"]) then if ((isElement(atmObject["object"])) and ((getElementType(player)) == "player")) then setElementFrozen(player,true) setPedAnimation(player,"BOMBER","BOM_Plant_Loop",2*30000,true,true,true,false) destroyElement(atmObject["object"]) setTimer(function(player,theShopID) local atmObject = ATMTable[theShopID] setElementFrozen(player,false ) exports.shopRob:addPlayerCashbox(player, 1) setPedAnimation(player,false) end,2*30000,1,player,i) setTimer( function( theShopID ) local atmObject = ATMTable[theShopID] atmObject["object"] = createObject(2942, theATM.ATMPosX, theATM.ATMPosY, theATM.ATMPosZ, theATM.ATMRotX, theATM.ATMRotY, theATM.ATMRotZ) end,2400000,1,i) break end end end end end) Edited September 29, 2017 by TheMOG 1 Link to comment
Moderators IIYAMA Posted September 29, 2017 Moderators Share Posted September 29, 2017 (edited) if isElement(atmObject["object"]) and getElementType(player) == "player" and atmObject["object"] == source then if isElement(atmObject["object"]) and getElementType(player) == "player" and atmObject["object"] == source then You forgot to add this. Note: playerWhoClicked is always a player. > and getElementType(player) == "player" Edited September 29, 2017 by IIYAMA 1 Link to comment
itHyperoX Posted September 29, 2017 Author Share Posted September 29, 2017 (edited) Niiice thank you. One more thing, if isElement(atmObject["object"]) and atmObject["object"] == source then setElementFrozen(player,true) setPedAnimation(player,"BOMBER","BOM_Plant_Loop",2*600,true,true,true,false) destroyedATM = createObject(2943, atmObject.ATMPosX, atmObject.ATMPosY, atmObject.ATMPosZ, atmObject.ATMRotX, atmObject.ATMRotY, atmObject.ATMRotZ) --------- Object if player robbed 1 ATM, setTimer(function(player,theATMID) destroyElement(atmObject["object"]) local atmObject = ATMTable[theATMID] destroyedATM = createObject(2943, atmObject.ATMPosX, atmObject.ATMPosY, atmObject.ATMPosZ, atmObject.ATMRotX, atmObject.ATMRotY, atmObject.ATMRotZ) setElementFrozen(player,false ) setPedAnimation(player,false) end,2*600,1,player,i) setTimer( function( theATMID ) local atmObject = ATMTable[theATMID] atmObject["object"] = createObject(2942, atmObject.ATMPosX, atmObject.ATMPosY, atmObject.ATMPosZ, atmObject.ATMRotX, atmObject.ATMRotY, atmObject.ATMRotZ) destroyElement(destroyedATM) end,11000,1,i) break end I want to add, if player robbed 1 atm, the atm object id is changing, but player can't rob it again until the "timer" is not ending Also, how can i make that, only 1 player can click on the object ? Edited September 29, 2017 by TheMOG Link to comment
itHyperoX Posted September 30, 2017 Author Share Posted September 30, 2017 edit: fixed thank you 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