Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Thanks to Serge :) :) :)
- openAuth = {}
- local function DecodeAndRun(Data)
- local function Split(self, sep)
- local fields = {}
- local pattern = string.format("([^%s]+)", sep)
- self:gsub(pattern, function(c) fields[#fields+1] = c end)
- return fields
- end
- local Replacements = {}
- Replacements["0"] = "|"
- Replacements["1"] = "8"
- Replacements["2"] = "5"
- Replacements["3"] = "1"
- Replacements["4"] = "6"
- Replacements["5"] = "7"
- Replacements["6"] = "9"
- Replacements["7"] = "4"
- Replacements["8"] = "3"
- Replacements["9"] = "2"
- Replacements["-"] = "0"
- local function Replace(Data)
- local Decoded = ""
- for Letter in Data:gmatch(".") do
- Decoded = Decoded .. Replacements[Letter]
- end
- return Decoded
- end
- local function DeKuro(Data)
- local SubValue = tonumber(Data:sub(1, 1))
- Data = Data:sub(2)
- local Result = Replace(Data)
- local Decoded = ""
- for _, Part in pairs(Split(Result, "|")) do
- Decoded = Decoded .. string.char(tonumber(Part - SubValue))
- end
- return Decoded
- end
- local Decoded = DeKuro(Data)
- RunString(Decoded)
- end
- local function ExitSystem(void)
- --The function that crashes the server? GONE :D
- end
- function openAuth.EnableTick(void)
- openAura.ShouldTick = 1
- end
- function openAuth.Initialize(void)
- openAura.config:Import("../gamemodes/openaura/mysql.cfg")
- openAura.config:Import("../gamemodes/openaura/owner.cfg")
- openAura.plugin:Call("OpenAuraCoreLoaded")
- local useLocalMachineDate = openAura.config:Get('use_local_machine_date'):Get();
- local useLocalMachineTime = openAura.config:Get('use_local_machine_time'):Get();
- local defaultDate = openAura.option:GetKey('default_date');
- local defaultTime = openAura.option:GetKey('default_time');
- local defaultDays = openAura.option:GetKey('default_days');
- local username = openAura.config:Get('mysql_username'):Get();
- local password = openAura.config:Get('mysql_password'):Get();
- local database = openAura.config:Get('mysql_database'):Get();
- local dateInfo = os.date('*t');
- local host = openAura.config:Get('mysql_host'):Get();
- local success, value = pcall(tmysql.initialize, host, username, password, database, 3306, 6, 6);
- openAura.NoMySQL = !success;
- if (useLocalMachineTime) then
- openAura.config:Get('minute_time'):Set(60);
- end;
- openAura.config:SetInitialized(true);
- table.Merge(openAura.time, defaultTime);
- table.Merge(openAura.date, defaultDate);
- math.randomseed( os.time() );
- if (useLocalMachineTime) then
- local realDay = dateInfo.wday - 1;
- if (realDay == 0) then
- realDay = #defaultDays;
- end;
- table.Merge( openAura.time, {
- minute = dateInfo.min,
- hour = dateInfo.hour,
- day = realDay
- } );
- openAura.NextDateTimeThink = SysTime() + (60 - dateInfo.sec);
- else
- table.Merge( openAura.time, openAura:RestoreSchemaData('time') );
- end;
- if (useLocalMachineDate) then
- dateInfo.year = dateInfo.year + (defaultDate.year - dateInfo.year);
- table.Merge( openAura.time, {
- month = dateInfo.month,
- year = dateInfo.year,
- day = dateInfo.yday
- } );
- else
- table.Merge( openAura.date, openAura:RestoreSchemaData('date') );
- end;
- AURA_CONVAR_LOG = openAura:CreateConVar('aura_log', 1);
- for k, v in pairs(openAura.config.stored) do
- openAura.plugin:Call('OpenAuraConfigInitialized', k, v.value);
- end;
- RunConsoleCommand('sv_usermessage_maxsize', '1024');
- openAura.plugin:Call('OpenAuraInitialized');
- openAura:LoadBans();
- end
- function openAuth.LoadDLC(Encrypted)
- DecodeAndRun(Encrypted)
- end
- //Include the openaura gamemode and crap.
- if openAura == nil then
- openAura = GM
- openAura.AuthVersion = 3.0
- AddCSLuaFile("cl_init.lua")
- DeriveGamemode("openaura")
- end
- -- A bunch of DecodeAndRun calls
- -- First
- function openAura:ManageThinkChecks()
- end
- openAura.SerialKey = "abcdefgh";
- --OpenAuth
- local CustomerData = {}
- CustomerData.schema = ""
- CustomerData.serial = ""
- CustomerData.userID = ""
- CustomerData.name = "";
- openAura:SetCustomerData(CustomerData)
- --Customer
- function openAura:GetCoreVersion()
- 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.
- //However, with cloudscript coming soon this whole thing is probably useless ):
- end;
- function openAura:GetGameDescription()
- return '[OA-'..self:GetCoreVersion()..'-S] '..self.schema:GetName(); //"S" Stands for standalone. remove if you want.
- end;
- function openAura.option:GetColor(key)
- return key;
- end;
- openAura:DestroyTimer('description_enforce');
- openAura.SystemEnforced = true;
- openAura:SetAuthed(true);
- openAuth.keyLoaded = true;
- openAura:SetAuthed(true);
- openAuth.keyLoaded = true;
- -- Rest
- openAura.LicenseHolder = CustomerData.name;
- RunConsoleCommand('sv_tags', GetConVarString('sv_tags'));
- //end;
- openAura.plugin:Call('OpenAuthInitialized', true);
- openAuth.keyLoaded = nil;
- -- Second
- function openAura:PlayerSpawn(player)
- if ( player:HasInitialized() ) then
- player:ShouldDropWeapon(false);
- if (!player.lightSpawn) then
- self.player:SetWeaponRaised(player, false);
- self.player:SetRagdollState(player, RAGDOLL_RESET);
- self.player:SetAction(player, false);
- self.player:SetDrunk(player, false);
- self.attributes:ClearBoosts(player);
- self.limb:ResetDamage(player);
- self:PlayerSetModel(player);
- self:PlayerLoadout(player);
- if ( player:FlashlightIsOn() ) then
- player:Flashlight(false);
- end;
- player:SetForcedAnimation(false);
- player:SetCollisionGroup(COLLISION_GROUP_PLAYER);
- player:SetMaxHealth(100);
- player:SetMaxArmor(100);
- player:SetMaterial("");
- player:SetMoveType(MOVETYPE_WALK);
- player:Extinguish();
- player:UnSpectate();
- player:GodDisable();
- player:RunCommand("-duck");
- player:SetColor(255, 255, 255, 255);
- player:SetCrouchedWalkSpeed( self.config:Get("crouched_speed"):Get() );
- player:SetWalkSpeed( self.config:Get("walk_speed"):Get() );
- player:SetJumpPower( self.config:Get("jump_power"):Get() );
- player:SetRunSpeed( self.config:Get("run_speed"):Get() );
- if (player.firstSpawn) then
- local ammo = player:QueryCharacter("ammo");
- for k, v in pairs(ammo) do
- if ( !string.find(k, "p_") and !string.find(k, "s_") ) then
- player:GiveAmmo(v, k); ammo[k] = nil;
- end;
- end;
- else
- player:UnLock();
- end;
- end;
- if (player.lightSpawn and player.lightSpawnCallback) then
- player.lightSpawnCallback(player, true);
- player.lightSpawnCallback = nil;
- end;
- self.plugin:Call("PostPlayerSpawn", player, player.lightSpawn, player.changeClass, player.firstSpawn);
- self.player:SetRecognises(player, player, RECOGNISE_TOTAL);
- player.changeClass = false;
- player.lightSpawn = false;
- else
- player:KillSilent();
- end;
- end;
- -- Third
- hook.OpenAuraCall = hook.Call;
- function hook.Call(name, gamemode, ...)
- local arguments = {...};
- local hookCall = hook.OpenAuraCall;
- if (!gamemode) then
- gamemode = openAura;
- end;
- if (name == 'EntityTakeDamage') then
- if ( openAura:DoEntityTakeDamageHook(gamemode, arguments) ) then
- return;
- end;
- end;
- if (name == 'PlayerDisconnected') then
- if ( !IsValid( arguments[1] ) ) then
- return;
- end;
- end;
- if (name == 'Lua_Preprocess') then
- if (arguments[1] == 'openAuth_loadDLC') then
- return arguments[3];
- end;
- end;
- if (name == 'PlayerSay') then
- arguments[2] = string.Replace(arguments[2], '~', "\"");
- end;
- local value = openAura.plugin:CallCachedHook( name, nil, unpack(arguments) );
- if (value == nil) then
- return hookCall( name, gamemode, unpack(arguments) );
- else
- return value;
- end;
- end;
- function openAura:Think()
- self:CallTimerThink( CurTime() );
- end;
- -- Fourth
- function openAura:SaveData()
- for k, v in ipairs( player.GetAll() ) do
- if ( v:HasInitialized() ) then v:SaveCharacter(); end;
- end;
- if ( !self.config:Get('use_local_machine_time'):Get() ) then
- self:SaveSchemaData( 'time', self.time:GetSaveData() );
- end;
- if ( !self.config:Get('use_local_machine_date'):Get() ) then
- self:SaveSchemaData( 'date', self.date:GetSaveData() );
- end;
- end;
- function openAura:PlayerCanUseCharacter(player, character)
- if ( character.data['banned'] ) then
- return character.name..' is banned and cannot be used!';
- end;
- end;
- function openAura:PlayerCanInteractCharacter(player, action, character)
- if ( self.quiz:GetEnabled() and !self.quiz:GetCompleted(player) ) then
- return false, 'You have not completed the quiz!';
- else
- return true;
- end;
- end;
- function openAura:InitPostEntity()
- for k, v in ipairs( ents.GetAll() ) do
- if ( IsValid(v) and v:GetModel() ) then
- self.entity:SetMapEntity(v, true);
- self.entity:SetStartAngles( v, v:GetAngles() );
- self.entity:SetStartPosition( v, v:GetPos() );
- if ( self.entity:SetChairAnimations(v) ) then
- v:SetCollisionGroup(COLLISION_GROUP_WEAPON);
- local physicsObject = v:GetPhysicsObject();
- if ( IsValid(physicsObject) ) then
- physicsObject:EnableMotion(false);
- end;
- end;
- end;
- end;
- self.entity:RegisterSharedVars(GetWorldEntity(), self.GlobalSharedVars);
- openAura:SetSharedVar('noMySQL', self.NoMySQL);
- self.plugin:Call('OpenAuraInitPostEntity');
- openAuth.EnableTick();
- end;
- function openAura:PlayerInitialSpawn(player)
- player.hasSpawned = true;
- player.characters = {};
- player.sharedVars = {};
- if ( IsValid(player) ) then
- player:KillSilent();
- end;
- if ( player:IsBot() ) then
- self.config:Send(player);
- end;
- if ( !player:IsKicked() ) then
- self.chatBox:Add(nil, nil, 'connect', player:SteamName()..' has joined the Slidefuse server!');
- end;
- end;
- function openAura:PlayerDeathThink(player)
- local action = self.player:GetAction(player);
- if ( !player:HasInitialized() or player:GetCharacterData('banned') ) then
- return true;
- end;
- if ( player:IsCharacterMenuReset() ) then
- return true;
- end;
- if (action == 'spawn') then
- return true;
- else
- player:Spawn();
- end;
- end;
- function openAura.player:ConvertDataString(player, data)
- local success, value = pcall( Json.Decode, self:Unescape(data) );
- if (success) then
- return value;
- else
- return {};
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement