Jump to content

[Help] Join-Quit


Atouk

Recommended Posts

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

Link to comment

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 ) 

Link to comment

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 ) 

Link to comment
  • Moderators

Parameters: oldNick, newNick

function nickChangeHandler(oldNick, newNick) 
    outputChatBox(oldNick.." is now known as "..newNick, getRootElement(), 255, 100, 100) 
end 
addEventHandler("onPlayerChangeNick", getRootElement(), nickChangeHandler) 

Link to comment
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. :(

Link to comment
  • Moderators

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) 

Link to comment

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 ) 

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