Advertisement
Guest User

Untitled

a guest
May 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.85 KB | None | 0 0
  1. local SQL_HOST = "67.228.228.59"
  2. local SQL_USER = "pubga448_akim12"
  3. local SQL_PASS = "thankstomini"
  4. local SQL_DATABASE = "pubga448_bringback"
  5. local SQL_PORT = "3306"
  6.  
  7. function TS.DoRealTimeDonation()
  8.  
  9. local query = "SELECT * FROM `tb_realtimedonations`";
  10. local tbl = mysql.query( TS.SQL, query );
  11.  
  12. local steamidtable = { }
  13.  
  14. for k, v in pairs( player.GetAll() ) do
  15.  
  16. steamidtable[v:SteamID()] = v
  17.  
  18. end
  19.  
  20. for k, v in pairs( tbl ) do
  21.  
  22. local steamid = v[1];
  23. local charname = v[2];
  24. local fail = tonumber( v[3] );
  25. local tokens = tonumber( v[4] );
  26. local strength = tonumber( v[5] );
  27. local speed = tonumber( v[6] );
  28. local sprint = tonumber( v[7] );
  29. local endurance = tonumber( v[8] );
  30. local aim = tonumber( v[9] );
  31. local sneak = tonumber( v[10] );
  32. local medic = tonumber( v[11] );
  33.  
  34. local inchar = false;
  35.  
  36. for n, m in pairs( player.GetAll() ) do
  37.  
  38. if( mysql.escape( TS.SQL, m:Nick() ) == mysql.escape( TS.SQL, charname ) ) then
  39.  
  40. inchar = true;
  41. break;
  42.  
  43. end
  44.  
  45. end
  46.  
  47. if( fail == 0 ) then
  48.  
  49. --ingame
  50. if( steamidtable[steamid] and inchar ) then
  51.  
  52. local ply = steamidtable[steamid];
  53.  
  54. ply:GiveMoney( tokens );
  55. ply:RaiseStat( "Strength", strength );
  56. ply:RaiseStat( "Endurance", endurance );
  57. ply:RaiseStat( "Sprint", sprint );
  58. ply:RaiseStat( "Speed", speed );
  59. ply:RaiseStat( "Medic", medic );
  60. ply:RaiseStat( "Sneak", sneak );
  61. ply:RaiseStat( "Aim", aim );
  62.  
  63. mysql.query( TS.SQL, "DELETE FROM `tb_realtimedonations` WHERE `SteamID` = '" .. steamid .. "'" );
  64.  
  65. --not ingame
  66. else
  67.  
  68. local tbl = mysql.query( TS.SQL, "SELECT `uID` FROM `tb_users` WHERE `STEAMID` = '" .. steamid .. "'" );
  69. local uid = tonumber( tbl[1][1] );
  70.  
  71. tbl = mysql.query( "SELECT `charTokens`, `statStrength`, `statEndurance`, `statSprint`, `statSpeed`, `statMedic`, `statSneak`, `statAim` FROM `tb_characters` WHERE `userID` = '" .. uid .. "' AND `charName` = '" .. charname .. "'" );
  72.  
  73. if( not tbl or #tbl < 1 ) then
  74.  
  75. mysql.query( "UPDATE `tb_realtimedonations` SET `Fail` = '1' WHERE `SteamID` = '" .. steamid .. "'" );
  76.  
  77. else
  78.  
  79. tokens = tokens + tonumber( tbl[1][1] );
  80. strength = strength + tonumber( tbl[1][2] );
  81. endurance = endurance + tonumber( tbl[1][3] );
  82. sprint = sprint + tonumber( tbl[1][4] );
  83. speed = speed + tonumber( tbl[1][5] );
  84. medic = medic + tonumber( tbl[1][6] );
  85. sneak = sneak + tonumber( tbl[1][7] );
  86. aim = aim + tonumber( tbl[1][8] );
  87.  
  88. local query = "UPDATE `tb_characters` SET ";
  89. query = query .. "`charTokens` = '" .. tokens .. "', ";
  90. query = query .. "`statStrength` = '" .. strength .. "', ";
  91. query = query .. "`statEndurance` = '" .. endurance .. "', ";
  92. query = query .. "`statSprint` = '" .. sprint .. "', ";
  93. query = query .. "`statSpeed` = '" .. speed .. "', ";
  94. query = query .. "`statMedic` = '" .. medic .. "', ";
  95. query = query .. "`statSneak` = '" .. sneak .. "', ";
  96. query = query .. "`statAim` = '" .. aim .. "' WHERE `userID` = '" .. uid .. "' AND `charName` = '" .. charname .. "'";
  97.  
  98. mysql.query( TS.SQL, query );
  99. mysql.query( TS.SQL, "DELETE FROM `tb_realtimedonations` WHERE `SteamID` = '" .. steamid .. "'" );
  100.  
  101. end
  102.  
  103. end
  104.  
  105. end
  106.  
  107. end
  108.  
  109. end
  110.  
  111. function TS.ConnectToSQL()
  112.  
  113. local err;
  114. --If you are to change mysql info here, change below too.
  115. -- TS.SQL, err = mysql.connect( "67.228.228.59", "pubga448_akim12", "thankstomini", "pubga448_bringback", "3306" );
  116. TS.SQL, err = mysql.connect( "67.228.228.59", "pubga448_akim12", "thankstomini", "pubga448_bringback", "3306" );
  117.  
  118. if( TS.SQL == 0 ) then
  119.  
  120. Msg( "SQL CONNECTION ERROR: " .. err .. "\n" );
  121.  
  122. else
  123.  
  124. Msg( "SQL CONNECTION SUCCESS\n" );
  125.  
  126. end
  127.  
  128. sql.Query( "CREATE TABLE IF NOT EXISTS `tb_doors` ( SteamID CHAR(32), id INTEGER, CheckTime INTEGER, SessionID INTEGER );" );
  129. sql.Query( "CREATE TABLE IF NOT EXISTS `tb_toollog` ( log TEXT );" );
  130. sql.Query( "CREATE TABLE IF NOT EXISTS `tb_proplog` ( log TEXT );" );
  131.  
  132. end
  133.  
  134. function TS.CheckSQLStatus()
  135.  
  136. local tbl = mysql.query( "SELECT `STEAMID` FROM `tb_users`" );
  137.  
  138. if( not tbl or #tbl < 1 ) then
  139.  
  140. mysql.disconnect( TS.SQL );
  141. -- TS.SQL, err = mysql.connect( "67.228.228.59", "pubga448_akim12", "thankstomini", "pubga448_bringback", "3306" );
  142. TS.SQL, err = mysql.connect( "67.228.228.59", "pubga448_akim12", "thankstomini", "pubga448_bringback", "3306" );
  143.  
  144. end
  145.  
  146. end
  147.  
  148. function TS.ClearActiveList()
  149.  
  150. local ip = GetConVarString( "ip" );
  151. local port = TS.Port;
  152.  
  153. if( string.find( ip, ":" ) ) then
  154. port = string.gsub( string.sub( ip, string.find( ip, ":" ) + 1 ), " ", "" );
  155. ip = string.sub( ip, 1, string.find( ip, ":" ) - 1 );
  156. end
  157.  
  158. local query = "UPDATE `tb_users` SET `serverIP` = '', `serverPort` = '' WHERE `serverIP` = '" .. ip .. "' AND `serverPort` = '" .. port .. "'";
  159. mysql.query( TS.SQL, query );
  160.  
  161. end
  162.  
  163. TS.DoorID = 1;
  164.  
  165. --Format a door entity (has to do with properties, etc..)
  166. function TS.FormatDoorEntity( x, y, z, buildingname, name, parent, state, price )
  167.  
  168. local ents = ents.FindInBox( Vector( x, y, z ), Vector( x, y, z ) );
  169.  
  170. for k, v in pairs( ents ) do
  171.  
  172. if( v:IsDoor() ) then
  173.  
  174. local door = v;
  175.  
  176. door:SetNWString( "buildingname", buildingname );
  177. door:SetNWString( "doorname", name );
  178. door:SetNWString( "doorparent", parent );
  179. door:SetNWInt( "doorstate", state );
  180. door:SetNWFloat( "doorprice", price );
  181. door:SetNWBool( "formatteddoor", true );
  182. door:SetNWInt( "doorid", TS.DoorID );
  183. door:SetNWFloat( "origx", x );
  184. door:SetNWFloat( "origy", y );
  185. door:SetNWFloat( "origz", z );
  186.  
  187. if( state == 1 or state == 2 or state == 3 ) then
  188. door:Fire( "lock", "", 0 );
  189. end
  190.  
  191. door:GetTable().OrigName = name;
  192.  
  193. table.insert( TS.DoorGroups[buildingname], door );
  194. TS.DoorGroupsByID[TS.DoorID] = door;
  195.  
  196. TS.DoorID = TS.DoorID + 1;
  197.  
  198. end
  199.  
  200. end
  201.  
  202. end
  203.  
  204. TS.DoorGroups = { }
  205. TS.DoorGroupsByID = { }
  206.  
  207. --Loads map's property info
  208. function TS.CreateDoorInfo()
  209.  
  210. if( not file.Exists( "VeniScript/mapdata/" .. game.GetMap() .. ".txt" ) ) then
  211. SetGlobalInt( "PropertyPaying", 0 ); --Disable property paying if there's no map data
  212. return;
  213. end
  214.  
  215. local arg = TS.GetArgumentLists( file.Read( "VeniScript/mapdata/" .. game.GetMap() .. ".txt" ) );
  216.  
  217. if( not arg ) then return; end
  218.  
  219. for k, v in pairs( arg ) do
  220.  
  221. if( v[1] == "BEGINBUILDING" ) then
  222.  
  223. local buildingname = v[2] or " ";
  224. k = k + 1;
  225.  
  226. if( not TS.DoorGroups[buildingname] ) then
  227. TS.DoorGroups[buildingname] = { }
  228. end
  229.  
  230. while( arg[k][1] ~= "ENDBUILDING" ) do
  231.  
  232. local x = tonumber( arg[k][1] );
  233. local y = tonumber( arg[k][2] );
  234. local z = tonumber( arg[k][3] );
  235. local doorname = arg[k][4];
  236. local parent = arg[k][5];
  237. local doorstate = tonumber( arg[k][6] );
  238. local doorprice = tonumber( arg[k][7] );
  239.  
  240. TS.FormatDoorEntity( x, y, z, buildingname, doorname, parent, doorstate, doorprice );
  241. k = k + 1;
  242.  
  243. end
  244.  
  245. end
  246.  
  247. end
  248.  
  249. end
  250.  
  251. function TS.LoadMapData()
  252.  
  253. local curmap = game.GetMap();
  254.  
  255. include( "maps/rp_tb_city45_v01.lua" );
  256.  
  257. end
  258.  
  259. TS.TT = nil;
  260. TS.TT = { }
  261.  
  262. function TS.LoadToolTrust()
  263.  
  264. local filedata = file.Read( "VeniScript/data/tooltrust.txt" ) or "";
  265. TS.TT = TS.GetArgumentLists( filedata );
  266.  
  267. end
  268.  
  269. TS.CombineRoster = nil;
  270. TS.CombineRoster = { }
  271.  
  272. function TS.LoadCombineRoster()
  273.  
  274. local filedata = file.Read( "VeniScript/data/combine_roster.txt" ) or "";
  275. TS.CombineRoster = TS.GetArgumentLists( filedata );
  276.  
  277. end
  278.  
  279. TS.MiscFlags = nil;
  280. TS.MiscFlags = { }
  281.  
  282. function TS.LoadMiscFlags()
  283.  
  284. local filedata = file.Read( "VeniScript/data/misc_flags.txt" ) or "";
  285. TS.MiscFlags = TS.GetArgumentLists( filedata );
  286.  
  287. end
  288.  
  289. TS.AdminFlags = nil;
  290. TS.AdminFlags = { }
  291.  
  292. function TS.LoadAdminFlags()
  293.  
  294. local filedata = file.Read( "VeniScript/data/admin_flags.txt" ) or "";
  295. TS.AdminFlags = TS.GetArgumentLists( filedata );
  296.  
  297. for k, v in pairs( TS.AdminFlags ) do
  298.  
  299. TS.AdminFlags[v[1]] = v[2];
  300. TS.AdminFlags[k] = nil;
  301.  
  302. end
  303.  
  304. end
  305.  
  306. TS.CIDs = nil;
  307. TS.CIDs = { }
  308.  
  309. function TS.LoadCIDs()
  310.  
  311. local filedata = file.Read( "VeniScript/data/cids.txt" ) or "";
  312. TS.CIDs = TS.GetArgumentLists( filedata );
  313.  
  314. end
  315.  
  316. TS.PhysgunBans = nil;
  317. TS.PhysgunBans = { }
  318.  
  319. function TS.LoadPhysgunBans()
  320.  
  321. local filedata = file.Read( "VeniScript/data/physgunbans.txt" ) or "";
  322. TS.PhysgunBans = TS.GetArgumentLists( filedata );
  323.  
  324. end
  325.  
  326. TS.TeamData = nil;
  327. TS.ClientTeamData = nil;
  328.  
  329. TS.TeamData = { }
  330. TS.ClientTeamData = { }
  331.  
  332. function TS.SendClientTeamData( ply )
  333.  
  334. for k, v in pairs( TS.ClientTeamData ) do
  335.  
  336. umsg.Start( "CreateTeam" );
  337. umsg.Short( v.ID );
  338. umsg.String( v.Name );
  339. umsg.Short( v.Color.r ); umsg.Short( v.Color.g );
  340. umsg.Short( v.Color.b ); umsg.Short( v.Color.a );
  341. umsg.End();
  342.  
  343. end
  344.  
  345. end
  346.  
  347. function TS.ParseTeams()
  348.  
  349. local filedata = file.Read( "VeniScript/data/teams.txt" ) or "";
  350. local rawdata = TS.GetArgumentLists( filedata );
  351.  
  352. local tName, tID, tJob, tColor, tArmor, tModels, tWeapons, tWeaponAmmo, tHealth, tItems;
  353.  
  354. for _, v in pairs( rawdata ) do
  355.  
  356. local cmd = v[1];
  357.  
  358. if( cmd == "TEAM_START" ) then
  359.  
  360. tName = "";
  361. tID = 0;
  362. tJob = "";
  363. tColor = Color( 255, 255, 255, 255 );
  364. tWeapons = { }
  365. tWeaponAmmo = { }
  366. tModels = { }
  367. tItems = { }
  368. tArmor = 0;
  369. tHealth = 0;
  370.  
  371. end
  372.  
  373. if( cmd == "TEAM_ITEM" ) then
  374.  
  375. table.insert( tItems, v[2] );
  376.  
  377. end
  378.  
  379. if( cmd == "TEAM_BONUSHEALTH" ) then
  380.  
  381. tHealth = tonumber( v[2] );
  382.  
  383. end
  384.  
  385. if( cmd == "TEAM_NAME" ) then
  386.  
  387. tName = v[2];
  388.  
  389. end
  390.  
  391. if( cmd == "TEAM_WEAPON" ) then
  392.  
  393. table.insert( tWeapons, v[2] );
  394.  
  395. end
  396.  
  397. if( cmd == "TEAM_WEAPONAMMO" ) then
  398.  
  399. table.insert( tWeaponAmmo, { Type = v[2], Amount = tonumber( v[3] ) } );
  400.  
  401. end
  402.  
  403. if( cmd == "TEAM_MODEL" ) then
  404.  
  405. table.insert( tModels, v[2] );
  406.  
  407. end
  408.  
  409. if( cmd == "TEAM_ARMOR" ) then
  410.  
  411. tArmor = tonumber( v[2] );
  412.  
  413. end
  414.  
  415. if( cmd == "TEAM_JOB" ) then
  416.  
  417. tJob = v[2];
  418.  
  419. end
  420.  
  421. if( cmd == "TEAM_ID" ) then
  422.  
  423. tID = tonumber( v[2] );
  424.  
  425. end
  426.  
  427. if( cmd == "TEAM_COLOR" ) then
  428.  
  429. local r = tonumber( v[2] );
  430. local g = tonumber( v[3] );
  431. local b = tonumber( v[4] );
  432. local a = tonumber( v[5] );
  433.  
  434. tColor = Color( r, g, b, a );
  435.  
  436. end
  437.  
  438. if( cmd == "TEAM_END" ) then
  439.  
  440. team.SetUp( tID, tName, tColor );
  441.  
  442. table.insert( TS.TeamData, { Items = tItems, Weapons = tWeapons, Ammo = tWeaponAmmo, Armor = tArmor, Health = tHealth, Models = tModels, Job = tJob, Name = tName, ID = tID, Color = tColor } );
  443. table.insert( TS.ClientTeamData, { Name = tName, ID = tID, Color = tColor } );
  444.  
  445. end
  446.  
  447. end
  448.  
  449. end
  450.  
  451. TS.ItemData = { }
  452. TS.FactoryItems = { }
  453.  
  454. --Item callbacks: PickupFunc, UseFunc
  455. --Misc item vars: Message
  456.  
  457. function TS.CreateTempItem( id, name, size, weight, model, desc )
  458.  
  459. local NewItem = { }
  460.  
  461. NewItem.UniqueID = id;
  462. NewItem.Name = name;
  463. NewItem.Size = size;
  464. NewItem.Weight = weight;
  465. NewItem.Model = model;
  466. NewItem.Desc = desc;
  467. NewItem.Usable = false;
  468. NewItem.BlackMarket = false;
  469. NewItem.FactoryBuyable = false;
  470.  
  471. TS.ItemData[id] = NewItem;
  472.  
  473. return id;
  474.  
  475. end
  476.  
  477. --Load item scripts into TS.ItemData
  478. function TS.ParseItems()
  479.  
  480. local list = file.FindInLua( "VeniScript/gamemode/items/*.lua" );
  481.  
  482. for _, v in pairs( list ) do
  483.  
  484. ITEM = nil;
  485. ITEM = { }
  486.  
  487. include( "items/" .. v );
  488.  
  489. ITEM.UniqueID = string.gsub( v, ".lua", "" );
  490.  
  491. ITEM.Name = ITEM.Name or "";
  492. ITEM.Size = ITEM.Size or 1;
  493. ITEM.Usable = ITEM.Usable or false;
  494. ITEM.Weight = ITEM.Weight or 1;
  495. ITEM.Model = ITEM.Model or "";
  496. ITEM.Desc = ITEM.Desc or "";
  497. ITEM.SupplyLicense = ITEM.License or 0;
  498. ITEM.Flags = ITEM.Flags or "";
  499.  
  500. if( ITEM.BlackMarket == nil ) then
  501. ITEM.BlackMarket = false;
  502. end
  503.  
  504. if( ITEM.FactoryBuyable == nil ) then
  505. ITEM.FactoryBuyable = false;
  506. end
  507.  
  508. if( ITEM.RebelCost == nil ) then
  509. ITEM.RebelCost = -1;
  510. end
  511.  
  512. ITEM.FactoryPrice = ITEM.FactoryPrice or 0;
  513. ITEM.FactoryStock = ITEM.FactoryStock or 0;
  514.  
  515. TS.ItemData[ITEM.UniqueID] = ITEM;
  516.  
  517. if( ITEM.FactoryBuyable ) then
  518.  
  519. local factoryitem = { }
  520. factoryitem.ID = ITEM.UniqueID;
  521. factoryitem.Name = ITEM.Name;
  522. factoryitem.Desc = ITEM.Desc;
  523. factoryitem.Model = ITEM.Model;
  524. factoryitem.StockPrice = ITEM.FactoryPrice;
  525. factoryitem.StockCount = ITEM.FactoryStock;
  526. factoryitem.BlackMarket = ITEM.BlackMarket;
  527. factoryitem.SupplyLicense = ITEM.SupplyLicense;
  528. factoryitem.RebelCost = ITEM.RebelCost;
  529. factoryitem.Flags = ITEM.Flags;
  530.  
  531. table.insert( TS.FactoryItems, factoryitem );
  532.  
  533. end
  534.  
  535. end
  536.  
  537.  
  538. end
  539.  
  540. function GM:ShutDown()
  541.  
  542. mysql.disconnect( TS.SQL );
  543.  
  544. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement