Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Garry's Mod Starfall v
« Previous 1 … 10 11 12 13 14 … 18 Next »
globaltables doesn't keep data between sf instances...
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Linear Mode
globaltables doesn't keep data between sf instances...
05-11-2015, 11:43 AM,
#3
Yuri6037 Offline
TSCM Member
***
Posts: 216
Threads: 45
Joined: Feb 2015
RE: globaltables doesn't keep data between sf instances...
Here is the lib code (which adds variables to global tables) :
Code:
function intellihud.RegisterVehicle(VehicleEnt, data) if (not(IsValid(VehicleEnt))) then error("VehicleEnt must be a valid vehicle entity !") return end if (globaltables.global.IntelliHUD == nil) then globaltables.global.IntelliHUD = {} end globaltables.global.IntelliHUD[VehicleEnt:index()] = data end

And now the code that reads from it :
Code:
local function CheckPlayerSeats(p) if (globaltables.global.IntelliHUD == nil) then return end if (p:inVehicle()) then if (not(plysVeh[p] == p:vehicle())) then plysVeh[p] = p:vehicle() local e = p:vehicle() if (IsValid(e) and not(globaltables.global.IntelliHUD[e:index()] == nil)) then local data = globaltables.global.IntelliHUD[e:index()] if (IsValid(data.ZPM) and data.ZPM:class() == "starfall_processor") then plysData[p].VehData = {EnergyEntity = data.ZPM:getWirelink(), Name = data.Name, NameColor = data.NameColor} end end end if (not(plysData[p].VehData == nil)) then local en = plysData[p].VehData.EnergyEntity if (IsValid(en)) then if (not(plysData[p].VehData.PEnergy == en["P"])) then plysData[p].VehData.PEnergy = en["P"] plysForceSend[p] = true end end end elseif (IsValid(plysVeh[p])) then plysVeh[p] = nil plysData[p].VehData = nil plysForceSend[p] = true end end

The given function runs in a think hook to check if the player seats on a vehicle, and then retrieves if the vehicle exists on the defined IntelliHUD global table. However as I said, if you spawn the first function before the second one, the reader (second function) will not detect that the given vehicle is inside the table defined by first function. But if you inverse and spawn before the reader (second function), then it will detect any first function spawned.

You may also notice that the first function is not complete : indeed you need a special function that generates a table which contains an entity corresponding to ZPM starfall processor, a string name, and a color for the string name color.

To everyone, about this code, please don't copy it for your own projects, otherwise I will need to remove it from here. You can take the base idea if you want, just don't copy the code, and in plus that wouldn't help you understanding better how SF works by copying other's codes...

Thanks by advance,
Yuri6037
Find
Reply
« Next Oldest | Next Newest »


Messages In This Thread
globaltables doesn't keep data between sf instances... - by Yuri6037 - 04-11-2015, 09:47 AM
RE: globaltables doesn't keep data between sf instances... - by Person8880 - 04-11-2015, 06:36 PM
RE: globaltables doesn't keep data between sf instances... - by Yuri6037 - 05-11-2015, 11:43 AM
RE: globaltables doesn't keep data between sf instances... - by TheOneAndOnlyTee - 05-11-2015, 01:30 PM
RE: globaltables doesn't keep data between sf instances... - by Yuri6037 - 05-11-2015, 06:13 PM
RE: globaltables doesn't keep data between sf instances... - by Person8880 - 05-11-2015, 06:56 PM
RE: globaltables doesn't keep data between sf instances... - by TheOneAndOnlyTee - 06-11-2015, 02:58 AM
RE: globaltables doesn't keep data between sf instances... - by Yuri6037 - 06-11-2015, 08:15 AM
RE: globaltables doesn't keep data between sf instances... - by Yuri6037 - 06-11-2015, 01:00 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.