BananasTheKing

Faction Change Base

Jan 16th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. function ITEM:PreChangeModel(player, bIsWearing)
  2. local faction = self("changeFaction");
  3. local accessoryData = player:GetAccessoryData();
  4.  
  5. if (faction and !player.changingFaction and !player.changingClass) then
  6. if (bIsWearing) then
  7. self:ChangeFaction(player, faction);
  8. else
  9. self:ChangeFaction(player, "Citizen");
  10. end;
  11. end;
  12. end;
  13.  
  14. function ITEM:ChangeFaction(player, faction)
  15. local factionTable = CW.faction:FindByID(faction);
  16.  
  17. if (factionTable) then
  18. player:SetCharacterData("Faction", factionTable.name, true);
  19.  
  20. CW.player:SetWhitelisted(player, factionTable.name, true);
  21. CW.player:SaveCharacter(player);
  22.  
  23. if (player:HasInitialized()) then
  24. local pos, ang = player:GetPos(), player:EyeAngles();
  25.  
  26. CW.player:Notify(player, "You are now part of the "..factionTable.name.." faction.");
  27.  
  28. -- This variable is to stop scary stack overflow issues.
  29. player.changingFaction = true;
  30. CW.player:LoadCharacter(player, CW.player:GetCharacterID(player));
  31. player.changingFaction = nil;
  32.  
  33. player:SetPos(pos);
  34. player:SetEyeAngles(ang);
  35. end;
  36. end;
  37. end;
  38.  
  39.  
  40.  
  41.  
  42. --3:18 PM - skoden is now Online.
  43. 3:22 PM - skoden: https://pastebin.com/fiTqDPwy
  44. 3:23 PM - skoden: In apparel items use ITEM.changeFaction = "name";
  45. 3:23 PM - skoden: the stuff i linked goes in your apparel base
  46. 3:29 PM - skoden: paste it right in your apparel or item base depending on what you are using it with
Advertisement
Add Comment
Please, Sign In to add comment