S3Nn4oXx Posted September 1, 2015 Share Posted September 1, 2015 Hello guys i really interesting in Lua and it's really cool so look what i made here, ik that i can't do getLocalPlayer i think, so how i am supposed to do that ? server.lua function Lol() local localPlayerName = getPlayerName(getLocalPlayer()) outputChatBox ( "#164F8C[TEXT]..localPlayerName..#FFFFFFis Laughing out loud!", getRootElement(), 255, 255, 255, true ) end addCommandHandler("lol", Lol) Btw I want to learn how to do that when i type /lol [otherplayername] so it shows in mainchat, [TEXT]PlayerName thinks [otherplayername] is Laughing out Loud and when i type just /lol so it shows [MyName] Is laughing out loud and when i type /lol [otherplayername] it shows [MyName] thinks [otherplayername] is Laughing out loud Thanks for your attention! Link to comment
HUNGRY:3 Posted September 1, 2015 Share Posted September 1, 2015 function Lol(thePlayer) local localPlayerName = getPlayerName(thePlayer) outputChatBox ( "#164F8C[TEXT]"..localPlayerName.."#FFFFFFis Laughing out loud!", getRootElement(), 255, 255, 255 ) end addCommandHandler("lol", Lol) Link to comment
t3wz Posted September 1, 2015 Share Posted September 1, 2015 getLocalPlayer can be used only in the client side (and you're trying to use this in the server side), When you add a command with addCommandHandler the function which you pass as parameter in the third argument automatically gain 2 new parameters playerSource, string commandName playerSource will be the player who triggered the command (then you can use this instead of getLocalPlayer), commandName will be the command name (eh, obviously ) Your final code will be like this one: function Lol( playerSource, commandName ) local localPlayerName = getPlayerName( playerSource ) outputChatBox ( "#164F8C[TEXT]"..localPlayerName.."#FFFFFFis Laughing out loud!", getRootElement(), 255, 255, 255, true ) end addCommandHandler("lol", Lol) about using parameters in the commands you can read about it in the wiki (scroll down a bit until find "Handler function parameters"), Read the examples also. Link to comment
S3Nn4oXx Posted September 1, 2015 Author Share Posted September 1, 2015 t3wz You are the best <3, Thanks i learned a lot! EDIT: can you add me on skype: thkhh75, I really don't get the argument thing 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