megaman54 Posted July 12, 2010 Share Posted July 12, 2010 I get these errors: Bad argument @ getPlayerAccount Bad argument @ isGuestAccount when executing this: local account = getPlayerAccount(source) if isGuestAccount(account) then i checked the script 10 times but sitll cant figure it out. Please help. Link to comment
dzek (varez) Posted July 12, 2010 Share Posted July 12, 2010 post full script dude! all i can say seeing these lines: - you are giving bad argument when using getPlayerAccount (source == bad argument) - you are giving bad argument when using isGuestAccount (account == bad argument) but.. its same as: Bad argument @ getPlayerAccount Bad argument @ isGuestAccount isnt it? Link to comment
megaman54 Posted July 12, 2010 Author Share Posted July 12, 2010 Well, here is the full script, as you wanted: function triggerTimer() setTimer(makeAccount, 2000, 1) end addEventHandler("onPlayerJoin", getRootElement(), triggerTimer) function makeAccount() local account = getPlayerAccount(source) if isGuestAccount(account) then addAccount(getPlayerName(source), getPlayerName(source)) outputChatBox("Your account has been created!", source, 0, 255, 0) end end addCommandHandler("makeaccountforme", makeAccount) Link to comment
MaddDogg Posted July 12, 2010 Share Posted July 12, 2010 There is no source at this point. I don't think you understand the concept of a source. Have a look at what parameters are given for your handler function: https://wiki.multitheftauto.com/wiki/AddCommandHandler Link to comment
dzek (varez) Posted July 12, 2010 Share Posted July 12, 2010 btw: are you sure you blocked "register" "login" and "logout" in ACL? if not - your script is extremly easy to hack and login as other user... oh well.. its still easy - just changing nickname.. whatever.. only script fix, not logical fix, cause your logic is totally broken function triggerTimer() setTimer(makeAccount, 2000, 1. source) end addEventHandler("onPlayerJoin", getRootElement(), triggerTimer) function makeAccount(playerSource) local account = getPlayerAccount(playerSource) if (account) then if isGuestAccount(account) then addAccount(getPlayerName(playerSource), getPlayerName(playerSource)) outputChatBox("Your account has been created!", source, 0, 255, 0) end else addAccount(getPlayerName(playerSource), getPlayerName(playerSource)) outputChatBox("Your account has been created!", source, 0, 255, 0) end end addCommandHandler("makeaccountforme", makeAccount) and suggestion: spend some time on reading wiki, and learning lua, not just merging random code snippets from somewhere - this will bring you nowhere.. https://wiki.multitheftauto.com/wiki/Scripting_Introduction https://wiki.multitheftauto.com/wiki/Debugging https://wiki.multitheftauto.com/wiki/Resources https://wiki.multitheftauto.com/wiki/Client_Scripting_Functions https://wiki.multitheftauto.com/wiki/Server_Scripting_Functions https://wiki.multitheftauto.com/wiki/Client_Scripting_Events https://wiki.multitheftauto.com/wiki/Server_Scripting_Events or just https://wiki.multitheftauto.com/ Link to comment
dzek (varez) Posted July 12, 2010 Share Posted July 12, 2010 MaddDogg notice he is running this funcion also on onPlayerJoin handler o_O Link to comment
megaman54 Posted July 12, 2010 Author Share Posted July 12, 2010 This script is still in the debugging stage. I'm trying to make it better, i started making it today. EDIT: The meaning of this script is to make an account if the joined player doesnt have one. I'm also using the MTA default auto-login thing. Link to comment
dzek (varez) Posted July 13, 2010 Share Posted July 13, 2010 EDIT: The meaning of this script is to make an account if the joined player doesnt have one. creating it with same password as username is at least stupid.. creating accounts based on nickname too.. I'm also using the MTA default auto-login thing. autologin is based on serial, your script on nickname.. i dont know much about autologin but.. isnt it creating accounts automatically? I'll upload my auto-registering and auto-logging script to community. 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