Jump to content

Save player team


Xedo

Recommended Posts

Posted

hi gyus. I try to save team to account but every time after reconnect i'm not in saved team o_O, can anyone help me please?

Posted

meta.xml:

<meta>
<script src="saveteam.lua" type="server" /> 
</meta>

saveteam.lua:

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
if  not (isGuestAccount (getPlayerAccount (source))) then
local playerTeam = getAccountData (theCurrentAccount, "team")
setPlayerTeam(source,playerTeam)
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)
 
function onQuit (quitType, reason, responsibleElement,thePreviousAccount)
if not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
if (account) then
local team = getPlayerTeam(source)
local teamName = getTeamName(team)
setAccountData (account, "team", teamName)
end
end
end
addEventHandler ("onPlayerQuit", getRootElement(), onQuit)

this should work.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

tnx, but it doesn't works too :(

i made something like you yesterday

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
 if  not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
   if (accountData) then
local playerTeam = getAccountData (theCurrentAccount, "Team")
 
     spawnPlayer (source, playerteam)
   end
 end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)
 
function onQuit (quitType, reason, responsibleElement)
 if not (isGuestAccount (getPlayerAccount (source))) then
   account = getPlayerAccount (source)
   if (account) then
     setAccountData (account, "Team", getPlayerTeam (source))
   end
 end
end
addEventHandler ("onPlayerQuit", getRootElement(), onQuit)

Posted

fixed function from solidsnake script

function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
if  not (isGuestAccount (getPlayerAccount (source))) then
local playerTeam = getAccountData (theCurrentAccount, "team")
local teamElement = getTeamFromName(playerTeam)
if (teamElement) then
setPlayerTeam(source,playerTeam)
end
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)

not tested too, should work

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

Can someone answer me: What's the point of using getPlayerAccount in onPlayerLogin event?

People, think for a moment. Also, can you login to a guest account? I'm pretty sure the 2nd line is pointless.

"it doesn't work" is as helpful to us as saying "Jump!" to a depressed person standing on a cliff.

Posted

i was thinking about it too, but when i saw the same in another topic i just left my will to ask..

Haha, last sentence is great :D

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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...