1LoL1 Posted December 9, 2015 Share Posted December 9, 2015 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
Dealman Posted December 9, 2015 Share Posted December 9, 2015 Not entirely sure what you're asking for... I'm assuming what you're looking for is getPlayerFromName? Link to comment
1LoL1 Posted December 9, 2015 Author Share Posted December 9, 2015 Use. else , end why else wtf? /gift name or number or i dont know Now: /gift name . text or: /gift Dealman . 454545www55411 i can use name dealman but he is not online i want: /gift [name] [text] not /gift [name] . [text] Link to comment
Captain Cody Posted December 9, 2015 Share Posted December 9, 2015 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
1LoL1 Posted December 10, 2015 Author Share Posted December 10, 2015 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
Rockyz Posted December 10, 2015 Share Posted December 10, 2015 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
1LoL1 Posted December 10, 2015 Author Share Posted December 10, 2015 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) Not work 0 Errors 0 Warnings Link to comment
Rockyz Posted December 10, 2015 Share Posted December 10, 2015 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
1LoL1 Posted December 10, 2015 Author Share Posted December 10, 2015 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) Same. Link to comment
Rockyz Posted December 10, 2015 Share Posted December 10, 2015 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
1LoL1 Posted December 10, 2015 Author Share Posted December 10, 2015 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) Same. Link to comment
DizzasTeR Posted December 10, 2015 Share Posted December 10, 2015 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
1LoL1 Posted December 10, 2015 Author Share Posted December 10, 2015 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
1LoL1 Posted December 10, 2015 Author Share Posted December 10, 2015 And one question if i want without this what i must use? plr = getPlayerFromPartialName( giftTo ) Link to comment
DizzasTeR Posted December 11, 2015 Share Posted December 11, 2015 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. Link to comment
1LoL1 Posted December 11, 2015 Author Share Posted December 11, 2015 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
DizzasTeR Posted December 12, 2015 Share Posted December 12, 2015 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
1LoL1 Posted December 12, 2015 Author Share Posted December 12, 2015 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now