function GM:Initialize()
Msg("-==========================================================-\n") Msg("XaymarRP loading up...\n") Msg("-==========================================================-\n") if sql.TableExists("rp_pinfo") && sql.TableExists("rp_inventory") && sql.TableExists("rp_items") then Msg("XRP: Tables already exist.\n") else
if (!sql.TableExists("rp_pinfo")) then -- PInfo --STEAM_ID,RPName,Money,MaxHP,MaxAP,InvSpc
sql.Query("CREATE TABLE rp_pinfo (STEAM_ID VARCHAR(255), Name VARCHAR(255), Money INT, MaxHP INT, MaxAP INT, InvSpc INT)") Msg("XRP: Created Table rp_items\n") end
if (!sql.TableExists("rp_inventory")) then -- Inventory --STEAM_ID,Item_ID,Count
sql.Query("CREATE TABLE rp_inventory (STEAM_ID VARCHAR(255), ItemID INT, Count INT)") Msg("XRP: Created Table rp_inventory\n") end
if (!sql.TableExists("rp_items")) then -- Items --ID,Name,Entity,Job_ID,Cost
sql.Query("CREATE TABLE rp_items (ID INT, Name VARCHAR(255), Ent VARCHAR(255), JobID INT, Cost INT)") Msg("XRP: Created Table rp_items\n") end
end
--Convars
Msg("Console Variables being created... [_____]\n") //Starting
CreateConVar("rp_startmoney", "500", FCVAR_SERVER_CAN_EXECUTE) --Starting Money CreateConVar("rp_startmaxhp", "25", FCVAR_SERVER_CAN_EXECUTE) --Starting Maximum HP CreateConVar("rp_startmaxap", "0", FCVAR_SERVER_CAN_EXECUTE) --Starting Maximum AP(Armor) CreateConVar("rp_startinvspc", "10", FCVAR_SERVER_CAN_EXECUTE) --Starting Inventory Space(How many items people can carry) Msg("Console Variables being created... [#____]\n") //Payment
CreateConVar("rp_nojobpayment", "50", FCVAR_SERVER_CAN_EXECUTE) --No-Job Payment CreateConVar("rp_customjobpayment", "75", FCVAR_SERVER_CAN_EXECUTE) --Custom-Job Payment Msg("Console Variables being created... [##___]\n") //Increasements
CreateConVar("rp_maxhpinc", "1", FCVAR_SERVER_CAN_EXECUTE) --Increase Maximum HP CreateConVar("rp_maxapinc", "1", FCVAR_SERVER_CAN_EXECUTE) --Increase Maximum AP CreateConVar("rp_invspcinc", "1", FCVAR_SERVER_CAN_EXECUTE) --Increase Inventory Space Msg("Console Variables being created... [###__]\n") //Limits
CreateConVar("rp_maxhplimit", "400", FCVAR_SERVER_CAN_EXECUTE) --Limit Maximum HP CreateConVar("rp_maxaplimit", "200", FCVAR_SERVER_CAN_EXECUTE) --Limit Maximum AP CreateConVar("rp_invspclimit", "100", FCVAR_SERVER_CAN_EXECUTE) --Limit Inventory Space Msg("Console Variables being created... [####_]\n") //Config
CreateConVar("rp_cmdprefix", "/", FCVAR_SERVER_CAN_EXECUTE) --Prefix for Chat Commands(/save, /reset, ...) Msg("Console Variables being created... [#####]\n")
--Timer
timer.Create("PaydayTimer", 300, 0, Job_Pay) --Job Payment Timer(Every 5 Minutes) timer.Create("IncHP", 450, 0, IncHP) --Increase HP Timer(Every 7.5 Minutes) timer.Create("IncAP", 600, 0, IncAP) --Increase AP Timer(Every 10 Minutes) timer.Create("IncInvSpc", 750, 0, IncInvSpc) --Increase InvSpc Timer(Every 12.5 Minutes) timer.Create("SaveData", 900, 0, Save_SQL) --Save player data(Every 15 Minutes) Msg("Timers created.\n")
--ConCommands
concommand.Add("rp_admin_resetall", CheckRA) concommand.Add("rp_admin_jobpay", CheckJP) concommand.Add("rp_admin_inchp", CheckIH) concommand.Add("rp_admin_incap", CheckIA) concommand.Add("rp_admin_incinvspc", CheckII) concommand.Add("rp_admin_incall", CheckAI) concommand.Add("rp_admin_save", CheckSP) Msg("Console Commands created.\n")
--Tables
Msg("Jail Places loading...\n") if file.Exists("XRP/"..game.GetMap().."_Jail.txt") then if file.Read("XRP/"..game.GetMap().."_Jail.txt") then JailTable = util.KeyValuesToTable( file.Read("XRP/"..game.GetMap().."_Jail.txt") ) PrintTable(JailTable)
else
Msg("XRP/"..game.GetMap().."_Jail.txt contains nothing.\n") end
else
Msg("XRP/"..game.GetMap().."_Jail.txt missing.\n") end
Msg("Jail Places loaded. Loading Doors...\n") if file.Exists("XRP/"..game.GetMap().."_Door.txt") then if file.Read("XRP/"..game.GetMap().."_Door.txt") then DoorTable = util.KeyValuesToTable( file.Read("XRP/"..game.GetMap().."_Door.txt") ) for Door, DoorT in pairs( DoorTable ) do
for IDK, Ent in pairs( ents.GetAll() )
print(Ent:GetName())
end
end
else
Msg("XRP/"..game.GetMap().."_Door.txt contains nothing.\n") end
else
Msg("XRP/"..game.GetMap().."_Door.txt missing.\n") end
Msg("Doors loaded.\n") Msg("-==========================================================-\n") Msg("XaymarRP finished loading. Waiting for Clients...\n") Msg("-==========================================================-\n")end