toptional Posted May 14, 2013 Share Posted May 14, 2013 Why won't this work D: no debug errors function saveStats() account = getPlayerAccount(source) setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) end addEventHandler("onPlayerLogout",getRootElement(),saveStats) addEventHandler("onPlayerQuit",getRootElement(),saveStats) function loadStats() account = getPlayerAccount(source) x = getAccountData ( account, "CMG2.Xpos" ) y = getAccountData ( account, "CMG2.Ypos" ) z = getAccountData ( account, "CMG2.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,0,skin) setCameraTarget(source) fadeCamera(source,true,2.5) else spawnPlayer(source,0,0,999999) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) (I chopped this off my larger script script becuase everything else worked like the health and ammo! Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 Why won't this work D: no debug errors function saveStats() account = getPlayerAccount(source) setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) end addEventHandler("onPlayerLogout",getRootElement(),saveStats) addEventHandler("onPlayerQuit",getRootElement(),saveStats) function loadStats() account = getPlayerAccount(source) x = getAccountData ( account, "CMG2.Xpos" ) y = getAccountData ( account, "CMG2.Ypos" ) z = getAccountData ( account, "CMG2.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,0,skin) setCameraTarget(source) fadeCamera(source,true,2.5) else spawnPlayer(source,0,0,999999) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) (I chopped this off my larger script script becuase everything else worked like the health and ammo! The 'skin' argument it not defined use : getElementModel Also the x and y and z on the setAccountData function is not defined use : getElementPosition With the account data function's . Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 skin is defined earlier in the script would this be fine for the x y z? x,y,z = getElementPosition x = getAccountData ( account, "CMG2.Xpos" ) y = getAccountData ( account, "CMG2.Ypos" ) z = getAccountData ( account, "CMG2.Zpos" ) Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 -- # Server Side Not Tested But I Hope It Work : function saveStats() local x,y,z = getElementPosition ( source ) local skin = getElementModel ( source ) local account = getPlayerAccount( source ) if not isGuestAccount ( account ) then setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) setAccountData ( account, "CMG2.skin", skin ) end end addEventHandler("onPlayerLogout",getRootElement(),saveStats) addEventHandler("onPlayerQuit",getRootElement(),saveStats) function loadStats(_,account) local x = getAccountData ( account, "CMG2.Xpos" ) local y = getAccountData ( account, "CMG2.Ypos" ) local z = getAccountData ( account, "CMG2.Zpos" ) local skin = getAccountData ( account, "CMG2.skin" ) if x and y and z and skin then spawnPlayer(source,x,y,z + 0.5,0,skin) setCameraTarget(source) fadeCamera(source,true,2.5) else spawnPlayer(source,0,0,999999,0,0) setCameraTarget(source) fadeCamera(source,true,2.5) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 Got another issue with spawning the player and with his skin! It won't work function saveStats() account = getPlayerAccount(source) Skin = getElementModel(source) setAccountData (account,"CMG2.skin",tostring(Skin) ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) end addEventHandler("onPlayerLogout",getRootElement(),saveStats) addEventHandler("onPlayerQuit",getRootElement(),saveStats) function loadStats() account = getPlayerAccount(source) skin = getAccountData (account,"CMG2.skin" ) if skin then setTimer (setElementModel,source, skin) end x = getAccountData ( account, "CMG2.Xpos" ) y = getAccountData ( account, "CMG2.Ypos" ) z = getAccountData ( account, "CMG2.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,tonumber(skin),0) setCameraTarget(source) fadeCamera(source,true,2.5) else --spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) Link to comment
Moderators IIYAMA Posted May 14, 2013 Moderators Share Posted May 14, 2013 You forgot the rotation. spawnPlayer(source,x,y,z+.5,0,tonumber(skin),0) spawnPlayer (thePlayer, x, y, z, rotation, skinID,interior ) Try this: function saveStats() local account = getPlayerAccount(source) if not isGuestAccount (account ) then local Skin = getElementModel(source) setAccountData (account,"CMG2.skin",tostring(Skin) ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) end end addEventHandler("onPlayerLogout",root,saveStats) addEventHandler("onPlayerQuit",root,saveStats) addEventHandler("onPlayerLogin",root, function ()--loadStats local account = getPlayerAccount(source) local skin = getAccountData (account,"CMG2.skin" ) local x,y,z = getAccountData ( account, "CMG2.Xpos" ),getAccountData ( account, "CMG2.Ypos" ),getAccountData ( account, "CMG2.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,0,tonumber(skin) or 0,0) setCameraTarget(source) fadeCamera(source,true,2.5) else --spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end) Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 Ok it works but the skin doesn't keep the same D: It has skin ID 0 all the time Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 (edited) -- # Server Side addEventHandler("onPlayerQuit",root, function ( ) local account = getPlayerAccount(source) if not isGuestAccount (account ) then local Skin = getElementModel(source) setAccountData (account,"CMG2.skin",Skin ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) end end ) addEventHandler("onPlayerLogout",root, function ( account ) if not isGuestAccount (account ) then local Skin = getElementModel(source) setAccountData (account,"CMG2.skin",Skin ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMG2.Xpos", x ) setAccountData ( account, "CMG2.Ypos", y ) setAccountData ( account, "CMG2.Zpos", z ) end end ) addEventHandler("onPlayerLogin",root, function ( _,account ) local skin = getAccountData (account,"CMG2.skin" ) local x,y,z = getAccountData ( account, "CMG2.Xpos" ),getAccountData ( account, "CMG2.Ypos" ),getAccountData ( account, "CMG2.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,0,tonumber(skin),0) setCameraTarget(source) fadeCamera(source,true,2.5) else -- spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end) Edited May 14, 2013 by Guest Link to comment
PaiN^ Posted May 14, 2013 Share Posted May 14, 2013 addEventHandler("onPlayerLogout",root, function ( account ) Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 addEventHandler("onPlayerLogout",root, function ( account ) Oh yes forget this line edited Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 Here's the whole script It makes more sense lol function saveStats() account = getPlayerAccount(source) if not isGuestAccount (account ) then local Skin = getElementModel(source) setAccountData (account,"CMGRP.skin",tostring(Skin) ) local Health = getElementHealth ( source ) setAccountData ( account, "CMGRP.health", tostring(Health) ) local Money = getPlayerMoney ( source ) setAccountData ( account, "CMGRP.money", Money ) local Armour = getPedArmor ( source ) setAccountData ( account, "CMGRP.armour", tostring(Armour) ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMGRP.Xpos", x ) setAccountData ( account, "CMGRP.Ypos", y ) setAccountData ( account, "CMGRP.Zpos", z ) end end addEventHandler("onPlayerLogout",getRootElement(),saveStats) addEventHandler("onPlayerQuit",getRootElement(),saveStats) function loadStats() account = getPlayerAccount(source) local skin = getAccountData (account,"CMGRP.skin" ) if skin then setTimer (setElementModel,source, skin) end local health = getAccountData ( account, "CMGRP.health" ) if health then setTimer (setElementHealth, 500, 1, source, health) end local money = getAccountData ( account, "CMGRP.money" ) if money then setPlayerMoney ( source, money ) end local armour = getAccountData ( account, "CMGRP.armour" ) if armour then setTimer (setPedArmor, 500, 1, source, armour) end x = getAccountData ( account, "CMGRP.Xpos" ) y = getAccountData ( account, "CMGRP.Ypos" ) z = getAccountData ( account, "CMGRP.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,tonumber(skin),0) setCameraTarget(source) fadeCamera(source,true,2.5) else --spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) Link to comment
PaiN^ Posted May 14, 2013 Share Posted May 14, 2013 Use #Mr.Pres[T]ege's edited code . Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 -- # Server Side addEventHandler("onPlayerQuit",getRootElement(), function ( ) account = getPlayerAccount(source) if not isGuestAccount (account ) then local Skin = getElementModel(source) setAccountData (account,"CMGRP.skin",Skin ) local Health = getElementHealth ( source ) setAccountData ( account, "CMGRP.health",Health ) local Money = getPlayerMoney ( source ) setAccountData ( account, "CMGRP.money", Money ) local Armour = getPedArmor ( source ) setAccountData ( account, "CMGRP.armour", Armour ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMGRP.Xpos", x ) setAccountData ( account, "CMGRP.Ypos", y ) setAccountData ( account, "CMGRP.Zpos", z ) end end ) addEventHandler("onPlayerLogout",getRootElement(), function ( account ) if not isGuestAccount (account ) then local Skin = getElementModel(source) setAccountData (account,"CMGRP.skin",Skin ) local Health = getElementHealth ( source ) setAccountData ( account, "CMGRP.health", Health ) local Money = getPlayerMoney ( source ) setAccountData ( account, "CMGRP.money", Money ) local Armour = getPedArmor ( source ) setAccountData ( account, "CMGRP.armour", Armour ) local x,y,z = getElementPosition(source) setAccountData ( account, "CMGRP.Xpos", x ) setAccountData ( account, "CMGRP.Ypos", y ) setAccountData ( account, "CMGRP.Zpos", z ) end end ) function loadStats( _,account ) local skin = getAccountData (account,"CMGRP.skin" ) setTimer(setElementModel,500,1,source, skin) local health = getAccountData ( account, "CMGRP.health" ) if health then setTimer (setElementHealth, 500, 1, source, health) end local money = getAccountData ( account, "CMGRP.money" ) setPlayerMoney ( source, money ) local armour = getAccountData ( account, "CMGRP.armour" ) setTimer (setPedArmor, 500, 1, source, armour) x = getAccountData ( account, "CMGRP.Xpos" ) y = getAccountData ( account, "CMGRP.Ypos" ) z = getAccountData ( account, "CMGRP.Zpos" ) if x and y and z then spawnPlayer(source,x,y,z + 0.5,tonumber(skin),0) setCameraTarget(source) fadeCamera(source,true,2.5) else --spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) Use this one because you add more things armor , health , etc.! Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 (edited) Thanks sorted it Great. Edited May 14, 2013 by Guest Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 I have another issue D: I don't know why but the teams arn't saving Server part - This is triggered when you first join the server and have to choose a skin, once that is done it saves your team as unemployed addEvent("lookSkin",true) addEventHandler("lookSkin",root,function(skin) setAccountData ( getPlayerAccount(source), "CMGRP.team", "Unemployed" ) givePlayerMoney(source,10000) giveWeapon ( source, 22, 90, true ) giveWeapon ( source, 4, 1, false ) setElementModel(source,skin) --setPlayerTeam ( source,Unemployed) end) In the save script here is the server side part addEventHandler("onPlayerQuit",getRootElement(), function ( ) account = getPlayerAccount(source) if not isGuestAccount (account ) then local Team = getPlayerTeam ( source ) setAccountData (account, "CMGRP.team",Team) end end ) addEventHandler("onPlayerLogout",getRootElement(), function ( account ) if not isGuestAccount (account ) then local Team = getPlayerTeam ( source ) setAccountData (account, "CMGRP.team",Team) end end ) function loadStats( _,account ) local team = getAccountData ( source, "CMGRP.team") setPlayerTeam (source,team) if x and y and z then spawnPlayer(source,x,y,z + 0.5,tonumber(skin),0) setCameraTarget(source) fadeCamera(source,true,2.5) else --spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) I've took out the unimportant stuff don't worry everything is defined, maybe not at the team part thats where the issue is D: Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 Unemployed = ?? Where do you create the team ? Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 Eariler in the script here: local Unemployed = createTeam ( "Unemployed",236,92,178) Link to comment
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 -- # Server Side addEventHandler("onPlayerQuit",getRootElement(), function ( ) account = getPlayerAccount(source) if not isGuestAccount (account ) then local Team = getPlayerTeam ( source ) if Team then local teamName = getTeamName ( Team ) setAccountData (account, "CMGRP.team",teamName) end end end ) addEventHandler("onPlayerLogout",getRootElement(), function ( account ) if not isGuestAccount (account ) then local Team = getPlayerTeam ( source ) if Team then local teamName = getTeamName ( Team ) setAccountData (account, "CMGRP.team",teamName) end end end ) function loadStats( _,account ) local team = getAccountData ( account, "CMGRP.team" ) setPlayerTeam (source,getTeamFromName(tostring(team))) if x and y and z then spawnPlayer(source,x,y,z + 0.5,tonumber(skin),0) setCameraTarget(source) fadeCamera(source,true,2.5) else --spawnPlayer(source,0,0,999999) --setCameraTarget(source) --fadeCamera(source,true,2.5) end end addEventHandler("onPlayerLogin",getRootElement(),loadStats) Link to comment
toptional Posted May 14, 2013 Author Share Posted May 14, 2013 Thanks for all this help it worked! 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