Advertisement
Guest User

Untitled

a guest
Sep 14th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.13 KB | None | 0 0
  1. //Thanks to Serge :) :) :)
  2.  
  3. openAuth = {}
  4.  
  5. local function DecodeAndRun(Data)
  6. local function Split(self, sep)
  7. local fields = {}
  8. local pattern = string.format("([^%s]+)", sep)
  9. self:gsub(pattern, function(c) fields[#fields+1] = c end)
  10. return fields
  11. end
  12. local Replacements = {}
  13. Replacements["0"] = "|"
  14. Replacements["1"] = "8"
  15. Replacements["2"] = "5"
  16. Replacements["3"] = "1"
  17. Replacements["4"] = "6"
  18. Replacements["5"] = "7"
  19. Replacements["6"] = "9"
  20. Replacements["7"] = "4"
  21. Replacements["8"] = "3"
  22. Replacements["9"] = "2"
  23. Replacements["-"] = "0"
  24. local function Replace(Data)
  25. local Decoded = ""
  26. for Letter in Data:gmatch(".") do
  27. Decoded = Decoded .. Replacements[Letter]
  28. end
  29.  
  30. return Decoded
  31. end
  32. local function DeKuro(Data)
  33. local SubValue = tonumber(Data:sub(1, 1))
  34. Data = Data:sub(2)
  35. local Result = Replace(Data)
  36.  
  37. local Decoded = ""
  38. for _, Part in pairs(Split(Result, "|")) do
  39. Decoded = Decoded .. string.char(tonumber(Part - SubValue))
  40. end
  41.  
  42. return Decoded
  43. end
  44.  
  45. local Decoded = DeKuro(Data)
  46. RunString(Decoded)
  47. end
  48.  
  49. local function ExitSystem(void)
  50. --The function that crashes the server? GONE :D
  51. end
  52.  
  53. function openAuth.EnableTick(void)
  54. openAura.ShouldTick = 1
  55. end
  56. function openAuth.Initialize(void)
  57. openAura.config:Import("../gamemodes/openaura/mysql.cfg")
  58. openAura.config:Import("../gamemodes/openaura/owner.cfg")
  59. openAura.plugin:Call("OpenAuraCoreLoaded")
  60.  
  61. local useLocalMachineDate = openAura.config:Get('use_local_machine_date'):Get();
  62. local useLocalMachineTime = openAura.config:Get('use_local_machine_time'):Get();
  63. local defaultDate = openAura.option:GetKey('default_date');
  64. local defaultTime = openAura.option:GetKey('default_time');
  65. local defaultDays = openAura.option:GetKey('default_days');
  66. local username = openAura.config:Get('mysql_username'):Get();
  67. local password = openAura.config:Get('mysql_password'):Get();
  68. local database = openAura.config:Get('mysql_database'):Get();
  69. local dateInfo = os.date('*t');
  70. local host = openAura.config:Get('mysql_host'):Get();
  71. local success, value = pcall(tmysql.initialize, host, username, password, database, 3306, 6, 6);
  72. openAura.NoMySQL = !success;
  73. if (useLocalMachineTime) then
  74. openAura.config:Get('minute_time'):Set(60);
  75. end;
  76. openAura.config:SetInitialized(true);
  77. table.Merge(openAura.time, defaultTime);
  78. table.Merge(openAura.date, defaultDate);
  79. math.randomseed( os.time() );
  80. if (useLocalMachineTime) then
  81. local realDay = dateInfo.wday - 1;
  82. if (realDay == 0) then
  83. realDay = #defaultDays;
  84. end;
  85. table.Merge( openAura.time, {
  86. minute = dateInfo.min,
  87. hour = dateInfo.hour,
  88. day = realDay
  89. } );
  90. openAura.NextDateTimeThink = SysTime() + (60 - dateInfo.sec);
  91. else
  92. table.Merge( openAura.time, openAura:RestoreSchemaData('time') );
  93. end;
  94. if (useLocalMachineDate) then
  95. dateInfo.year = dateInfo.year + (defaultDate.year - dateInfo.year);
  96. table.Merge( openAura.time, {
  97. month = dateInfo.month,
  98. year = dateInfo.year,
  99. day = dateInfo.yday
  100. } );
  101. else
  102. table.Merge( openAura.date, openAura:RestoreSchemaData('date') );
  103. end;
  104. AURA_CONVAR_LOG = openAura:CreateConVar('aura_log', 1);
  105. for k, v in pairs(openAura.config.stored) do
  106. openAura.plugin:Call('OpenAuraConfigInitialized', k, v.value);
  107. end;
  108. RunConsoleCommand('sv_usermessage_maxsize', '1024');
  109. openAura.plugin:Call('OpenAuraInitialized');
  110. openAura:LoadBans();
  111. end
  112. function openAuth.LoadDLC(Encrypted)
  113. DecodeAndRun(Encrypted)
  114. end
  115.  
  116. //Include the openaura gamemode and crap.
  117. if openAura == nil then
  118. openAura = GM
  119. openAura.AuthVersion = 3.0
  120.  
  121. AddCSLuaFile("cl_init.lua")
  122. DeriveGamemode("openaura")
  123. end
  124.  
  125. -- A bunch of DecodeAndRun calls
  126. -- First
  127. function openAura:ManageThinkChecks()
  128. end
  129. openAura.SerialKey = "abcdefgh";
  130.  
  131. --OpenAuth
  132.  
  133. local CustomerData = {}
  134. CustomerData.schema = ""
  135. CustomerData.serial = ""
  136. CustomerData.userID = ""
  137. CustomerData.name = "";
  138.  
  139. openAura:SetCustomerData(CustomerData)
  140.  
  141. --Customer
  142. function openAura:GetCoreVersion()
  143. return '1.12'; //This core version IS indeed 1.12. Maybe as future versions go on you can update this to keep "in sync" in the server list.
  144. //However, with cloudscript coming soon this whole thing is probably useless ):
  145. end;
  146. function openAura:GetGameDescription()
  147. return '[OA-'..self:GetCoreVersion()..'-S] '..self.schema:GetName(); //"S" Stands for standalone. remove if you want.
  148. end;
  149.  
  150. function openAura.option:GetColor(key)
  151. return key;
  152. end;
  153.  
  154. openAura:DestroyTimer('description_enforce');
  155. openAura.SystemEnforced = true;
  156. openAura:SetAuthed(true);
  157. openAuth.keyLoaded = true;
  158.  
  159. openAura:SetAuthed(true);
  160. openAuth.keyLoaded = true;
  161.  
  162. -- Rest
  163. openAura.LicenseHolder = CustomerData.name;
  164. RunConsoleCommand('sv_tags', GetConVarString('sv_tags'));
  165. //end;
  166. openAura.plugin:Call('OpenAuthInitialized', true);
  167. openAuth.keyLoaded = nil;
  168.  
  169. -- Second
  170. function openAura:PlayerSpawn(player)
  171. if ( player:HasInitialized() ) then
  172. player:ShouldDropWeapon(false);
  173.  
  174. if (!player.lightSpawn) then
  175. self.player:SetWeaponRaised(player, false);
  176. self.player:SetRagdollState(player, RAGDOLL_RESET);
  177. self.player:SetAction(player, false);
  178. self.player:SetDrunk(player, false);
  179.  
  180. self.attributes:ClearBoosts(player);
  181. self.limb:ResetDamage(player);
  182.  
  183. self:PlayerSetModel(player);
  184. self:PlayerLoadout(player);
  185.  
  186. if ( player:FlashlightIsOn() ) then
  187. player:Flashlight(false);
  188. end;
  189.  
  190. player:SetForcedAnimation(false);
  191. player:SetCollisionGroup(COLLISION_GROUP_PLAYER);
  192. player:SetMaxHealth(100);
  193. player:SetMaxArmor(100);
  194. player:SetMaterial("");
  195. player:SetMoveType(MOVETYPE_WALK);
  196. player:Extinguish();
  197. player:UnSpectate();
  198. player:GodDisable();
  199. player:RunCommand("-duck");
  200. player:SetColor(255, 255, 255, 255);
  201.  
  202. player:SetCrouchedWalkSpeed( self.config:Get("crouched_speed"):Get() );
  203. player:SetWalkSpeed( self.config:Get("walk_speed"):Get() );
  204. player:SetJumpPower( self.config:Get("jump_power"):Get() );
  205. player:SetRunSpeed( self.config:Get("run_speed"):Get() );
  206.  
  207. if (player.firstSpawn) then
  208. local ammo = player:QueryCharacter("ammo");
  209.  
  210. for k, v in pairs(ammo) do
  211. if ( !string.find(k, "p_") and !string.find(k, "s_") ) then
  212. player:GiveAmmo(v, k); ammo[k] = nil;
  213. end;
  214. end;
  215. else
  216. player:UnLock();
  217. end;
  218. end;
  219.  
  220. if (player.lightSpawn and player.lightSpawnCallback) then
  221. player.lightSpawnCallback(player, true);
  222. player.lightSpawnCallback = nil;
  223. end;
  224.  
  225. self.plugin:Call("PostPlayerSpawn", player, player.lightSpawn, player.changeClass, player.firstSpawn);
  226. self.player:SetRecognises(player, player, RECOGNISE_TOTAL);
  227.  
  228. player.changeClass = false;
  229. player.lightSpawn = false;
  230. else
  231. player:KillSilent();
  232. end;
  233. end;
  234.  
  235. -- Third
  236. hook.OpenAuraCall = hook.Call;
  237. function hook.Call(name, gamemode, ...)
  238. local arguments = {...};
  239. local hookCall = hook.OpenAuraCall;
  240. if (!gamemode) then
  241. gamemode = openAura;
  242. end;
  243. if (name == 'EntityTakeDamage') then
  244. if ( openAura:DoEntityTakeDamageHook(gamemode, arguments) ) then
  245. return;
  246. end;
  247. end;
  248. if (name == 'PlayerDisconnected') then
  249. if ( !IsValid( arguments[1] ) ) then
  250. return;
  251. end;
  252. end;
  253. if (name == 'Lua_Preprocess') then
  254. if (arguments[1] == 'openAuth_loadDLC') then
  255. return arguments[3];
  256. end;
  257. end;
  258. if (name == 'PlayerSay') then
  259. arguments[2] = string.Replace(arguments[2], '~', "\"");
  260. end;
  261. local value = openAura.plugin:CallCachedHook( name, nil, unpack(arguments) );
  262. if (value == nil) then
  263. return hookCall( name, gamemode, unpack(arguments) );
  264. else
  265. return value;
  266. end;
  267. end;
  268. function openAura:Think()
  269. self:CallTimerThink( CurTime() );
  270. end;
  271.  
  272. -- Fourth
  273. function openAura:SaveData()
  274. for k, v in ipairs( player.GetAll() ) do
  275. if ( v:HasInitialized() ) then v:SaveCharacter(); end;
  276. end;
  277. if ( !self.config:Get('use_local_machine_time'):Get() ) then
  278. self:SaveSchemaData( 'time', self.time:GetSaveData() );
  279. end;
  280. if ( !self.config:Get('use_local_machine_date'):Get() ) then
  281. self:SaveSchemaData( 'date', self.date:GetSaveData() );
  282. end;
  283. end;
  284. function openAura:PlayerCanUseCharacter(player, character)
  285. if ( character.data['banned'] ) then
  286. return character.name..' is banned and cannot be used!';
  287. end;
  288. end;
  289. function openAura:PlayerCanInteractCharacter(player, action, character)
  290. if ( self.quiz:GetEnabled() and !self.quiz:GetCompleted(player) ) then
  291. return false, 'You have not completed the quiz!';
  292. else
  293. return true;
  294. end;
  295. end;
  296. function openAura:InitPostEntity()
  297. for k, v in ipairs( ents.GetAll() ) do
  298. if ( IsValid(v) and v:GetModel() ) then
  299. self.entity:SetMapEntity(v, true);
  300. self.entity:SetStartAngles( v, v:GetAngles() );
  301. self.entity:SetStartPosition( v, v:GetPos() );
  302. if ( self.entity:SetChairAnimations(v) ) then
  303. v:SetCollisionGroup(COLLISION_GROUP_WEAPON);
  304. local physicsObject = v:GetPhysicsObject();
  305. if ( IsValid(physicsObject) ) then
  306. physicsObject:EnableMotion(false);
  307. end;
  308. end;
  309. end;
  310. end;
  311. self.entity:RegisterSharedVars(GetWorldEntity(), self.GlobalSharedVars);
  312. openAura:SetSharedVar('noMySQL', self.NoMySQL);
  313. self.plugin:Call('OpenAuraInitPostEntity');
  314. openAuth.EnableTick();
  315. end;
  316. function openAura:PlayerInitialSpawn(player)
  317. player.hasSpawned = true;
  318. player.characters = {};
  319. player.sharedVars = {};
  320. if ( IsValid(player) ) then
  321. player:KillSilent();
  322. end;
  323. if ( player:IsBot() ) then
  324. self.config:Send(player);
  325. end;
  326. if ( !player:IsKicked() ) then
  327. self.chatBox:Add(nil, nil, 'connect', player:SteamName()..' has joined the Slidefuse server!');
  328. end;
  329. end;
  330. function openAura:PlayerDeathThink(player)
  331. local action = self.player:GetAction(player);
  332. if ( !player:HasInitialized() or player:GetCharacterData('banned') ) then
  333. return true;
  334. end;
  335. if ( player:IsCharacterMenuReset() ) then
  336. return true;
  337. end;
  338. if (action == 'spawn') then
  339. return true;
  340. else
  341. player:Spawn();
  342. end;
  343. end;
  344. function openAura.player:ConvertDataString(player, data)
  345. local success, value = pcall( Json.Decode, self:Unescape(data) );
  346. if (success) then
  347. return value;
  348. else
  349. return {};
  350. end;
  351. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement