Jump to content

need little help


Recommended Posts

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
  
   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 by Guest
Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...