Jump to content

Some way to do something like "onPLayerRegister"??


Adde

Recommended Posts

Posted

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 
) 

My ingame nickname is: Mr.Snus

Posted

From your registration system you can trigger an event, then you can use it whenever you need, but such event doesn't exist by default.

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

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 

My ingame nickname is: Mr.Snus

Posted

After:

if (logIn(source, account, password) == true) then 

You can add:

triggerEvent ( "onPlayerRegister", source ) 

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

Aha okay, so I shoould use that instead of the one I used from the beginning? and then add an event/create an event to the function? If I understand wiki right.

My ingame nickname is: Mr.Snus

Posted

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.

Lua Scripter

?ucet=miki_cz

Owner of mshost.cz MTA portal.

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