Atouk Posted February 15, 2013 Posted February 15, 2013 Hello, I wanted to ask if I have any mistakes. function joinHandler( ) local joinedPlayerName = getPlayerName ( source ) exports["notifications"]:showBox ( source, "info", ..joinedPlayerName.. "Entro al servidor." ) end addEventHandler ( "onPlayerJoin", getRootElement(), joinHandler ) function quitHandler( ) local quitPlayerName = getPlayerName ( source ) exports["notifications"]:showBox ( source, "error", ..quitPlayerName.. "Salio del servidor." ) end addEventHandler ( "onPlayerQuit", getRootElement(), quitHandler ) What I do is that when a player opens the window "notifications" of H5N1 [PL]. The information that will be written: Player name and message. I hope answers, thanks
Castillo Posted February 15, 2013 Posted February 15, 2013 You got some problems: 1: You are showing it just to the player that joined/quitted. 2: You got two extra dots. You need to loop all players like this: function joinHandler ( ) local joinedPlayerName = getPlayerName ( source ) for _, player in ipairs ( getElementsByType ( "player" ) ) do exports [ "notifications" ]:showBox ( player, "info", joinedPlayerName .." Entro al servidor." ) end end addEventHandler ( "onPlayerJoin", getRootElement(), joinHandler ) function quitHandler ( ) local quitPlayerName = getPlayerName ( source ) for _, player in ipairs ( getElementsByType ( "player" ) ) do exports [ "notifications" ]:showBox ( player, "error", quitPlayerName .." Salio del servidor." ) end end addEventHandler ( "onPlayerQuit", getRootElement(), quitHandler )
Atouk Posted February 15, 2013 Author Posted February 15, 2013 (edited) Works perfect, but how do I remove the color codes? Edited February 15, 2013 by Guest
Castillo Posted February 15, 2013 Posted February 15, 2013 Use this: function joinHandler ( ) local joinedPlayerName = getPlayerName ( source ):gsub ( "#%x%x%x%x%x%x", "" ) for _, player in ipairs ( getElementsByType ( "player" ) ) do exports [ "notifications" ]:showBox ( player, "info", joinedPlayerName .." Entro al servidor." ) end end addEventHandler ( "onPlayerJoin", getRootElement(), joinHandler ) function quitHandler ( ) local quitPlayerName = getPlayerName ( source ):gsub ( "#%x%x%x%x%x%x", "" ) for _, player in ipairs ( getElementsByType ( "player" ) ) do exports [ "notifications" ]:showBox ( player, "error", quitPlayerName .." Salio del servidor." ) end end addEventHandler ( "onPlayerQuit", getRootElement(), quitHandler )
Atouk Posted February 15, 2013 Author Posted February 15, 2013 Soldisnake Thank you so much, I hope not to bother you.
Atouk Posted February 15, 2013 Author Posted February 15, 2013 which is the event for you when you rename the player jump out the window? (Event when changing the name)
Atouk Posted February 15, 2013 Author Posted February 15, 2013 Em, yes, but how he would tell you: (oldnick) renamed (newnick).
DNL291 Posted February 15, 2013 Posted February 15, 2013 Parameters: oldNick, newNick function nickChangeHandler(oldNick, newNick) outputChatBox(oldNick.." is now known as "..newNick, getRootElement(), 255, 100, 100) end addEventHandler("onPlayerChangeNick", getRootElement(), nickChangeHandler)
Atouk Posted February 15, 2013 Author Posted February 15, 2013 function nameHandler (oldNick, newNick) exports [ "notifications" ]:showBox ( player, "warning", oldNick:gsub ( "#%x%x%x%x%x%x", "" ) .." Ahora se llama: "..newNick:gsub ( "#%x%x%x%x%x%x", "" ) ) end addEventHandler("onPlayerChangeNick", getRootElement(), nameHandler) But does not work so I put.
DNL291 Posted February 15, 2013 Posted February 15, 2013 Try this: function nameHandler (oldNick, newNick) exports [ "notifications" ]:showBox ( root, "warning", oldNick:gsub ( "#%x%x%x%x%x%x", "" ) .." Ahora se llama: "..newNick:gsub ( "#%x%x%x%x%x%x", "" ) ) end addEventHandler("onPlayerChangeNick", getRootElement(), nameHandler)
Castillo Posted February 15, 2013 Posted February 15, 2013 You forgot the for-loop. function nameHandler ( oldNick, newNick ) for _, player in ipairs ( getElementsByType ( "player" ) ) do exports [ "notifications" ]:showBox ( player, "warning", oldNick:gsub ( "#%x%x%x%x%x%x", "" ) .." Ahora se llama: ".. newNick:gsub ( "#%x%x%x%x%x%x", "" ) ) end end addEventHandler ( "onPlayerChangeNick", getRootElement(), nameHandler )
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