JohnLehn Posted January 20, 2021 Share Posted January 20, 2021 Hello! I have a faction system for a Roleplay Server, made by me. I know i can use Owl Faction System, but i don't want. Bellow is my script. This is the problem: When i set a guy in a faction with [/setfactionleader <Name> <FactionID>] and he leaves, i doesn't save. And when he reconnects on server i must set him again the leader. How can i make it save? Here is my script. function makeleader (thePlayer, cmd, targetplayer, fraki) local Spielerdersoll = getPlayerFromName(targetplayer) local admin = getPlayerAccount(thePlayer) if (admin) then if getAccountData(admin, "rp.admin") == 3 then local Spieleracc = getPlayerAccount(Spielerdersoll) if (Spieleracc) then if fraki == "1" then outputChatBox("#ffffff"..targetplayer.." #ffffffis now the lider of LSPD!", thePlayer,255, 255, 0, true) outputChatBox("#990000Admin "..getPlayerName(thePlayer).." #ffffffhas promoted you to the function of LSPD leader!", Spielerdersoll, 255, 255, 0, true) setAccountData(Spieleracc, "rp.fraktion", 1) setAccountData(Spieleracc, "rp.rank", 7) setPlayerTeam(Spielerdersoll, team1) elseif fraki == "2" then outputChatBox("#ffffff"..targetplayer.." #ffffffis now the lider of Grove Street!", thePlayer,255, 255, 0, true) outputChatBox("#990000Admin "..getPlayerName(thePlayer).." #ffffffhas promoted you to the function of Grove Street leader!", Spielerdersoll, 255, 255, 0, true) setPlayerTeam(Spielerdersoll, team2) setAccountData(Spieleracc, "rp.fraktion", 2) setAccountData(Spieleracc, "rp.rank", 7) elseif fraki == "0" then outputChatBox("#ffffffYou set "..targetplayer.." #ffffffto Civilian!", thePlayer,255, 255, 0, true) outputChatBox("#990000Admin "..getPlayerName(thePlayer).." #ffffff has demoted you to Civillian.", Spielerdersoll, 255, 255, 255, true) setAccountData(Spieleracc, "rp.fraktion", 0) setAccountData(Spieleracc, "rp.rank", 0) end else outputChatBox("Player not found!", thePlayer, 255, 0, 0) end else outputChatBox("You are not an admin!", thePlayer, 255, 0, 0) end end end addCommandHandler("setfactionleader", makeleader) Link to comment
SpecT Posted January 20, 2021 Share Posted January 20, 2021 (edited) Well the code you have shown seems correct and it should save the data just fine. But you should add a handler when the player logs in (onPlayerLogin) and check (with getAccountData) if he has any rank and then do setPlayerTeam to the player. Edited January 20, 2021 by SpecT 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