SkymHaru_ Posted August 22, 2020 Share Posted August 22, 2020 (edited) Help, I have tried to place a delay for the commands, but it does not help me at all, could you help me? I don't speak English, that's why the code is in another language. Server: function ablanca(source) if isElementWithinMarker(source, cablanca) then if getElementData(source, "slicencia") == true then if getPlayerMoney(source) >= 2000 then takePlayerMoney(source, 2000) giveWeapon(source, 4, 1, true) outputChatBox("Has comprado un #EE850Ecuchillo #FFFFFFpor $2000.", source, 255, 255, 255, true) else outputChatBox("No tienes dinero suficiente", source, 255, 255, 255, true) end end end end addCommandHandler("ablanca", ablanca) Edited August 22, 2020 by SkymHaru_ Link to comment
DNL291 Posted August 22, 2020 Share Posted August 22, 2020 Add the player to a table index and remove it inside setTimer, then you will have check if the player element is in the table at the beginning of your function. Another way is to store getTickCount() in player's index, then calculate the elapsed time with getTickCount() - stored tickCount of player's index. Link to comment
Moderators IIYAMA Posted August 22, 2020 Moderators Share Posted August 22, 2020 There is also a useful function you can use. https://wiki.multitheftauto.com/wiki/CheckPassiveTimer Which represents DNL291's second way, but with it's own ecosystem. Link to comment
Arshin Posted August 25, 2020 Share Posted August 25, 2020 local Time = 1 --Minutes local CoolDown = {} function ablanca(source) if isElementWithinMarker(source, cablanca) then if getElementData(source, "slicencia") == true then if getPlayerMoney(source) >= 2000 then takePlayerMoney(source, 2000) giveWeapon(source, 4, 1, true) outputChatBox("Has comprado un #EE850Ecuchillo #FFFFFFpor $2000.", source, 255, 255, 255, true) CoolDown[source] = true setTimer( function() CoolDown[source] = nil end, Time*1000, 1) else outputChatBox("No tienes dinero suficiente", source, 255, 255, 255, true) end end end end addCommandHandler("ablanca", ablanca) 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