ZeyadGTX Posted July 18, 2014 Share Posted July 18, 2014 Hello i have this script which saves team when quit but the problem is : i kicked some one from The Team when he reconnect again he joins the Team Automatic i want it saves if the player in Team or not because when i kick my self from the team when i reconnect i join the team again automatic 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
DNL291 Posted July 18, 2014 Share Posted July 18, 2014 Use setAccountData to remove the player's team when you kick him from the team. Link to comment
ZeyadGTX Posted July 18, 2014 Author Share Posted July 18, 2014 can you explain with script ? Link to comment
cheez3d Posted July 18, 2014 Share Posted July 18, 2014 When the player quits you only store data in the "team" key if the player is in a team. You skip the case if getPlayerTeam returns false. Check if there was no team found and set "false" inside the "team" key and then when he joins, check if the string from the account data is "false" and skip the setting of the team if so, else set it's team to getTeamFromName(getAccountData(account,"team)). Link to comment
ZeyadGTX Posted July 18, 2014 Author Share Posted July 18, 2014 can't you help me with script ! Link to comment
cheez3d Posted July 18, 2014 Share Posted July 18, 2014 Do you want to learn anything or just ask us for help for the rest of your life? Link to comment
ZeyadGTX Posted July 18, 2014 Author Share Posted July 18, 2014 tell me what functions Link to comment
Et-win Posted July 18, 2014 Share Posted July 18, 2014 tell me what functions Or you are just going to read the scripting tutorials so you know how to do the basics. If you want free scripts, then move to https://community.multitheftauto.com/ and download them there. We are not your slaves here to give you every script you want. Go learn the basics, go learn understand what the scripts are actually doing at every rule. Then you LEARN to script something like this EASILY. Link to comment
Mr_Moose Posted July 21, 2014 Share Posted July 21, 2014 Replace from line 13 to this: if team and not isGuestAccount(account) then setAccountData(account, "team", getTeamName(team)) elseif not team then setAccountData(account, "team", getTeamFromName("Insert_teme_here")) end Personally I would use the solution provided by Cheez3D, but since that wasn't good enough for you, we're making it the hard way. This solves the special case but causes new issues if you want to have team less players too, which I wouldn't recommend, it's all up to you now. Link to comment
ZeyadGTX Posted July 21, 2014 Author Share Posted July 21, 2014 But This adds A Team For Guest ? Link to comment
Mr_Moose Posted July 22, 2014 Share Posted July 22, 2014 But This adds A Team For Guest ? Exactly, I assume this is what you wanted to do since you rejected the idea of handling the special case at login. 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