justn Posted March 15, 2014 Share Posted March 15, 2014 (edited) Hi so. Unfortunately, the problem is on line 18, if the player has logged into the account for the first time. the money does not set to $2000. function onQuit (quitType, reason, responsibleElement) if not (isGuestAccount (getPlayerAccount (source))) then account = getPlayerAccount (source) if (account) then local x,y,z = getElementPosition (source) setAccountData (account, "firstTime", tostring (getPlayerMoney (source))) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function assigntheteam (old, acc) local acc = getPlayerAccount(source) local firstTime = getAccountData(acc, 'firstTime') if (not firstTime) then setPlayerTeam(source, Unemployed) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) setPlayerMoney ( source, 2000 ) setAccountData(acc, 'firstTime', 'true') fadeCamera(source, true) setCameraTarget(source, source) else spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0) local playerMoney = getAccountData (acc, "firstTime") setPlayerMoney (source, playerMoney) fadeCamera(source, true) setCameraTarget(source, source) end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam) Edited March 15, 2014 by Guest Link to comment
Anubhav Posted March 15, 2014 Share Posted March 15, 2014 Try using givePlayerMoney instead of setPlayerMoney Link to comment
justn Posted March 15, 2014 Author Share Posted March 15, 2014 Try using givePlayerMoney instead of setPlayerMoney Still doesn't work. Link to comment
justn Posted March 15, 2014 Author Share Posted March 15, 2014 Nope No errors in debugscript. Link to comment
Anubhav Posted March 15, 2014 Share Posted March 15, 2014 Try adding a output for it. If it works then maybe its working. Link to comment
justn Posted March 15, 2014 Author Share Posted March 15, 2014 The output works, well there must be a problem in the setPlayerMoney Link to comment
DNL291 Posted March 15, 2014 Share Posted March 15, 2014 Try this: function onQuit () local account = getPlayerAccount(source) if account and not (isGuestAccount (account)) then setAccountData (account, "firstTime", tostring (getPlayerMoney (source))) end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function assigntheteam (old, acc) local acc = acc or getPlayerAccount(source) local firstTime = getAccountData(acc, 'firstTime') if not firstTime then setPlayerTeam(source, Unemployed) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) fadeCamera(source, true) setPlayerMoney ( source, 2000 ) setCameraTarget(source, source) setAccountData(acc, 'firstTime', 'true') else spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0) local playerMoney = getAccountData (acc, "firstTime") setPlayerMoney (source, tonumber(playerMoney)) fadeCamera(source, true) setCameraTarget(source, source) end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam) Link to comment
justn Posted March 15, 2014 Author Share Posted March 15, 2014 Thanks. but i have one more problem, i added x,y,z,interior,dimension (also added skin) to save the player's position/skin when he leaves the server and joins back in, but the problem is, when i create new account and login, it works fine, but when i reconnect, it spawns me in the middle of the map. If anyone can help me it would be a pleasure, and actually, this is the only thing i need help with in the script function onQuit () local account = getPlayerAccount(source) if account and not (isGuestAccount (account)) then local x,y,z = getElementPosition (source) setAccountData (account, "firstTime", tostring (getPlayerMoney (source))) setAccountData (account, "firstTime", x) setAccountData (account, "firstTime", y) setAccountData (account, "firstTime", z) setAccountData (account, "firstTime", tostring (getPedSkin (source))) setAccountData (account, "firstTime", getElementInterior (source)) setAccountData (account, "firstTime", getElementDimension (source)) local team = getPlayerTeam(source) if (team) and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) end end end addEventHandler ("onPlayerQuit", getRootElement(), onQuit) function assigntheteam (old, acc) local acc = acc or getPlayerAccount(source) local firstTime = getAccountData(acc, 'firstTime') if not firstTime then setPlayerTeam(source, Unemployed) spawnPlayer(source, 1643.40002, -2249.10009, 13.300, 178.0004, 0, 0, 0, Unemployed) fadeCamera(source, true) setPlayerMoney ( source, 2000 ) setCameraTarget(source, source) setAccountData(acc, 'firstTime', 'true') else local playerMoney = getAccountData (acc, "firstTime") local playerSkin = getAccountData (acc, "firstTime") local playerInt = getAccountData (acc, "firstTime") local playerDim = getAccountData (acc, "firstTime") local playerX = getAccountData (acc, "firstTime") local playerY = getAccountData (acc, "firstTime") local playerZ = getAccountData (acc, "firstTime") setPlayerMoney (source, tonumber(playerMoney)) spawnPlayer (source, playerX, playerY, playerZ +1, 0, playerSkin, playerInt, playerDim) -- -- FOR TEAM local team = getAccountData (acc, "team") if (team) and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) -- fadeCamera(source, true) setCameraTarget(source, source) end end end addEvent ( "IfNewPlayerJoin", true ) addEventHandler ( "IfNewPlayerJoin", getRootElement(), assigntheteam ) addEventHandler ("onPlayerLogin", getRootElement(), assigntheteam) Link to comment
JR10 Posted March 15, 2014 Share Posted March 15, 2014 Really? Check your setAccountData lines, they all modify the same account data 'firstTime'. Change each to something else. setAccountData (account, "firstTime", x) setAccountData (account, "firstTime", y) setAccountData (account, "firstTime", z) Should be: setAccountData (account, "posX", x) setAccountData (account, "posY", y) setAccountData (account, "posZ", z) Now change the rest, and don't forget to update the getAccountData lines. 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