Jump to content

need little help


Recommended Posts

Posted

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) 

Posted (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 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

Posted

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

Posted

Nope you are welcome :D

#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

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...