iMonkr Posted May 16, 2021 Posted May 16, 2021 Quote is this coding is correct? if player register, he can't register again, is this correct? bRegisteredOnce = {} function registerPlayer(source, username, password ) local accountAdded = addAccount(username, password) if (accountAdded) then triggerClientEvent (client, "createNotification", client, "#33aaccCogratuation #ffffffyour have account now .", "success") bRegisteredOnce[source] = true elseif bRegisteredOnce[source] == true then outputChatBox("You already registered on this server!",source) end end addEvent("register", true) addEventHandler("register", root, registerPlayer)
Moderators Patrick Posted May 30, 2021 Moderators Posted May 30, 2021 Hi! I moved your thread to Scripting section, next time ask your scripting related questions here. You have to check "bRegisteredOnce[source] == true" before(!) calling addAccount. Should look like this: bRegisteredOnce = {} function registerPlayer(source, username, password ) if bRegisteredOnce[source] == true then outputChatBox("You already registered on this server!",source) else local accountAdded = addAccount(username, password) if (accountAdded) then triggerClientEvent (client, "createNotification", client, "#33aaccCogratuation #ffffffyour have account now .", "success") bRegisteredOnce[source] = true end end end addEvent("register", true) addEventHandler("register", root, registerPlayer) - Of course, this works until the next resource/server restart. Probably a better solution if you use getAccountsBySerial to check is there any associated account to player's serial. function registerPlayer(source, username, password ) local serial = getPlayerSerial(source) local serialAccounts = getAccountsBySerial(serial) if serialAccounts and #serialAccounts > 0 then outputChatBox("You already registered on this server!",source) else local accountAdded = addAccount(username, password) if (accountAdded) then triggerClientEvent (client, "createNotification", client, "#33aaccCogratuation #ffffffyour have account now .", "success") end end end addEvent("register", true) addEventHandler("register", root, registerPlayer)
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