S3Nn4oXx Posted August 31, 2015 Posted August 31, 2015 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 )
Noki Posted August 31, 2015 Posted August 31, 2015 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)
S3Nn4oXx Posted August 31, 2015 Author Posted August 31, 2015 Thanks but i don't get it, idk what to put inside (), like _,msg
S3Nn4oXx Posted August 31, 2015 Author Posted August 31, 2015 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
Noki Posted August 31, 2015 Posted August 31, 2015 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)
S3Nn4oXx Posted August 31, 2015 Author Posted August 31, 2015 I can write what i want? in ur code i can replace from State to freeze, Example ?
Noki Posted August 31, 2015 Posted August 31, 2015 You won't be able to change state to freeze, as freeze is the function's name. You'll need to use a variable that currently isn't in use.
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