JanKy Posted January 3, 2017 Share Posted January 3, 2017 Hello guys ! Im working on a dayz server , and im still learning lua. And i have a problem with a vip system. Here is the code : function givepackvip (thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("vip")) then setElementData(thePlayer, "M4A1 CCO SD", 1) setElementData(thePlayer, "M4A1 CCO SD Mag", 150) setElementData(thePlayer, "M4A03", 1) setElementData(thePlayer, "M4A03 Mag", 69) setElementData(thePlayer, "Veteran Backpack", 1) setElementData(thePlayer, "MP5A5", 1) setElementData(thePlayer, "MP5A5 Mag", 150) setElementData(thePlayer, "Binoculars", 1) setElementData(thePlayer, "Burger", 3) setElementData(thePlayer, "Canteen", 3) setElementData(thePlayer, "Morphine", 2) setElementData(thePlayer, "Medical Supplies", 2) setElementData(thePlayer, "Ghillie Suit Ghost", 1) setElementData(thePlayer, "Map", 1) setElementData(thePlayer, "GPS", 1) setElementData(thePlayer, "Toolbox", 1) setElementData(thePlayer, "Infrared Googles", 1) setElementData(thePlayer, "Watch", 1) outputChatBox("#6495ED[DayzLife Romania]#C0C0C0You got the vip pack!", thePlayer, 255, 255, 255, true) end end addCommandHandler("vipitems", givepackvip) I want to make the command be available only once at 10 minutes ( 600000 ms ) [ To avoid players spamming the command for free items ] . I tried with setTimer, but i dont think i understand it so well.. Some help? Thanks in advance ! ^^' Link to comment
Miika Posted January 3, 2017 Share Posted January 3, 2017 timer = {} function givepackvip (thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("vip")) then if not isTimer(timer[account]) then timer[account] = setTimer(function() timer[account] = false end, 600000, 1) setElementData(thePlayer, "M4A1 CCO SD", 1) setElementData(thePlayer, "M4A1 CCO SD Mag", 150) setElementData(thePlayer, "M4A03", 1) setElementData(thePlayer, "M4A03 Mag", 69) setElementData(thePlayer, "Veteran Backpack", 1) setElementData(thePlayer, "MP5A5", 1) setElementData(thePlayer, "MP5A5 Mag", 150) setElementData(thePlayer, "Binoculars", 1) setElementData(thePlayer, "Burger", 3) setElementData(thePlayer, "Canteen", 3) setElementData(thePlayer, "Morphine", 2) setElementData(thePlayer, "Medical Supplies", 2) setElementData(thePlayer, "Ghillie Suit Ghost", 1) setElementData(thePlayer, "Map", 1) setElementData(thePlayer, "GPS", 1) setElementData(thePlayer, "Toolbox", 1) setElementData(thePlayer, "Infrared Googles", 1) setElementData(thePlayer, "Watch", 1) outputChatBox("#6495ED[DayzLife Romania]#C0C0C0You got the vip pack!", thePlayer, 255, 255, 255, true) else outputChatBox("#6495ED[DayzLife Romania]#C0C0C0You can request vip pack every hour!", thePlayer, 255, 0, 0, true) end end end addCommandHandler("vipitems", givepackvip) Try it and post possible errors. Link to comment
JanKy Posted January 3, 2017 Author Share Posted January 3, 2017 16 minutes ago, Miika822 said: timer = {} function givepackvip (thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("vip")) then if not isTimer(timer[account]) then timer[account] = setTimer(function() timer[account] = false end, 600000, 1) setElementData(thePlayer, "M4A1 CCO SD", 1) setElementData(thePlayer, "M4A1 CCO SD Mag", 150) setElementData(thePlayer, "M4A03", 1) setElementData(thePlayer, "M4A03 Mag", 69) setElementData(thePlayer, "Veteran Backpack", 1) setElementData(thePlayer, "MP5A5", 1) setElementData(thePlayer, "MP5A5 Mag", 150) setElementData(thePlayer, "Binoculars", 1) setElementData(thePlayer, "Burger", 3) setElementData(thePlayer, "Canteen", 3) setElementData(thePlayer, "Morphine", 2) setElementData(thePlayer, "Medical Supplies", 2) setElementData(thePlayer, "Ghillie Suit Ghost", 1) setElementData(thePlayer, "Map", 1) setElementData(thePlayer, "GPS", 1) setElementData(thePlayer, "Toolbox", 1) setElementData(thePlayer, "Infrared Googles", 1) setElementData(thePlayer, "Watch", 1) outputChatBox("#6495ED[DayzLife Romania]#C0C0C0You got the vip pack!", thePlayer, 255, 255, 255, true) else outputChatBox("#6495ED[DayzLife Romania]#C0C0C0You can request vip pack every hour!", thePlayer, 255, 0, 0, true) end end end addCommandHandler("vipitems", givepackvip) Try it and post possible errors. Thank you man, it works like a charm ^^ 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