Vladimir5 Posted December 19, 2011 Share Posted December 19, 2011 I made script to save teams addEventHandler("onPlayerQuit",root, function() -- adding on player quit event hisAcc = getPlayerAccount(source) -- get the player account if hisAcc and not isGuestAccount(hisAcc) then -- if he is logged in hisTeam = getPlayerTeam(source) -- get his team if hisTeam then -- if got the team hisTeamName = getTeamName(hisTeam) -- get the team name if hisTeamName then setAccountData(hisAcc,"team",hisTeamName) -- save the team in value "team" at his account end outputDebugString( "Quit getTeamName "..tostring( hisTeamName ) ) end outputDebugString( "Quit getPlayerTeam "..tostring( hisTeam ) ) end outputDebugString( "Quit getPlayerAccount "..tostring( hisAcc ) ) end ) addEventHandler("onPlayerLogin",root, function(_,theCurrentAccount) -- adding on player login event hisAcc = theCurrentAccount hisTeamName = getAccountData(hisAcc,"team") -- get the saved value [ team name ] if hisTeamName then -- if got the value hisTeam = getTeamFromName(hisTeamName) -- get the team from the name saved if hisTeam then -- if got the team setPlayerTeam(source,hisTeam) -- set his team to the saved team end outputDebugString( "Login getTeamFromName "..tostring( hisTeam ) ) end outputDebugString( "Login getAccountData "..tostring( hisTeamName ) ) end ) And saw the error in Console... [2011-12-19 19:32:29] ERROR: Client triggered serverside event requestServerInfo, but event is not added serverside [2011-12-19 19:32:33] LOGOUT: Zer0 logged out as 'Zer0' [2011-12-19 19:32:36] INFO: Login getTeamFromName userdata: 00000072 [2011-12-19 19:32:36] INFO: Login getAccountData Team [2011-12-19 19:32:36] LOGIN: (Admin, Everyone) Zer0 successfully logged in as 'Zer0' (IP: 5.183.238.126 Serial: 0E24BA9A4E4A97C2C0991896E9D372E3) [2011-12-19 19:32:37] ERROR: Client triggered serverside event requestServerInfo, but event is not added serverside What for error? Link to comment
Vladimir5 Posted December 19, 2011 Author Share Posted December 19, 2011 Help please! Link to comment
Xeno Posted December 19, 2011 Share Posted December 19, 2011 Show us the server side. Link to comment
Vladimir5 Posted December 19, 2011 Author Share Posted December 19, 2011 addEventHandler("onPlayerQuit",root, function() -- adding on player quit event hisAcc = getPlayerAccount(source) -- get the player account if hisAcc and not isGuestAccount(hisAcc) then -- if he is logged in hisTeam = getPlayerTeam(source) -- get his team if hisTeam then -- if got the team hisTeamName = getTeamName(hisTeam) -- get the team name if hisTeamName then setAccountData(hisAcc,"team",hisTeamName) -- save the team in value "team" at his account end outputDebugString( "Quit getTeamName "..tostring( hisTeamName ) ) end outputDebugString( "Quit getPlayerTeam "..tostring( hisTeam ) ) end outputDebugString( "Quit getPlayerAccount "..tostring( hisAcc ) ) end ) addEventHandler("onPlayerLogin",root, function(_,theCurrentAccount) -- adding on player login event hisAcc = theCurrentAccount hisTeamName = getAccountData(hisAcc,"team") -- get the saved value [ team name ] if hisTeamName then -- if got the value hisTeam = getTeamFromName(hisTeamName) -- get the team from the name saved if hisTeam then -- if got the team setPlayerTeam(source,hisTeam) -- set his team to the saved team end outputDebugString( "Login getTeamFromName "..tostring( hisTeam ) ) end outputDebugString( "Login getAccountData "..tostring( hisTeamName ) ) end ) It is server.lua Link to comment
Xeno Posted December 19, 2011 Share Posted December 19, 2011 1. Use LUA tags 2. Where in that script is requestServerInfo ? -.- Link to comment
Vladimir5 Posted December 19, 2011 Author Share Posted December 19, 2011 Can you sumbit code? Link to comment
Xeno Posted December 19, 2011 Share Posted December 19, 2011 no. This is not a request a script forum. Link to comment
Xeno Posted December 19, 2011 Share Posted December 19, 2011 I felt bad so here... I use this function setTeam() local account = getPlayerAccount(source) -- gets players account local team = getAccountData (account, "team") -- gets players team if (team) and getTeamFromName(team) then setPlayerTeam(source, getTeamFromName(team)) -- sets players team end end addEventHandler("onPlayerLogin",root,setTeam) -- sets players team on login function save() local team = getPlayerTeam(source) -- Gets the players team local account = getPlayerAccount(source) if (team) and not isGuestAccount(account) then -- Checks to see if the player is a guest or not setAccountData(account, "team", getTeamName(team)) --saves team end end addEventHandler("onPlayerQuit", getRootElement(), save) -- saves team on quit Link to comment
Vladimir5 Posted December 19, 2011 Author Share Posted December 19, 2011 I'll test it,thanks. Nice job man! Works! Link to comment
Xeno Posted December 19, 2011 Share Posted December 19, 2011 I'll test it,thanks.Nice job man! Works! No problem 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