Jump to content

Command


R.y.c.k

Recommended Posts

How to create command /lu - 'Lucky ! """"""" how to add this feature ?

example: Ern€st: /lu AnTO_on and in chat see Ern€st #5dacd1 say: Lucky AnTO_on !

function luck(player, cmd) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
        outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky!", root, 255, 255, 255, true) 
        restriction[player][cmd] = true 
        setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
    else 
        outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("lu", luck) 

Link to comment
restriction = {} 
  
function luck(player, cmd, who) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
    local target = getPlayerFromName ( who ) 
     if target ~= false then 
        outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky "..getPlayerName(target).."!", root, 255, 255, 255, true) 
        restriction[player][cmd] = true 
        setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
        end 
        else 
                outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) 
    end 
    end 
addCommandHandler("lu", luck) 

Edited by Guest
Link to comment
Guest Guest4401
6: Bad argument @ 'getPlayerFromName'

You should type /lu

But you typed /lu

or

The script is clientsided, but it should be serversided.

Link to comment
restriction = {} 
      
function luck(player, cmd, who) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
        if tostring(who) then 
            local target = getPlayerFromName ( who ) 
            if target then 
                outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky "..getPlayerName(target).."!", root, 255, 255, 255, true) 
                restriction[player][cmd] = true 
                setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
            end 
        else 
            outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky!", root, 255, 255, 255, true) 
            restriction[player][cmd] = true 
            setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
        end 
    else 
        outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("lu", luck) 

Nick with colors wont work, you have to make your own getPlayerFromName.

Edited by Guest
Link to comment

try this

restriction = {} 
  
function luck(player, cmd, who) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
    local target = getPlayerFromName ( who ) 
     if target ~= false then 
        outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky "..getPlayerName(target).."!", root, 255, 255, 255, true) 
               restriction[player][cmd] = true 
        setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
        elseif not target then 
                outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky!", root, 255, 255, 255, true) 
        restriction[player][cmd] = true 
        setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
        end 
        else 
                outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) 
    end 
    end 
addCommandHandler("lu", luck) 
  

Link to comment
restriction = {} 
  
function findPlayer(namepart) 
    for i, player in ipairs(getElementsByType("player")) do 
        local name = getPlayerName(player) 
        local name2 = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") 
        if string.find(name:lower(), namepart:lower(), 1, true) then  
            return player, name  
        elseif string.find(name2:lower(), namepart:lower(), 1, true) then 
            return player, name 
        end 
    end 
    return false 
end 
      
function luck(player, cmd, who) 
    if (not restriction[player]) then restriction[player] = {} end 
    if not restriction[player][cmd] then 
        if who then 
            local target = findPlayer ( who ) 
            if target then 
                outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky "..getPlayerName(target).."!", root, 255, 255, 255, true) 
                restriction[player][cmd] = true 
                setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
            end 
        else 
            outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky!", root, 255, 255, 255, true) 
            restriction[player][cmd] = true 
            setTimer(function () restriction[player][cmd] = false end, 5000, 1) 
        end 
    else 
        outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) 
    end 
end 
addCommandHandler("lu", luck) 

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