Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- openAuth = {}
- function openAuth.EnableTick()
- openAura.ShouldTick = true;
- end;
- function openAuth.Initialize()
- 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
- if(!openAura)then
- openAura = GM;
- AddCSLuaFile("cl_init.lua");
- DeriveGamemode("openaura");
- end;
- function openAura:ManageThinkChecks()
- return;
- end;
- function openAura:GetGameDescription()
- return '[OA-FINAL] '..self.schema:GetName();
- end
- function openAura.option:GetColor(key)
- return key;
- end;
- openAura.plugin:Call('OpenAuthInitialized', true);
- 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;
- 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;
- 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 connected to the 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;
Add Comment
Please, Sign In to add comment