nasserdfdd Posted May 14, 2015 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)
darhal Posted May 14, 2015 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 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
Walid Posted May 14, 2015 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) Do not yield your back to your enemy, might feel something strange in your ass. Two things are infinite the universe and human stupidity and i'm not sure about the universe. UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators
darhal Posted May 15, 2015 Posted May 15, 2015 Nope you are welcome #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
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