· 8 years ago · Aug 29, 2018, 10:26 AM
1util.AddNetworkString("loadStockGraph")
2util.AddNetworkString("orderPlaced")
3util.AddNetworkString("assetSold")
4util.AddNetworkString("SendValues")
5util.AddNetworkString("LogoutStocks")
6util.AddNetworkString("longTimeSpan")
7util.AddNetworkString("newMarketteer")
8util.AddNetworkString("assetUpdate")
9util.AddNetworkString("loadStockGraphData")
10util.AddNetworkString("avaaialbeStockUpdate")
11util.AddNetworkString("marketChange")
12util.AddNetworkString("marketTremors")
13util.AddNetworkString("sendNewsValues")
14util.AddNetworkString("openStockMarket")
15util.AddNetworkString("investmentGroupCreation")
16util.AddNetworkString("investmentGroupAdminPanel")
17util.AddNetworkString("investmentGroupLoadAdminPanel")
18util.AddNetworkString("returnPlayersAssets")
19util.AddNetworkString("sellInvestmentGroup")
20util.AddNetworkString("investInInvestmentGroup")
21util.AddNetworkString("invNewBalance")
22util.AddNetworkString("purchaseAdvertising")
23util.AddNetworkString("acceptAsset")
24util.AddNetworkString("refuseAsset")
25util.AddNetworkString("collectMoney")
26util.AddNetworkString("failOnInvestment")
27util.AddNetworkString("insideTraderChatTextCop")
28util.AddNetworkString("insideTraderChatText")
29util.AddNetworkString("tradeWarning")
30util.AddNetworkString("tradeWarningAccepted")
31
32----------DONT TOUCH--------------
33
34local stockAddonFuncs = {}
35local stockAddonConfig = {}
36
37local Round = math.Round -- Being efficient
38local Rand = math.Rand -- More efficient
39
40------------CONFIG---------------
41
42stockAddonConfig.interfaceCommand = "stocks"
43
44stockAddonConfig.moneyType = "DRP" -- Other options are PS1 & PS2 (pointshop 1 + pointshop 2)
45
46stockAddonConfig.eventFrequency = 1800 -- How often an event happens
47stockAddonConfig.chanceOfEvent = 10 -- How likely is the market likely to crash, the lower the high chance it will boom (not implemented yet)
48
49local copJobs = -- Add cop groups so the inside trader NPC can snitch out inside traders
50 {
51 ["Civil Protection"] = true
52 }
53
54local investmentGroupAdvertises = {"Advertise your investment group here"} -- Default advertisement message
55
56local stockAddonNewsItems = { -- The default first 3 tweets
57 {
58 ["messenger"] = "Stock Addon Official",
59 ["messagebody"] = "Up top if you press the Load Stock Market button will load\nup the stock markets where you can make money\nhave fun! This addon was also inspried by a TV show\ncalled Billions on Showtime, go watch it!",
60 ["time"] = 60
61 },
62
63 {
64 ["messenger"] = "Stock Addon Official",
65 ["messagebody"] = "On the left you can see player investments into you\ncompany, you will either be able to return them\nonce you can afford to or defunct on them. Be aware\ndefuncting will make you loose reputation.",
66 ["time"] = 60
67 },
68
69 {
70 ["messenger"] = "Stock Addon Official",
71 ["messagebody"] = "Welcone to your very own investment group. You can\nraise capital from players and invest it into markets,\ntherefore making more money and returning it\nto your customers.",
72 ["time"] = 60
73 }
74}
75
76local stockMarket = {
77 {["stockDifficulty"] = 110, -- Market difficulty - higher the harder (MIN 95 - MAX 250)
78 ["stockName"] = "CIA", -- The name of the twetter
79 ["stockCrashEvent"] = "CIA: Lets invest all our money in cars!", -- The message on the news alert
80 ["stockCrashEventTweet"] = "It turns out Google is a really handy tool to snoop\non people, huh", -- The tweet you'll see on the investment group admin page
81 ["stockPrefix"] = "GOG", -- Stock prefix
82 ["marketStocks"] = 800000000, -- How many stocks avaialable (don't go higher than 2147483647)
83 ["newStockValue"] = 807, -- Starting value of the stock market (only uses this when you first install the script)
84 ["hoverStockValue"] = 800, -- Hover value (where you want the AI to keep the number ruffly), its seperate to starting value as you may want a market to swing in a certain direction
85 ["marketValues"] = {}, -- The market values (DONT TOUCH)
86 ["marketOldValues"] = {}, -- The market history (DONT TOUCH)
87 ["marketPlayers"] = {} -- The people currently viewing the market (DONT TOUCH)
88 },
89
90 {["stockDifficulty"] = 100,
91 ["stockName"] = "Steve Jobs",
92 ["stockCrashEvent"] = "Steve Jobs: Im back from the dead",
93 ["stockCrashEventTweet"] = "Im back from the dead beeeeeches",
94 ["stockPrefix"] = "APL",
95 ["marketStocks"] = 200000000,
96 ["newStockValue"] = 602,
97 ["hoverStockValue"] = 600,
98 ["marketValues"] = {},
99 ["marketOldValues"] = {},
100 ["marketPlayers"] = {}
101 },
102
103 {["stockDifficulty"] = 102,
104 ["stockName"] = "Garry Newman",
105 ["stockCrashEvent"] = "Garry Newman: Still haven't fixed the server browser",
106 ["stockCrashEventTweet"] = "I still haven't fixed the server browser LMFAO",
107 ["stockPrefix"] = "GAZ",
108 ["marketStocks"] = 350000000,
109 ["newStockValue"] = 447,
110 ["hoverStockValue"] = 450,
111 ["marketValues"] = {},
112 ["marketOldValues"] = {},
113 ["marketPlayers"] = {}
114 },
115
116 {["stockDifficulty"] = 100,
117 ["stockName"] = "Sammsung h8ter 4000",
118 ["stockCrashEvent"] = "Sammsung: Oh no - my phone is on fire!",
119 ["stockCrashEventTweet"] = "Here is the new SFire - fantastic for camping",
120 ["stockPrefix"] = "SAM",
121 ["marketStocks"] = 400000000,
122 ["newStockValue"] = 524,
123 ["hoverStockValue"] = 500,
124 ["marketValues"] = {},
125 ["marketOldValues"] = {},
126 ["marketPlayers"] = {}
127 },
128
129 {["stockDifficulty"] = 112,
130 ["stockName"] = "Walmart Official",
131 ["stockCrashEvent"] = "Walmart: Oh look, we just discovered the internet!",
132 ["stockCrashEventTweet"] = "Oh look, we just discovered the internet!",
133 ["stockPrefix"] = "WAL",
134 ["marketStocks"] = 275000000,
135 ["newStockValue"] = 254,
136 ["hoverStockValue"] = 250,
137 ["marketValues"] = {},
138 ["marketOldValues"] = {},
139 ["marketPlayers"] = {}
140 },
141
142 {["stockDifficulty"] = 120,
143 ["stockName"] = "BP Official",
144 ["stockCrashEvent"] = "BP: ANOTHER oil spill!?!?!",
145 ["stockCrashEventTweet"] = "ANOTHER oil spill!?!?!",
146 ["stockPrefix"] = "BP",
147 ["marketStocks"] = 745000000,
148 ["newStockValue"] = 357,
149 ["hoverStockValue"] = 350,
150 ["marketValues"] = {},
151 ["marketOldValues"] = {},
152 ["marketPlayers"] = {}
153 },
154
155 {["stockDifficulty"] = 140,
156 ["stockName"] = "AT&T Official",
157 ["stockCrashEvent"] = "AT&T: Some say TMobile actaully offer service",
158 ["stockCrashEventTweet"] = "Some say TMobile actaully offer service",
159 ["stockPrefix"] = "ATT",
160 ["marketStocks"] = 820000000,
161 ["newStockValue"] = 648,
162 ["hoverStockValue"] = 650,
163 ["marketValues"] = {},
164 ["marketOldValues"] = {},
165 ["marketPlayers"] = {}
166 },
167
168 {["stockDifficulty"] = 130,
169 ["stockName"] = "Hewlett Packard",
170 ["stockCrashEvent"] = "HP: Profits are in - printer ink sales are down",
171 ["stockCrashEventTweet"] = "Profits are in - printer ink sales are down",
172 ["stockPrefix"] = "HP",
173 ["marketStocks"] = 940000000,
174 ["newStockValue"] = 749,
175 ["hoverStockValue"] = 750,
176 ["marketValues"] = {},
177 ["marketOldValues"] = {},
178 ["marketPlayers"] = {}
179 },
180
181 {["stockDifficulty"] = 160,
182 ["stockName"] = "Elon musk",
183 ["stockCrashEvent"] = "SPACEX: Mars is habitable? No.",
184 ["stockCrashEventTweet"] = "Someone shot our spacescraft down with a sniper? Oh dear",
185 ["stockPrefix"] = "SPX",
186 ["marketStocks"] = 690000000,
187 ["newStockValue"] = 934,
188 ["hoverStockValue"] = 950,
189 ["marketValues"] = {},
190 ["marketOldValues"] = {},
191 ["marketPlayers"] = {}
192 },
193
194 {["stockDifficulty"] = 150,
195 ["stockName"] = "Nintendo Official",
196 ["stockCrashEvent"] = "Nintendo: Switch up you're day - get a swtich!",
197 ["stockCrashEventTweet"] = "Bam bam bam - im eating game startups for breakfest!",
198 ["stockPrefix"] = "NIN",
199 ["marketStocks"] = 550000000,
200 ["newStockValue"] = 745,
201 ["hoverStockValue"] = 750,
202 ["marketValues"] = {},
203 ["marketOldValues"] = {},
204 ["marketPlayers"] = {}
205 },
206
207 {["stockDifficulty"] = 200,
208 ["stockName"] = "FTSE 100",
209 ["stockCrashEvent"] = "FTSE: Shock result - the UK has brexited!",
210 ["stockCrashEventTweet"] = "Shock result - the UK has brexited!",
211 ["stockPrefix"] = "FTSE",
212 ["marketStocks"] = 1500000000,
213 ["newStockValue"] = 6000,
214 ["hoverStockValue"] = 6000,
215 ["marketValues"] = {},
216 ["marketOldValues"] = {},
217 ["marketPlayers"] = {}
218 },
219
220 {["stockDifficulty"] = 250,
221 ["stockName"] = "Down Jones",
222 ["stockCrashEvent"] = "realDonalTrump: I won the election. Easy.",
223 ["stockCrashEventTweet"] = "Trump won the election! - Stocks are fantastic",
224 ["stockPrefix"] = "DJ",
225 ["marketStocks"] = 2000000000,
226 ["newStockValue"] = 20000,
227 ["hoverStockValue"] = 20000,
228 ["marketValues"] = {},
229 ["marketOldValues"] = {},
230 ["marketPlayers"] = {}
231 }
232}
233
234------------END CONFIG-----------
235
236if not sql.TableExists( "investmentGroups" ) then
237 sql.Query( "CREATE TABLE investmentGroups ( groupID INTEGER PRIMARY KEY AUTOINCREMENT, name STRING, ownerSID STRING, reputation INTEGER, balance INTEGER )" )
238end
239
240if not sql.TableExists( "investmentGroupsAssets" ) then
241 sql.Query( "CREATE TABLE investmentGroupsAssets ( ownerName STRING, ownerSID STRING, amount INTEGER, profitGaurentee INTEGER, accepted BOOLEAN, locationID INTEGER, FOREIGN KEY(locationID) REFERENCES investmentGroups(groupID) )" )
242end
243
244if not sql.TableExists( "investmentGroupReturnableMoney" ) then
245 sql.Query( "CREATE TABLE investmentGroupReturnableMoney ( ownerSID STRING, returnedBy STRING, amount INTEGER )" )
246end
247
248if not sql.TableExists( "marketBuyins" ) then
249 sql.Query( "CREATE TABLE marketBuyins ( assetSID STRING, purchasePrice INTEGER, amount INTEGER, market INTEGER, type BOOLEAN )" )
250end
251
252if not sql.TableExists( "stockAvialability" ) then
253 sql.Query( "CREATE TABLE stockAvialability ( market INTEGER, avaialability INTEGER )" )
254 for k, v in pairs(stockMarket) do -- only ever done once dw bois <3
255 sql.Query( "INSERT INTO stockAvialability VALUES ('"..k.."', '"..v["marketStocks"].."') ")
256 end
257end
258
259-- https://i.gyazo.com/51f3e18af68397ea1f67bfacb64363ac.png NEEDS UPDATING
260
261if stockAddonConfig.moneyType == "ps1" then
262 function stockAddonFuncs.investInInvestmentGroupPS1(ply, playerSafeName, steamID, amount, profitGaurentee, groupID)
263 if ply:PS_GetPoints(amount) > amount then
264 ply:PS_TakePoints(amount)
265 stockAddonFuncs.investmenyAssetUpdate(playerSafeName, steamID, amount, profitGaurentee, groupID)
266 end
267 end
268
269 function stockAddonFuncs.buyPersonStockPS1(ply, stockPrice, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
270 if ply:PS_GetPoints(amount) > amount then
271 ply:PS_TakePoints(stockPrice)
272 stockAddonFuncs.buyPersonStockInfo(ply, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
273 end
274 end
275
276 function stockAddonFuncs.addMoneySAPS1(ply, money)
277 ply:PS_GivePoints(money)
278 end
279
280 stockAddonFuncs.investInInvestmentGroup = stockAddonFuncs.investInInvestmentGroupPS1
281 stockAddonFuncs.buyPersonStock = stockAddonFuncs.buyPersonStockPS1
282 stockAddonFuncs.addMoneySA = stockAddonFuncs.addMoneySAPS1
283elseif stockAddonConfig.moneyType == "ps2" then
284 function stockAddonFuncs.investInInvestmentGroupPS2(ply, playerSafeName, steamID, amount, profitGaurentee, groupID)
285 if ply.PS2_Wallet.points > amount then
286 ply:PS2_AddStandardPoints(-amount)
287 stockAddonFuncs.investmenyAssetUpdate(playerSafeName, steamID, amount, profitGaurentee, groupID)
288 end
289 end
290
291 function stockAddonFuncs.buyPersonStockPS2(ply, stockPrice, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
292 if ply.PS2_Wallet.points > stockPrice then
293 ply:PS2_AddStandardPoints(-stockPrice)
294 stockAddonFuncs.buyPersonStockInfo(ply, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
295 end
296 end
297
298 function stockAddonFuncs.addMoneySAPS2(ply, money)
299 ply:PS2_AddStandardPoints(money)
300 end
301
302 stockAddonFuncs.investInInvestmentGroup = stockAddonFuncs.investInInvestmentGroupPS2
303 stockAddonFuncs.buyPersonStock = stockAddonFuncs.buyPersonStockPS2
304 stockAddonFuncs.addMoneySA = stockAddonFuncs.addMoneySAPS2
305else
306 function stockAddonFuncs.investInInvestmentGroupDRP(ply, playerSafeName, steamID, amount, profitGaurentee, groupID)
307 if amount > 0 then --no negatives or zeros allowed! (for group reputation reasons)
308 if ply:canAfford(amount) then -- If you can actaully afford this sale
309 ply:addMoney(-amount) -- removes there money
310 stockAddonFuncs.investmenyAssetUpdate(playerSafeName, steamID, amount, profitGaurentee, groupID)
311 end
312 end
313 end
314
315 function stockAddonFuncs.buyPersonStockDRP(ply, stockPrice, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
316 if ply:canAfford(stockPrice) then -- If you can actaully afford this sale
317 ply:addMoney(-stockPrice) -- removes there money
318 stockAddonFuncs.buyPersonStockInfo(ply, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
319 end
320 end
321
322 function stockAddonFuncs.addMoneySADRP(ply, money)
323 ply:addMoney(money)
324 end
325
326 stockAddonFuncs.investInInvestmentGroup = stockAddonFuncs.investInInvestmentGroupDRP
327 stockAddonFuncs.buyPersonStock = stockAddonFuncs.buyPersonStockDRP
328 stockAddonFuncs.addMoneySA = stockAddonFuncs.addMoneySADRP
329end
330
331
332function stockAddonFuncs.investmenyAssetUpdate(playerSafeName, steamID, amount, profitGaurentee, groupID)
333 sql.Query( "INSERT INTO investmentGroupsAssets (ownerName, ownerSID, amount, profitGaurentee, accepted, locationID) VALUES ("..playerSafeName..", "..steamID..", "..amount..", "..profitGaurentee..", 'false' , "..groupID..")" )
334end
335
336function stockAddonFuncs.buyPersonStockInfo(ply, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
337 local marketSavePrice = Round(marketPrice)
338 local changeSeverity = sharesAmount/marketFreeStocks
339 local priceIncrease = marketPrice*Rand(changeSeverity/2,changeSeverity*2) -- The amount of market price will go up
340 -----
341 local newAvaialabityValue = marketFreeStocks - sharesAmount -- Updates the avaialbe stocks
342 sql.Query( "UPDATE stockAvialability SET avaialability = '"..newAvaialabityValue.."' WHERE market = '"..onlineMarket.."' " )
343 stockAddonFuncs.marketChange(-priceIncrease, onlineMarket) -- Changes the market
344 -----
345 sql.Query( "INSERT INTO marketBuyins (assetSID, purchasePrice, amount, market, type) VALUES ('"..ply:SteamID64().."', "..marketSavePrice..", "..sharesAmount..", "..onlineMarket..", 0)" )
346 -----
347 local latestAsset = sql.QueryValue("SELECT rowid FROM marketBuyins ORDER BY rowid DESC LIMIT 1")
348 net.Start("assetUpdate") -- Updates the player
349 net.WriteTable({["assetID"] = latestAsset, ["purchasePrice"] = marketSavePrice, ["amount"] = sharesAmount, ["type"] = 0})
350 net.Send(ply)
351
352 net.Start("avaaialbeStockUpdate") -- Updates everyone
353 net.WriteInt(newAvaialabityValue,32)
354 net.Send(stockMarket[onlineMarket]["marketPlayers"])
355end
356
357function stockAddonFuncs.setTradePos(ply, newPos)
358 if !ply:IsAdmin() then return end
359
360 local jsonPositions = file.Read("npcpositions.txt","DATA")
361 local positions = util.JSONToTable(jsonPositions)
362 table.insert(positions, newPos)
363 local jsonPositions = util.TableToJSON(positions)
364 file.Write("npcpositions.txt", jsonPositions)
365end
366
367--------------------
368
369local hooksay = "PlayerSay"
370hook.Add(hooksay, "stockAddonChatHook", function(ply, text)
371 if string.lower(text) == "!stocks" or string.lower(text) == "/stocks" then
372 stockAddonMainMenu(ply)
373 elseif string.lower(text) == "!traderset" or string.lower(text) == "/traderset" then
374 stockAddonFuncs.setTradePos(ply, ply:GetPos())
375 ply:ChatPrint("Inside trader position set")
376 end
377end)
378
379---------------------------------
380
381net.Receive("investmentGroupLoadAdminPanel",function(_, ply)
382 local invAssetData = {} -- locals the variable
383 local invGroupData = sql.Query( "SELECT groupID, name, reputation, balance FROM investmentGroups WHERE ownerSID = ('"..ply:SteamID64().."') LIMIT 1 " ) -- nabs the data of your inv group
384
385 if invGroupData == false or invGroupData == nil then -- just in case your trying to fuck the system
386 invGroupData = {} -- just in case your trying to fuck the system
387 invAssetData = {} -- just in case your trying to fuck the system
388 else
389 invAssetData = sql.Query( "SELECT rowid, profitGaurentee, ownerName, ownerSID, amount, accepted FROM investmentGroupsAssets WHERE locationID = ('"..invGroupData[1]["groupID"].."') " ) -- gets your inv group assets
390
391 if invAssetData == false or invAssetData == nil then -- if you have no assets
392 invAssetData = {}
393 end
394 end
395 ------
396 net.Start("investmentGroupAdminPanel")
397 net.WriteTable(invGroupData)
398 net.WriteTable(invAssetData)
399 net.WriteTable(stockAddonNewsItems)
400 net.Send(ply)
401end)
402
403net.Receive("investInInvestmentGroup",function(_, ply)
404 local groupID = net.ReadInt(32) -- So it knows that group you are investing into
405 local amount = net.ReadInt(32) -- How much you want to invset
406 local profitGaurentee = net.ReadInt(32)
407 local playerSafeName = sql.SQLStr(ply:Nick()) -- Just in case you change your name to something malicous
408 local playerSID = sql.SQLStr(ply:SteamID64())
409 -----
410
411 stockAddonFuncs.investInInvestmentGroup(ply, playerSafeName, playerSID, amount, profitGaurentee, groupID)
412end)
413
414net.Receive("openStockMarket",function(_, ply)
415 local isInGroup = sql.QueryValue("SELECT balance FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." LIMIT 1") -- Checks if you have a inv group
416 --
417 loadStockGraph(ply, 1, isInGroup)
418end)
419
420net.Receive("marketChange",function(_, ply)
421 local newMarket = net.ReadInt(5) -- So it knows that market
422 local isInGroup = sql.QueryValue("SELECT balance FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." LIMIT 1") -- checks if is in inv group and if so gets there balance
423 local onlineMarket = stockAddonFuncs.currentMarket(ply) -- Gets there old market
424 ---
425 if !(onlineMarket) then return end
426 table.RemoveByValue(stockMarket[onlineMarket]["marketPlayers"], ply) -- stop sending old data
427 ---
428 loadStockGraph(ply, newMarket, isInGroup)
429end)
430
431net.Receive("loadStockGraphData",function(_, ply)
432 local marketWasOn = net.ReadInt(5) -- What there previous market was on
433 local isInGroup = sql.QueryValue("SELECT balance FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." LIMIT 1") -- Checks if is in inv group
434 ---
435 loadStockGraph(ply, marketWasOn, isInGroup)
436end)
437
438function loadStockGraph(ply, onlineMarket, isInGroup)
439 local playersAssets = stockAddonFuncs.activeAssets(ply, onlineMarket)
440 local invGroup = false
441
442 if isInGroup then
443 invGroup = isInGroup
444 end
445
446 table.insert(stockMarket[onlineMarket]["marketPlayers"], ply) -- Start sending new data
447
448 local marketStocks = sql.QueryValue( "SELECT avaialability FROM stockAvialability WHERE market = '"..onlineMarket.."' " )
449
450 net.Start("LoadStockGraph")
451 net.WriteTable(stockMarket[onlineMarket]["marketValues"])
452 net.WriteTable(playersAssets)
453 net.WriteInt(marketStocks,32)
454 net.WriteType(invGroup)
455 net.Send(ply)
456end
457
458net.Receive("longTimeSpan",function(_, ply)
459 local onlineMarket = stockAddonFuncs.currentMarket(ply) -- Checks there current market
460 ----
461 local playersAssets = stockAddonFuncs.activeAssets(ply, onlineMarket) -- Gets there assets
462 ----
463 table.RemoveByValue(stockMarket[onlineMarket]["marketPlayers"], ply) -- Removes them from the market data stream
464 ----
465 local isInGroup = sql.QueryValue("SELECT balance FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." LIMIT 1") -- Checks if they are in an inv group
466 local invGroup = false
467
468 if (isInGroup) then
469 invGroup = isInGroup
470 end
471 ----
472 local marketStocks = sql.QueryValue( "SELECT avaialability FROM stockAvialability WHERE market = '"..onlineMarket.."' " )
473
474 net.Start("loadStockGraph")
475 net.WriteTable(stockMarket[onlineMarket]["marketOldValues"])
476 net.WriteTable(playersAssets)
477 net.WriteInt(marketStocks,32)
478 net.WriteType(invGroup)
479 net.Send(ply)
480end)
481
482net.Receive("purchaseAdvertising",function(_, ply)
483 local advertiserName = net.ReadString() -- If I add name filters for rude words this will be changed
484
485 local money = sql.QueryValue("SELECT balance FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." LIMIT 1 ") -- Gets the amount of money the stake us
486 if money == false or money == nil then else -- As a shceck to make sure you arn't being malicous
487 local newBalance = money - 50000
488 if newBalance > 0 then
489 table.insert(investmentGroupAdvertises,advertiserName)
490 sql.Query("UPDATE investmentGroups SET balance = "..newBalance.." WHERE ownerSID = "..ply:SteamID64().." ") -- Updates groups rep
491 end
492 end
493end)
494
495net.Receive("returnPlayersAssets",function(_, ply)
496 local assetID = net.ReadInt(32) -- Nabs there asset ID
497 local money = sql.Query("SELECT investmentGroupsAssets.amount, investmentGroupsAssets.profitGaurentee, investmentGroupsAssets.ownerSID, investmentGroups.reputation, investmentGroups.balance, investmentGroups.name, investmentGroups.groupID FROM investmentGroupsAssets, investmentGroups WHERE investmentGroupsAssets.rowid = "..assetID.." AND investmentGroupsAssets.locationID = investmentGroups.groupID AND investmentGroups.ownerSID = "..ply:SteamID64().." LIMIT 1 ") -- Gets the amount of money the stake us
498 local investedAmount = tonumber(money[1]["amount"])
499 local profitValue = investedAmount*(tonumber(money[1]["profitGaurentee"])/100 + 1)
500 local newBalance = money[1]["balance"] - profitValue
501 if money == false or money == nil then else
502 if newBalance > 0 then
503 local newRep = money[1]["reputation"] + 1
504 local workingGroupName = sql.SQLStr("Your $"..investedAmount.. " invested into "..money[1]["name"].." is now worth $"..profitValue)
505 sql.Query("INSERT INTO investmentGroupReturnableMoney (ownerSID, amount, returnedBy) VALUES ('"..money[1]["ownerSID"].."', "..profitValue..", "..workingGroupName.." ) ") -- Makes the money claimable again
506 sql.Query("DELETE FROM investmentGroupsAssets WHERE rowid = "..assetID.." AND locationID = "..money[1]["groupID"].."") -- Removes the investment from the inv group assets
507 sql.Query("UPDATE investmentGroups SET reputation = "..newRep..", balance = "..newBalance.." WHERE ownerSID = "..ply:SteamID64().." ") -- Updates groups rep
508 end
509 end
510end)
511
512net.Receive("investmentGroupCreation",function(_, ply)
513 local groupName = net.ReadString() -- Gets the name of the group your making
514 local safeGroupName = sql.SQLStr(groupName) -- Just in case your a cunt
515
516 --https://i.gyazo.com/9da044df3a429a3454bc56f31e40249d.png a very early sketh design of admin panel for novelty ;)
517
518 local groupCheck = sql.Query( "SELECT name FROM investmentGroups WHERE ownerSID = ('"..ply:SteamID64().."') LIMIT 1 " ) -- Another cunt check to make sure your not making more than 1 group
519 local nameCheck = sql.Query( "SELECT name FROM investmentGroups WHERE name = ('"..safeGroupName.."') LIMIT 1 ") -- Making sure you arn't using someone elses name
520
521 if groupCheck == false or groupCheck == nil and nameCheck == false or nameCheck == nil then
522 sql.Query( "INSERT INTO investmentGroups (name, ownerSID, reputation, balance) VALUES ("..safeGroupName..",'"..ply:SteamID64().."', '0', '0')" ) -- Makes your fresh new group
523
524 net.Start("investmentGroupAdminPanel")
525 net.WriteTable({{["name"] = groupName, ["balance"] = 0, ["reputation"] = 0}}) -- The default values of an inv group
526 net.WriteTable({}) -- You won't have any assets yet
527 net.WriteTable(stockAddonNewsItems)
528 net.Send(ply)
529 end
530end)
531
532net.Receive("orderPlaced",function(_, ply)
533 local sharesAmount = net.ReadInt(32) -- How many shares your willing to throw at the stock market like a fool
534 local invGroupMode = net.ReadBool() -- If they are making a inv group bet
535 local onlineMarket = stockAddonFuncs.currentMarket(ply) -- Checks what market they are currently on
536 if !(onlineMarket) then return end
537 local marketFreeStocks = sql.QueryValue( "SELECT avaialability FROM stockAvialability WHERE market = '"..onlineMarket.."' " ) -- How many socks are avaialable
538
539 if sharesAmount > 0 and (marketFreeStocks - sharesAmount >= 0) then -- Bit of ye old maths
540 local marketPrice = stockMarket[onlineMarket]["marketValues"][1] -- How much a stock costs
541 local stockPrice = sharesAmount*marketPrice -- How much is this gonna cost
542
543 if invGroupMode == true then -- You are now making a group sale
544 local balance = sql.Query( "SELECT balance FROM investmentGroups WHERE ownerSID = ('"..ply:SteamID64().."') LIMIT 1 " ) -- Gets the amount of money you have
545 if tonumber(balance[1]["balance"]) - stockPrice > 0 then -- Checks you can actaully affor the sale
546 -- print("getting this far") | bings, ur gay
547 local marketSavePrice = Round(marketPrice) -- Rounds the price so it isn't like 53435.3452389573429058734209587234809 as that's annoying TODO: Make it not do that in the first place
548 local changeSeverity = sharesAmount/marketFreeStocks -- How much the market will be impacted on the sale
549 local priceIncrease = marketPrice*Rand(changeSeverity/2,changeSeverity*2) -- The amount of market price will go up (maybe down?)
550 -----
551 local newBalance = Round(tonumber(balance[1]["balance"]) - stockPrice,2) -- Works out your new balance
552 sql.Query( "UPDATE investmentGroups SET balance = "..newBalance.." WHERE ownerSID = "..ply:SteamID64().."") -- Updates your new balance
553 -----
554 local newAvaialabityValue = marketFreeStocks - sharesAmount -- Updates the avaialbe stocks
555 sql.Query( "UPDATE stockAvialability SET avaialability = '"..newAvaialabityValue.."' WHERE market = '"..onlineMarket.."' " )
556 stockAddonFuncs.marketChange(-priceIncrease, onlineMarket) -- Changes the market
557 -----
558 sql.Query( "INSERT INTO marketBuyins (assetSID, purchasePrice, amount, market, type) VALUES ('"..ply:SteamID64().."', "..marketSavePrice..", "..sharesAmount..", "..onlineMarket..", 1)" ) -- Inserts the new buy into sql db
559 -----
560 local latestAsset = sql.Query("SELECT rowid FROM marketBuyins ORDER BY rowid DESC LIMIT 1") -- Gets the assetID
561 net.Start("assetUpdate") -- Updates the player
562 net.WriteTable({["assetID"] = latestAsset[1]["rowid"], ["purchasePrice"] = marketSavePrice, ["amount"] = sharesAmount, ["type"] = 1})
563 net.Send(ply)
564
565 net.Start("avaaialbeStockUpdate") -- Updates everyone of new amount of stocks avaialble
566 net.WriteInt(newAvaialabityValue,32)
567 net.Send(stockMarket[onlineMarket]["marketPlayers"])
568 end
569 else -- You are making a personal sale
570 stockAddonFuncs.buyPersonStock(ply, stockPrice, marketPrice, marketFreeStocks, sharesAmount, onlineMarket)
571 end
572 end
573end)
574
575net.Receive("sellInvestmentGroup",function(_, ply)
576 local invAssetData = sql.Query( "SELECT investmentGroupsAssets.rowid FROM investmentGroupsAssets, investmentGroups WHERE investmentGroups.ownerSID = "..ply:SteamID64().." AND investmentGroupsAssets.locationID = investmentGroups.groupID " ) -- TODO: Make it do something like checking if anything exists
577
578 if invAssetData == false or invAssetData == nil then -- Makes sure they don't have any outstanding assets
579 local money = sql.Query("SELECT balance FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." LIMIT 1 ") -- Gets the amount of money the stake us
580 if money == false or money == nil then else -- As a shceck to make sure you arn't being malicous
581 stockAddonFuncs.addMoneySA(ply, money[1]["balance"])
582 end
583
584 sql.Query("DELETE FROM investmentGroups WHERE ownerSID = "..ply:SteamID64().." ") -- Deletes the investment group
585 end
586end)
587
588net.Receive("assetSold",function(_, ply)
589 local assetID = net.ReadInt(32) -- Nabs the asset ID
590 local isInGroup = net.ReadType() -- Chekcks if the sale is a group sale
591 local onlineMarket = stockAddonFuncs.currentMarket(ply) -- Gets market the player is currently on
592 if !(onlineMarket) then return end
593 local marketAvaialbeStocks = sql.QueryValue( "SELECT avaialability FROM stockAvialability WHERE market = '"..onlineMarket.."' " ) -- How many socks are avaialable
594 local sharesAmount = sql.Query("SELECT amount, type FROM marketBuyins WHERE rowid = "..assetID.." AND assetSID = "..ply:SteamID64().." LIMIT 1 ") -- Gets the data from your sale
595
596 local profitFromSale = sharesAmount[1]["amount"]*stockMarket[onlineMarket]["marketValues"][1]-stockMarket[onlineMarket]["marketValues"][1]*0.02
597 if tonumber(sharesAmount[1]["type"]) == 0 then -- If this is a personal order
598 stockAddonFuncs.addMoneySA(ply, profitFromSale)
599 else -- If this is a buisness order
600 local newBalance = Round(isInGroup + profitFromSale, 2)
601 sql.Query( "UPDATE investmentGroups SET balance = "..newBalance.." WHERE ownerSID = "..ply:SteamID64().."")
602
603 net.Start("invNewBalance")
604 net.WriteDouble(newBalance)
605 net.Send(ply)
606 end
607 -----
608 local changeSeverity = sharesAmount[1]["amount"]/marketAvaialbeStocks
609 local priceIncrease = stockMarket[onlineMarket]["marketValues"][1]*Rand(changeSeverity,changeSeverity*2) -- THe amount of market price will go up
610 -----
611 sql.Query("DELETE FROM marketBuyins WHERE rowid = "..assetID.." AND assetSID = "..ply:SteamID64().." ") -- Deletes the stock
612 -----
613 stockAddonFuncs.marketChange(priceIncrease, onlineMarket) -- Changes the market
614 -----
615 local newAvaialabityValue = marketAvaialbeStocks + sharesAmount[1]["amount"] -- Updates the avaialbe stocks
616 sql.Query( "UPDATE stockAvialability SET avaialability = '"..newAvaialabityValue.."' WHERE market = '"..onlineMarket.."' " )
617
618 net.Start("avaaialbeStockUpdate")
619 net.WriteInt(newAvaialabityValue,32)
620 net.Send(stockMarket[onlineMarket]["marketPlayers"])
621end)
622
623net.Receive("acceptAsset",function(_, ply)
624 local assetID = net.ReadInt(32)
625 local assetCheck = sql.Query("SELECT investmentGroups.groupID, investmentGroups.balance, investmentGroupsAssets.amount FROM investmentGroupsAssets, investmentGroups WHERE investmentGroupsAssets.rowid = "..assetID.." AND investmentGroupsAssets.locationID = investmentGroups.groupID AND investmentGroups.ownerSID = "..ply:SteamID64().." LIMIT 1 ") -- Checks if the inv group owns the asset
626
627 if assetCheck == false or assetCheck == nil then else -- Makes sure the asset exists and your not just a con artist
628 local newBalance = assetCheck[1]["balance"] + assetCheck[1]["amount"]
629 sql.Query( "UPDATE investmentGroupsAssets SET accepted = 'true' WHERE rowid = "..assetID.."")
630 sql.Query( "UPDATE investmentGroups SET balance = "..newBalance.." WHERE ownerSID = "..ply:SteamID64().."")
631 end
632end)
633
634net.Receive("collectMoney",function(_, ply)
635 local assetID = net.ReadInt(32)
636 local assetValue = sql.QueryValue("SELECT amount FROM investmentGroupReturnableMoney WHERE ownerSID = "..ply:SteamID64().." AND rowid = "..assetID.." ") -- Gets the value of the assets (as obvs I can't rely on player to send right amount)
637 stockAddonFuncs.addMoneySA(ply, assetValue)
638 -----
639 sql.Query( "DELETE FROM investmentGroupReturnableMoney WHERE rowid = "..assetID.." and ownerSID = "..ply:SteamID64().." ") -- Deletes the asset (and also does a check to make sure you own the asset)
640end)
641
642net.Receive("refuseAsset",function(_, ply)
643 local assetID = net.ReadInt(32)
644 local assetCheck = sql.Query("SELECT investmentGroupsAssets.amount, investmentGroupsAssets.ownerSID, investmentGroups.name FROM investmentGroupsAssets, investmentGroups WHERE investmentGroupsAssets.rowid = "..assetID.." AND investmentGroupsAssets.locationID = investmentGroups.groupID AND investmentGroups.ownerSID = "..ply:SteamID64().." LIMIT 1 ") -- Checks if the inv group owns the asset
645
646 if assetCheck == false or assetCheck == nil then else
647 local refuser = sql.SQLStr("was refused by "..assetCheck[1]["name"])
648 sql.Query( "INSERT INTO investmentGroupReturnableMoney (ownerSID, amount, returnedBy) VALUES ("..assetCheck[1]["ownerSID"]..", "..assetCheck[1]["amount"]..", "..refuser..")") -- Makes it able for the player to reclaim the money
649 sql.Query( "DELETE FROM investmentGroupsAssets WHERE rowid = "..assetID.."") -- Removes the investment from the inv group assets table
650 end
651end)
652
653net.Receive("failOnInvestment",function(_, ply)
654 local assetID = net.ReadInt(32)
655
656 local ownerCheck = sql.Query("SELECT investmentGroups.groupID, investmentGroups.reputation, investmentGroups.ownerSID FROM investmentGroupsAssets, investmentGroups WHERE investmentGroupsAssets.rowid = "..assetID.." AND investmentGroupsAssets.locationID = investmentGroups.groupID AND investmentGroups.ownerSID = "..ply:SteamID64().." LIMIT 1 ") -- Gets the amount of money the stake us - TODO Merge with below sql statement
657 if ownerCheck == false or ownerCheck == nil then else -- As a shceck to make sure you arn't being malicous
658 local newRep = ownerCheck[1]["reputation"] - 1
659 sql.Query("DELETE FROM investmentGroupsAssets WHERE rowid = "..assetID.." AND locationID = "..ownerCheck[1]["groupID"].."") -- Removes the investment from the inv group assets
660 sql.Query("UPDATE investmentGroups SET reputation = "..newRep.." WHERE ownerSID = "..ply:SteamID64().." ") -- Removes the investment from the inv group assets
661 end
662end)
663
664net.Receive("LogoutStocks",function(_, ply)
665 local onlineMarket = stockAddonFuncs.currentMarket(ply) -- Finds what market you are on
666 if !(onlineMarket) then return end
667 table.RemoveByValue(stockMarket[onlineMarket]["marketPlayers"], ply) -- Removes you from the net stream
668end)
669
670net.Receive("tradeWarningAccepted",function(_, ply)
671 stockAddonFuncs.insidTradePlayer(ply)
672end)
673
674---------------------------------
675
676function stockAddonMainMenu(ply)
677 local hasInvGroup = sql.Query( "SELECT name FROM investmentGroups WHERE ownerSID = '"..ply:SteamID64().."' LIMIT 1 " ) -- Checks to see if you have an inv group
678 --------
679 local investmentGroups = sql.Query( "SELECT groupID, name, reputation FROM investmentGroups ORDER BY reputation DESC" ) -- Get all the inv groups
680
681 if investmentGroups == false or investmentGroups == nil then -- Does a check if there are no groups (i have it check for nil and false as sometimes it does either)
682 investmentGroups = {}
683 end
684
685 --print(ply:SteamID64()) | Not a place for debugging anymore, bings
686
687 local financialReturns = sql.Query( "SELECT rowid, amount, returnedBy FROM investmentGroupReturnableMoney WHERE ownerSID = '"..ply:SteamID64().."' " ) -- Checks to see if you have an inv group
688
689 if financialReturns == false or financialReturns == nil then -- Does a check if there are no groups (i have it check for nil and false as sometimes it does either)
690 financialReturns = {}
691 end
692 -------
693 net.Start("newMarketteer")
694 net.WriteTable(investmentGroups)
695 net.WriteTable(financialReturns)
696 net.WriteType(hasInvGroup)
697 net.Send(ply)
698end
699
700function stockAddonFuncs.marketChange(priceIncrease, market)
701 local newStockValue = stockMarket[market]["newStockValue"] + priceIncrease
702 if newStockValue > stockMarket[market]["hoverStockValue"]/10 then -- for DRASTIC changes
703 stockMarket[market]["newStockValue"] = newStockValue
704 end
705end
706
707function stockAddonFuncs.currentMarket(ply)
708 for k, markets in pairs(stockMarket) do
709 for _, v in pairs(markets["marketPlayers"]) do
710 if v == ply then
711 return k
712 end
713 end
714 end
715end
716
717function stockAddonFuncs.activeAssets(ply, market)
718 if !(market) then return end
719 local assetList = sql.Query("SELECT rowid, purchasePrice, amount, type FROM marketBuyins WHERE assetSID = '".. ply:SteamID64().."' AND market = "..market.." ")
720
721 if assetList == false or assetList == nil then
722 assetList = {}
723 end
724
725 return assetList
726end
727
728local insideTraderInfluencer = {}
729local insideTraderUsers = {}
730function insideTrader(ply)
731 if insideTraderUsers[ply] != true then
732 if copJobs[team.GetName(ply:Team())] then -- If the player is a cop
733 local chanceOfResponse = math.random(1, 100)
734
735 if chanceOfResponse > 60 then
736 local randomTrader = math.random(1, #insideTraderUsers)
737 local unluckyTrader = insideTraderUsers[randomTrader]
738
739 if unluckyTrader == nil then
740 net.Start("insideTraderChatText")
741 local chatText = {Color(255,0,0,255), "Inside Trader", Color(255,255,255,255), " Nobody talks to me :( "}
742 net.WriteTable(chatText)
743 net.Send(ply)
744 else
745 net.Start("insideTraderChatText")
746 local chatText = {Color(255,0,0,255), "Inside Trader", Color(255,255,255,255), " OKAY OKAY ILL SNITCH! "}
747 net.WriteTable(chatText)
748 net.Send(ply)
749
750 ply:warrant(unluckyTrader, "Inside trading")
751
752 net.Start("insideTraderChatText")
753 local chatText = {Color(255,0,0,255), "Inside Trader", Color(255,255,255,255), " Some guy named ", Color(0,0,0,255), unluckyTrader:Nick(), Color(255,255,255,255), " came to me I swear!"}
754 net.WriteTable(chatText)
755 net.Send(ply)
756
757 insideTraderUsers[ply] = nil
758 end
759 else
760 net.Start("insideTraderChatText")
761 local chatText = {Color(255,0,0,255), "Inside Trader", Color(255,255,255,255), " F*** off, I'll never snitch! "}
762 net.WriteTable(chatText)
763 net.Send(ply)
764
765 local randomTrader = math.random(1, #insideTraderUsers)
766 insideTraderUsers[ply] = nil
767 end
768
769 MoveNPC()
770 else
771 net.Start("tradeWarning")
772 net.Send(ply)
773 end
774 end
775end
776
777function stockAddonFuncs.insidTradePlayer(ply)
778 if copJobs[team.GetName(ply:Team())] then return end -- If the player is a cop
779
780 if #insideTraderInfluencer == 0 then
781 local targetedMarket = math.random(1,12)
782 local currentTime = os.time()
783 local endTime = os.time() + math.random(300,600)
784 local eventLength = math.Round((endTime-currentTime))
785 local eventName = stockMarket[targetedMarket]["stockName"]
786
787 insideTraderInfluencer = {{["eventLength"] = endTime, ["eventName"] = eventName}}
788
789 timer.Simple(eventLength,function()
790 local marketStrength = stockMarket[targetedMarket]["newStockValue"]/stockMarket[targetedMarket]["hoverStockValue"]
791 local crashBase = 20*marketStrength
792
793 local marketAI = math.random(0,100)
794
795 if marketAI < crashBase then
796 stockAddonFuncs.marketChange(-stockMarket[targetedMarket]["newStockValue"]*0.1, targetedMarket)
797 else
798 stockAddonFuncs.marketChange(stockMarket[targetedMarket]["newStockValue"]*0.05, targetedMarket)
799 end
800
801 table.Empty(insideTraderInfluencer)
802 end)
803 end
804
805 net.Start("insideTraderChatText")
806 local chatText = {Color(255,0,0,255), "Inside Trader", Color(255,255,255,255), " Someone tells me the ", Color(0,0,0,255), insideTraderInfluencer[1]["eventName"].."'s", Color(255,255,255,255), " value will crash in around ", Color(0,0,0,255), tostring(math.Round((insideTraderInfluencer[1]["eventLength"]-os.time())/60)), Color(255,255,255,255), " minutes - be careful though as by talking to me you have put yourself at risk"}
807 net.WriteTable(chatText)
808 net.Send(ply)
809
810 if table.HasValue(insideTraderUsers,ply) then else
811 table.insert(insideTraderUsers, ply)
812 end
813
814 MoveNPC()
815end
816
817function stockAddonFuncs.marketGenerator(ID, difficulty)
818 local newBox = 0
819 local oldBox = 0
820 local newMarketValue = 0
821
822 for i = 1, 119 do -- Generates a pre-existant market
823 local changeAmount = newMarketValue/difficulty
824 oldBox = newBox
825 newBox = Rand(-changeAmount,changeAmount)
826 newMarketValue = (stockMarket[ID]["newStockValue"] + oldBox) + newBox
827
828 table.insert(stockMarket[ID]["marketValues"], newMarketValue)
829 table.insert(stockMarket[ID]["marketOldValues"], newMarketValue) -- I could generate a new set of stocks for it - but bit of a waste rly tbh ngl
830 end
831
832 -------------------------------------
833
834 timer.Create("marketTable"..ID,1,0,function() -- Continues the market
835 local changeAmount = newMarketValue/difficulty
836 oldBox = newBox
837 newBox = Rand(-changeAmount,changeAmount)
838 newMarketValue = (stockMarket[ID]["newStockValue"] + oldBox) + newBox
839
840 table.remove(stockMarket[ID]["marketValues"], 119)
841 table.insert(stockMarket[ID]["marketValues"], 1, newMarketValue)
842
843 net.Start("SendValues") -- Sends the market to people with the addon running
844 net.WriteFloat(newMarketValue)
845 net.Send(stockMarket[ID]["marketPlayers"])
846 end)
847
848 timer.Create("oldMarketData"..ID,60,0,function() -- Stores historic values in the market evey 60 secs + stablizes sudden changes in the market
849 table.remove(stockMarket[ID]["marketOldValues"], 119)
850 table.insert(stockMarket[ID]["marketOldValues"], 1, stockMarket[ID]["marketValues"][60])
851
852 local stockGap = stockMarket[ID]["hoverStockValue"]-stockMarket[ID]["newStockValue"] -- Market stablizer
853 local marketOffBalance = Rand(stockGap*0.1, stockGap*0.2)
854
855 stockAddonFuncs.marketChange(marketOffBalance, ID)
856 end)
857
858 timer.Create("marketAI"..ID,300,0,function() -- Stores historic values in the market evey 60 secs + stablizes sudden changes in the market
859 local marketStrength = stockMarket[ID]["newStockValue"]/stockMarket[ID]["hoverStockValue"]
860 local crashBase = 10*marketStrength
861
862 local marketAI = math.random(0,100)
863
864 if marketAI < crashBase then
865 stockAddonFuncs.marketChange(-stockMarket[ID]["newStockValue"]*0.1, ID)
866 else
867 stockAddonFuncs.marketChange(stockMarket[ID]["newStockValue"]*0.05, ID)
868 end
869 end)
870end
871
872timer.Create("newsFeed",stockAddonConfig.eventFrequency,0,function()
873 local targetedMarket = math.random(1,12)
874 local marketAI = math.random(0,100)
875
876 local stockValue = stockMarket[targetedMarket]["newStockValue"]
877 local marketStrength = stockMarket[targetedMarket]["newStockValue"]/stockMarket[targetedMarket]["hoverStockValue"]
878 local crashBase = 10*marketStrength
879
880 timer.Simple(20,function()
881 if marketAI < crashBase then
882 stockAddonFuncs.marketChange(-stockMarket[targetedMarket]["newStockValue"]*0.2, targetedMarket)
883 else
884 stockAddonFuncs.marketChange(stockMarket[targetedMarket]["newStockValue"]*0.1, targetedMarket)
885 end
886 end)
887
888 table.remove(stockAddonNewsItems,3)
889 table.insert(stockAddonNewsItems,1,{["messenger"] = stockMarket[targetedMarket]["stockName"], ["messagebody"] = stockMarket[targetedMarket]["stockCrashEventTweet"], ["time"] = CurTime()})
890
891 net.Start("marketTremors")
892 net.WriteFloat(stockMarket[targetedMarket]["newStockValue"])
893 net.WriteString(stockMarket[targetedMarket]["stockCrashEvent"])
894 net.WriteString(stockMarket[targetedMarket]["stockPrefix"])
895 net.WriteString(investmentGroupAdvertises[1])
896 net.Broadcast()
897
898 if #investmentGroupAdvertises > 1 then
899 table.remove(investmentGroupAdvertises, 1)
900 else
901 table.insert(investmentGroupAdvertises,"Advertise your investment group here")
902 table.remove(investmentGroupAdvertises, 1)
903 end
904
905 timer.Create("marketNewsUpdate",1,30,function()
906 net.Start("sendNewsValues")
907 net.WriteFloat(stockMarket[targetedMarket]["marketValues"][1])
908 net.Broadcast()
909 end)
910end)
911
912---------------------------------
913
914for k, v in pairs(stockMarket) do
915 stockAddonFuncs.marketGenerator(k, v["stockDifficulty"])
916end
917
918resource.AddFile("materials/flatsingleworker.png")
919resource.AddFile("materials/multiworkertemimage.png")