Jump to content

[HELP] Name, Text


1LoL1

Recommended Posts

Hello, i created script but not work i don't know why i don't see first letter ? :( please can anyone help me or fix this?

And i can get in the script names.. example /gift SHIT text but SHIT is not online :(

function Gift (thePlayer,command,who,text,...) 
if text then 
local text = table.concat ( { ... }, " " ) 
outputChatBox("Admin "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "").." --> "..who.." [Reason: "..text.."]", root, 255, 0, 0, true) 
end 
end 
addCommandHandler("gift", Gift) 

Link to comment
    function Gift (thePlayer,command,who,text,...) 
    if text then 
    local text = table.concat ( { ... }, " " ) 
    outputChatBox("Admin "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "").." --> "..who.." [Reason: "..text.."]", root, 255, 0, 0, true) 
else 
return 
    end 
    end 
    addCommandHandler("gift", Gift) 

Link to comment
    function Gift (thePlayer,command,who,text,...) 
    if text then 
    local text = table.concat ( { ... }, " " ) 
    outputChatBox("Admin "..string.gsub(getPlayerName(thePlayer), "#%x%x%x%x%x%x", "").." --> "..who.." [Reason: "..text.."]", root, 255, 0, 0, true) 
else 
return 
    end 
    end 
    addCommandHandler("gift", Gift) 

Not work.

Now i must use /gift [name] "." [text] but i can use name IDIOT but idiot it's not online on my server.

i want: /gift [name] [text]

Link to comment

function Gift (plr,_,who,text) 
if who and isElement (who) and text then 
local txtt = table.concat ( { text }, " " ) 
outputChatBox("Admin "..plr:gsub("#%x%x%x%x%x%x", "").." --> "..who.." [Reason: "..txtt.."]", root, 255, 0, 0, true) 
end 
end 
addCommandHandler("gift", Gift) 
Link to comment

function Gift (plr,_,who,text) 
if who and isElement (who) and text then 
local txtt = table.concat ( { text }, " " ) 
outputChatBox("Admin "..getPlayerName (plr):gsub("#%x%x%x%x%x%x", "").." --> "..who.." [Reason: "..txtt.."]", root, 255, 0, 0, true) 
end 
end 
addCommandHandler("gift", Gift) 
Link to comment

function Gift (plr,_,who,text) 
if who and isElement (who) and text then 
local txtt = table.concat ( { text }, " " ) 
outputChatBox("Admin "..string.gsub(getPlayerName (plr),"#%x%x%x%x%x%x", "").." --> "..who.." [Reason: "..txtt.."]", root, 255, 0, 0, true) 
end 
end 
addCommandHandler("gift", Gift) 
Link to comment
function Gift( player, command, giftTo, ... ) 
    if( not giftTo or not ... ) then 
        return outputChatBox( "* Invalid syntex: /gift [Name] [Text]", player, 255, 0, 0 ); 
    else 
        outputChatBox( "Args: " .. giftTo .. " | " .. table.concat( {...}, " " ), player, 255,255,255 ) 
        plr = getPlayerFromPartialName( giftTo ) 
        if( not plr ) then 
            return outputChatBox( "* Player not found", player, 255, 0, 0 ); 
        else 
            local msg = table.concat( {...}, " " ); 
            outputChatBox( "* You sent a gift message: \"" .. msg .. "\" to " .. getPlayerName( plr ), player, 0, 255, 0, true ); 
            outputChatBox( "* " .. getPlayerName( player ) .. "#00FF00 gift-messaged you: \"" .. msg .. "\"", plr, 0, 255, 0, true ); 
        end 
    end 
end 
addCommandHandler( "gift", Gift ) 
  
function getPlayerFromPartialName(name) -- Author: TAPL 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 

Usage: /gift PlayerName Message

Link to comment
function Gift( player, command, giftTo, ... ) 
    if( not giftTo or not ... ) then 
        return outputChatBox( "* Invalid syntex: /gift [Name] [Text]", player, 255, 0, 0 ); 
    else 
        outputChatBox( "Args: " .. giftTo .. " | " .. table.concat( {...}, " " ), player, 255,255,255 ) 
        plr = getPlayerFromPartialName( giftTo ) 
        if( not plr ) then 
            return outputChatBox( "* Player not found", player, 255, 0, 0 ); 
        else 
            local msg = table.concat( {...}, " " ); 
            outputChatBox( "* You sent a gift message: \"" .. msg .. "\" to " .. getPlayerName( plr ), player, 0, 255, 0, true ); 
            outputChatBox( "* " .. getPlayerName( player ) .. "#00FF00 gift-messaged you: \"" .. msg .. "\"", plr, 0, 255, 0, true ); 
        end 
    end 
end 
addCommandHandler( "gift", Gift ) 
  
function getPlayerFromPartialName(name) -- Author: TAPL 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 

Usage: /gift PlayerName Message

Thanks works.

Link to comment
That function is just to remove any color codes from a player's name which we send to it and then match it. If you use getPlayerFromName then you have to give exactly the same name with color codes to send a message.

I have a name without a hex friend of mine has a name with hex

Me: LOL no hex

On: LOL1 with hex

if I use what I wrote and write /gift LOL so it applies to LOL1 not to LOL

Link to comment

Modify the getPlayerFromPartialName with this one:

  
function getPlayerFromPartialName(name) -- Author: TAPL 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_ == name then 
                return player 
            else  
                return false; 
            end 
        end 
    end 
end 

But remember now you have to specify exactly the same name inorder for it to work.

Link to comment
Modify the getPlayerFromPartialName with this one:
  
function getPlayerFromPartialName(name) -- Author: TAPL 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_ == name then 
                return player 
            else  
                return false; 
            end 
        end 
    end 
end 

But remember now you have to specify exactly the same name inorder for it to work.

Now not work i have name with hex and my friend have name with no hex but when i want to use /gift LOL1 i can't :(

Can you please fix to

/gift LOL with hex + without hex

/gift LOL1 and other names with hex + without hex

But remember now you have to specify exactly the same name inorder for it to work.

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