kieran Posted August 29, 2017 Share Posted August 29, 2017 Hey, so I made a custom event with my login script, basically when a player registers an account it sets team to "Everyone" it was working, but my MTA messed up and I forget how I done it, scripts are below, any help would be great! Team Change Everyone = createTeam ( "Everyone", 0, 255, 0 ) function regteam () setPlayerTeam ( source, Everyone ) outputChatBox ("Please press F1 for information and rules", source, 255, 50, 100) end addEventHandler("onRequestRegister",getRootElement(),regteam) As you can see, this has a custom event to change team. Custom Event function registerPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) triggerClientEvent (source,"hideLoginWindow",getRootElement()) end end end end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) Here is the event I have. When a player clicks "register" this event is triggered, all scripts are server side... Apart from the GUI of course It all works, but won't set team someone know where I gone wrong? Link to comment
ViRuZGamiing Posted August 30, 2017 Share Posted August 30, 2017 I don't know what triggers onRequestRegister but I suppose a GUI Button so that would be the source of your event so in regteam you're setting a team for your button. Might be false since I can't see the onRequestRegister as trigger part 1 Link to comment
kieran Posted August 31, 2017 Author Share Posted August 31, 2017 On 30/08/2017 at 01:15, ViRuZGamiing said: I don't know what triggers onRequestRegister but I suppose a GUI Button so that would be the source of your event so in regteam you're setting a team for your button. Might be false since I can't see the onRequestRegister as trigger part function registerPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true ) triggerClientEvent (source,"hideLoginWindow",getRootElement()) end end end end end addEvent("onRequestRegister",true) addEventHandler("onRequestRegister",getRootElement(),registerPlayer) THIS is onRequestRegister, what it does is checks the 2 edits "username" and "password", if the account isn't there it then adds the account and outputs a message. In theory when a player registers, if I do: Everyone = createTeam ( "Everyone", 0, 255, 0 ) function regteam () setPlayerTeam ( source, Everyone ) outputChatBox ("Please press F1 for information and rules", source, 255, 50, 100) end addEventHandler("onRequestRegister",getRootElement(),regteam) The players team should be set.... But I don't know if I should just use localPlayer or onPlayerLogin.... I am slightly confusing myself basically I am going to make it to set the new registered players team and since there is no native event to check if an account is added for the first time, I am just trying to use the one on login panel. Link to comment
kieran Posted August 31, 2017 Author Share Posted August 31, 2017 Got it working, turns out that it was working... Must of forgot to restart the resource last time thanks anyways! Link to comment
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