Jump to content

Advertising


S3Nn4oXx

Recommended Posts

Hello guys I need help, I am Beginner in LUA and idk what i did :) can you help me?

[ADVERT]Playername:

  
function advert() 
    local localPlayerName = getPlayerName(getLocalPlayer()) 
    outputChatBox ( "#FF0000[ADVERT]"..localPlayerName, getRootElement(), 255, 255, 255, true ) 
end 
addCommandHandler ( "advert", advert ) 
  

:)

Link to comment
function advert(_, msg) 
    local msg = table.concat({..}, " ") 
    local localPlayerName = getPlayerName(localPlayer) 
    outputChatBox("#FF0000[ADVERT]"..localPlayerName..": "..msg, root, 255, 255, 255, true) 
end 
addCommandHandler("advert", advert) 

Link to comment
function advert(_, msg) 
    local msg = table.concat({..}, " ") 
    local localPlayerName = getPlayerName(localPlayer) 
    outputChatBox("#FF0000[ADVERT]"..localPlayerName..": "..msg, root, 255, 255, 255, true) 
end 
addCommandHandler("advert", advert) 

It's not working

Link to comment

Whoops, my bad. I forgot this was client side for a second.

function advert(_, ...) 
    local localPlayerName = getPlayerName(localPlayer) 
    local msg = table.concat({...}, " ") 
    for _, v in pairs(getElementsByType("player")) do 
        outputChatBox("#FF0000[ADVERT]"..localPlayerName..": "..msg, 255, 255, 255, true) 
    end 
end 
addCommandHandler("advert", advert) 

Thanks but i don't get it,

idk what to put inside (), like _,msg

They're called arguments. Think of it as giving someone instructions. You can tell them to do more specific things by explaining it further. Take the code below:

function freeze() 
    setElementFrozen(getPlayerFromName("Noki")) 
end 
freeze() 

Will freeze a player. However, if you want to toggle freeze, you can use an argument to specify.

function freeze(state) 
    setElementFrozen(getPlayerFromName("Noki"), state) 
end 
freeze(true) 
freeze(false) 

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