Jump to content

Some way to do something like "onPLayerRegister"??


Adde

Recommended Posts

Hello, I want to ask you if it´s possible to make a function to trigger when a player have register. Example make this happend when someone register:

function onPlayerRegister () 
setElementPosition ( player, x, y, z ) 
SetPlayerTeam ( player, "team" ) 
SetElementModel ( player, 1 ) 
givePlayerMoney ( player, 1000 ) 
addEventHandler("???", getRootElement, onPlayerRegister) 

Anyone who knows how to do that or if it works? I tested to put it in registerpanel with the other things happend at register but it didn´t work.

I found something on the forum that maybe helped me a bit. Can this work?

addEventHandler("onPlayerLogin", root, 
function(_, account) 
    if not getAccountData(account, "FirstTime") then 
       setElementPosition ( player, x, y, z ) 
       setPlayerTeam ( player, "team" ) 
       setElementModel ( player, 1 ) 
       givePlayerMoney ( player, 1000 ) 
       setAccountData(account, "FirstTime", true) 
end 
end 
) 

Link to comment

So if I have this

function registerHandler(username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        outputChatBox( "", root, 255, 255, 255 ) 
    else 
        account = addAccount(username, password) 
        if (logIn(source, account, password) == true) then 
            triggerClientEvent(source, "hideRegisterWindow", getRootElement()) 
       end 
    end 
end 
addEventHandler("submitRegister", root, registerHandler) 

I can do something like this

Server side

function registerHandler(username, password) 
    local account = getAccount(username, password) 
    if (account ~= false) then 
        outputChatBox( "", root, 255, 255, 255 ) 
    else 
        account = addAccount(username, password) 
        if (logIn(source, account, password) == true) then 
            triggerClientEvent(source, "hideRegisterWindow", getRootElement()) 
            triggerServerEvent(source, "playerSpawn", getRootElement()) 
       end 
    end 
end 
addEventHandler("submitRegister", root, registerHandler) 
  
function playerSpawn() 
setElementPosition(source, 232.23, 1904.39, 17.84) 
setPlayerTeam(source, "Army") 
setElementModel(source, 179) 
setPlayerNametagColor(source, 59, 166, 109) 
end 

Link to comment

I found something on the forum that maybe helped me a bit. Can this work?

addEventHandler("onPlayerLogin", root, 
function(_, account) 
    if not getAccountData(account, "FirstTime") then 
       setElementPosition ( player, x, y, z ) 
       setPlayerTeam ( player, "team" ) 
       setElementModel ( player, 1 ) 
       givePlayerMoney ( player, 1000 ) 
       setAccountData(account, "FirstTime", true) 
end 
end 
) 

That should work, you just have no "player" variable declared, use source instead.

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