Batista Posted December 15, 2011 Share Posted December 15, 2011 Hello all, I want to do a script that save the team when I quit, and when I login again I return to the same team. Please help me with it. Thank you. Link to comment
Castillo Posted December 15, 2011 Share Posted December 15, 2011 (edited) I won't give you the script himself, but the functions/events you can use. Functions: getPlayerTeam -- To get the player team. getTeamName -- To get the player team name. getPlayerAccount -- To get the player account. setAccountData -- To save the team name in his account. getAccountData -- To get the saved team name in his account. getTeamFromName -- To get a team by it's name. setPlayerTeam -- To set the player team. Events: [url=https://wiki.multitheftauto.com/wiki/OnPlayerQuit]https://wiki.multitheftauto.com/wiki/OnPlayerQuit[/url] [url=https://wiki.multitheftauto.com/wiki/OnPlayerLogin]https://wiki.multitheftauto.com/wiki/OnPlayerLogin[/url] Click on the links and start learning. Edited December 15, 2011 by Guest Link to comment
TAPL Posted December 15, 2011 Share Posted December 15, 2011 you forgot this setPlayerTeam Link to comment
Al3grab Posted December 15, 2011 Share Posted December 15, 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 setAccountData(hisAcc,"team",hisTeamName) -- save the team in value "team" at his account end end 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 end end ) Link to comment
Castillo Posted December 15, 2011 Share Posted December 15, 2011 @Al3grab: Are you f**** stu***?? I wanted him to make it, not to get the complete script, now he'll just copy and paste it on a Lua file and say "thanks". Link to comment
Al3grab Posted December 15, 2011 Share Posted December 15, 2011 @Al3grab: Are you f**** stu***?? I wanted him to make it, not to get the complete script, now he'll just copy and paste it on a Lua file and say "thanks". i'm bored Link to comment
BinSlayer1 Posted December 15, 2011 Share Posted December 15, 2011 well, as long as there are still people around there who will give out full working scripts.. Actually, another way of learning is to get a complete script and trying to understand how everything fits together; and it's rather effective than attempting to create a script from scratch as a newbie Link to comment
Batista Posted December 15, 2011 Author Share Posted December 15, 2011 Thank you Al3agrab. @SolidSnake, the person know from his mistakes and from othres help. I try to do one with the functions that you give it to me and I didn't, it's hard for a new scripter as me, with Al3agrab help I know more about that. Link to comment
Castillo Posted December 15, 2011 Share Posted December 15, 2011 Oh c'mon, you didn't even try to make it, you just copied it like I said. Link to comment
Batista Posted December 15, 2011 Author Share Posted December 15, 2011 No, at the first I try to make one, but I find it hardly. When I have a look at this topic, I found that Al3agrab post it, so I start readingit to know how he do it. 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