Jump to content

Help with script


DrPhoX

Recommended Posts

  
local restriction = {} 
  
function getPlayerFromNamePart(name) 
    if name then 
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player 
            end 
        end 
    end 
    return false 
end 
  
addCommandHandler("likeu", 
    function(player, cmd, players) 
        if not restriction[player] then 
            restriction[player] = true 
            setTimer(function () restriction[player] = false end, 5000, 1)   
        else 
            return outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) 
        end 
        if players then 
        local playerss = getPlayerFromNamePart(players) 
        if playerss then 
            outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) 
        end 
        else 
            outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) 
        end 
    end 
) 
  

Link to comment
  
  
local restriction = {} 
  
function getPlayerFromNamePart(name) 
    if name then 
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player 
            end 
        end 
    end 
    return false 
end 
  
addCommandHandler("likeu", 
    function(player, cmd, players) 
        if not restriction[player] then 
            restriction[player] = true 
            setTimer(function () restriction[player] = false end, 5000, 1)  
            if players then 
            local playerss = getPlayerFromNamePart(players) 
                if playerss then 
                    outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) 
                end 
            else 
            outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) 
            end          
        else 
            outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) 
        end 
    end 
) 
  
  

Link to comment

And one more thing...

When i have this:

local restriction = {} 
  
function getPlayerFromNamePart(name) 
    if name then 
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player 
            end 
        end 
    end 
    return false 
end 
  
addCommandHandler("likeu", 
    function(player, cmd, players) 
        if not restriction[player] then 
            restriction[player] = true 
            setTimer(function () restriction[player] = false end, 5000, 1) 
            if players then 
            local playerss = getPlayerFromNamePart(players) 
                if playerss then 
                    outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) 
                end 
            else 
            outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) 
            end         
        else 
            outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) 
        end 
    end 
) 
  
function hateMap(player, cmd) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
        outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I hate this map! #ffffff(type: /hatemap)", root, 255, 255, 255, true) 
        restriction[player][cmd] = true 
        setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
    else 
        outputChatBox("#ffa500-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("hatemap", hateMap) 

So command /hatemap working but command /likeu and /likeu don't work, it shows antispam message, not (I like you) message :/

Link to comment
  
local restriction = {} 
  
function getPlayerFromNamePart(name) 
    if name then 
        for i, player in ipairs(getElementsByType("player")) do 
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then 
                return player 
            end 
        end 
    end 
    return false 
end 
  
addCommandHandler("likeu", 
    function(player, cmd, players) 
        if (not restriction[player]) then restriction[player] = {} end 
        if not restriction[player][cmd] then 
            restriction[player][cmd] = true 
            setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
            if players then 
            local playerss = getPlayerFromNamePart(players) 
                if playerss then 
                    outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I like you #ffffff" .. getPlayerName(playerss) .. "! #ffffff(type: /likeu )", root, 255, 165, 0, true) 
                end 
            else 
            outputChatBox("#ffffff".. getPlayerName(player) .."#ffa500: I like you! #ffffff(type: /likeu)", player, 255, 165, 0, true) 
            end         
        else 
            outputChatBox("-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 165, 0, true) 
        end 
    end 
) 
  
function hateMap(player, cmd) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
        outputChatBox("#FFFFFF".. getPlayerName(player) .."#ffa500: I hate this map! #ffffff(type: /hatemap)", root, 255, 255, 255, true) 
        restriction[player][cmd] = true 
        setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
    else 
        outputChatBox("#ffa500-LaB-: #ffffffYou must wait 5 seconds to write this command again.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("hatemap", hateMap) 
  
  

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