Jump to content

Please help!!!


Vladimir5

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...