nasserdfdd Posted May 14, 2015 Share Posted May 14, 2015 hi again today i need little help i have medkit script i want when i use med kit to wait 2 sec then i can use another one local theMarker = createMarker(1176.19, -1339.09, 13.985, "cylinder", 3, 0, 255, 0) addEventHandler("onMarkerHit", theMarker, function(player) if getElementType(player) == "player" then outputChatBox("Type /med to buy 25% of Health", player, 255, 255, 255) end end) addCommandHandler("med", function(player) if getPlayerMoney(player) >= 1500 then local newHealth = getElementHealth(player) + 25 setElementHealth(player, newHealth) takePlayerMoney(player, 1500) outputChatBox("You have bought 25% health for $1,500", player, 0, 255, 0) end end) Link to comment
darhal Posted May 14, 2015 Share Posted May 14, 2015 (edited) local theMarker = createMarker(1176.19, -1339.09, 13.985, "cylinder", 3, 0, 255, 0) local antiSpamTimer = {} local canPlayerUseMedkitsAgain = {} addEventHandler("onMarkerHit", theMarker, function(player) if getElementType(player) == "player" then outputChatBox("Type /med to buy 25% of Health", player, 255, 255, 255) end end) addCommandHandler("med", function(player) if getPlayerMoney(player) >= 1500 and not canPlayerUseMedkitsAgain[player] then local newHealth = getElementHealth(player) + 25 setElementHealth(player, newHealth) takePlayerMoney(player, 1500) canPlayerUseMedkitsAgain[player] = true outputChatBox("You have bought 25% health for $1,500", player, 0, 255, 0) antiSpamTimer[player] = setTimer(function (player) canPlayerUseMedkitsAgain[player] = false end, 2000, 1, player) end end) Edited May 14, 2015 by Guest Link to comment
Walid Posted May 14, 2015 Share Posted May 14, 2015 Try this one local theMarker = createMarker(1176.19, -1339.09, 13.985, "cylinder", 3, 0, 255, 0) local Timer = {} addEventHandler("onMarkerHit", theMarker, function(player) if getElementType(player) == "player" then outputChatBox("Type /med to buy 25% of Health", player, 255, 255, 255) end end) addCommandHandler("med", function(player) if getPlayerMoney(player) >= 1500 then if (isTimer(Timer[player])) then outputChatBox("You can only use med kit once every 4 seconds",player, 255, 0, 0) return end local newHealth = getElementHealth(player) + 25 setElementHealth(player, newHealth) takePlayerMoney(player, 1500) outputChatBox("You have bought 25% health for $1,500", player, 0, 255, 0) Timer[player] = setTimer(function() end, 2000, 1 ) -- 2 seconds end end) 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