itHyperoX Posted June 29, 2017 Share Posted June 29, 2017 (edited) Hi everyone! i edited my "login", everything work fine, saving datas but, i made a "serial protect" to acccount. When you register, it set your serial, when you login, it check is this your serial if not the script kick you. So the problem is, when i trying to login to another account which is protected by "serial protect", the server kick the player who tried to login to another account, but reseting the datas i mean not saving your bank balance, or rcPoints, adminlevel etc.. Here is the login part: addEventHandler("onPlayerLogin", getRootElement(),function(_, account) local serial = getPlayerSerial(source) if getAccountData(getPlayerAccount(source),"acc.protect") ~= serial then kickPlayer(source,"Server","Not your account!") else triggerEvent("loadAccount",source,account) setElementData(source,"loggedin",true) exports["rc_notification"]:notification("You successfully logged in!",source,"info") end end) the triggerEvent: addEvent("accountBetoltese", true) addEventHandler("loadAccount",root,function (account) local playerX = getAccountData(account,"acc.pos_X") local playerY = getAccountData(account,"acc.pos_Y") local playerZ = getAccountData(account,"acc.pos_Z") local rotacio = getAccountData(account,"acc.Rot" or 0) local interior = getAccountData(account,"acc.interior" or 0) local dimenzio = getAccountData(account,"acc.dimension" or 0) local kinezet = getAccountData(account,"acc.skinID" or 0) local elet = getAccountData(account,"acc.health" or 0) local armor = getAccountData(account,"acc.armor" or 0) local bank = getAccountData(account,"acc.bank" or 0) local admin = getAccountData(account,"acc.admin" or 0) local rcPoints = getAccountData(account,"acc.rcPoints" or 0) local fegyverek = getAccountData(account,"acc.Weapons") local teamname = getAccountData(account,"acc.squad") local money = getAccountData(account,"acc.money") local team = teamname and getTeamFromName(teamname) or nil if playerX or PlayerY or playerZ then spawnPlayer(source, playerX, playerY, playerZ, rotacio, kinezet, interior, dimenzio, team) end if elet then setElementHealth(source, elet) end if money then setElementData(source,"acc.money",money) end if rcPoints then setElementData(source,"acc.rcPoints",rcPoints) end if armor then setPedArmor(source, armor) end if bank then setElementData(source,"acc.bank",bank) end if admin then setElementData(source,"acc.admin",admin) end if (fegyverek) and not (isPedDead(source)) then takeAllWeapons(source) for weapon, ammo in pairs(fromJSON(fegyverek)) do giveWeapon(source, weapon, ammo, true) end end setCameraTarget(source, source) end) I dont rlly know what can be the problem. Anyway, here is the onPlayerQuit, for saving the datas: addEvent("accountMentese", true) addEventHandler("accountMentese",root,function (account) local accountName = getAccountName(account) local x,y,z = getElementPosition (source) local _, _, rotacio = getElementRotation(source) local interior = getElementInterior(source) local dimenzio = getElementDimension(source) local team = getPlayerTeam(source) local kinezet = getElementModel(source) local elet = getElementHealth(source) local armor = getPedArmor(source) local bank = getElementData(source,"acc.bank") local admin = getElementData(source,"acc.admin") local rcPoints = getElementData(source,"acc.rcPoints") local money = exports["rc_core"]:getMoney(source) local finalteam = team and getTeamName(team) or nil local fegyverek = getAllPedWeapon(source) setAccountData(account,"acc.bank",bank) setAccountData(account,"acc.admin",admin) setAccountData(account,"acc.rcPoints",rcPoints) setAccountData(account,"acc.Rot",rotacio) setAccountData(account,"acc.money",money) setAccountData(account,"acc.dimension",dimenzio) setAccountData(account,"acc.interior", interior) setAccountData(account,"acc.squad",finalteam) setAccountData(account,"acc.skinID",kinezet) setAccountData(account,"acc.health",elet) setAccountData(account,"acc.armor",armor) setAccountData(account,"acc.pos_X", x) setAccountData(account,"acc.pos_Y", y) setAccountData(account,"acc.pos_Z", z) if (fegyverek) and not (isPedDead(source)) then setAccountData(account, "acc.Weapons", toJSON(fegyverek)) end end) onQuit.. addEventHandler("onPlayerQuit",root,function () local account = getPlayerAccount(source) if (account) and not (isGuestAccount(account)) then triggerEvent("accountMentese", source, account) end end) Thanks any help! Edited June 29, 2017 by TheMOG Link to comment
itHyperoX Posted June 29, 2017 Author Share Posted June 29, 2017 can't edit the post. Fixed. if getAccountData(getPlayerAccount(source),"acc.protect") ~= serial then logOut(source) kickPlayer(source,"Server","Not your account!") Link to comment
pa3ck Posted June 29, 2017 Share Posted June 29, 2017 (edited) The problem I think is that you actually let the person login and then attempt to save with the new login details (account), so if my account is "John" and I login to "Jane", when you do a getPlayerAccount to save my stuff, you would save to "Jane" instead of "John". You would need to modify the code, so it would save on the oldAccount parameter in the "onPlayerLogin" event. Edit: Yea, just seen your reply... Edited June 29, 2017 by pa3ck 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