Jump to content

[Help] Join-Quit


Atouk

Recommended Posts

Posted

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

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Parameters: oldNick, newNick

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

Please do not PM me with scripting related question nor support, use the forums instead.

Posted
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. :(

Posted

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) 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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