Jump to content

damage22

Members
  • Posts

    9
  • Joined

  • Last visited

damage22's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. Thanks! Yeah, that's a good idea. It's always a trade-off between access speed and amount of free memory, but if i have enough free memory, why not use it to lower CPU load? So I'll use cache for online players (even if it will be 250+, as it is planned for MTA 1.1, it's not that much), and query for data on player login.
  2. Ok, thanks! And what about pre-load vs. ondemand? I mean, if the server has enough free RAM, wouldn't it be easier to load all stats to local variables on resource start? Or it's too much? BTW, isn't xml loaded to memory? Because when i edit xml on running server, ingame contents change only after another xmlLoadFile. Should i load-unload it, or it's ok to keep it in memory?
  3. Hi everybody! I'm trying to figure out the best way to store data about players, for example their stats, car keys, houses etc. The built-in system, as far as i get it, has moved from accounts.xml to internal.db. Developers claim that now it's faster and more reliable, hence xml is slower. Also i've noticed, that all values are stored in the same table, with key and userid fields used to select them. So i suppose it's slower than dedicated tables for each key (or each player?). Basciaclly, i've came up with several ideas: 1) Load XML when resource starts, then use it to get player stats if needed 2) Use setAccountData and getAccountData each time we need something 3) Use SQLite and special tables for stats, vehicle ownership etc., then query if there's something we need 4) Use any of those above to load data on resource start (or player login), then store the info in some global variables (eg arrays, indexed by user id) 5) Same as #4, but use setElementData on player with sync turned off I understand, that with 10 players and 20 accounts all of them will work fine, but i suppose that with increased load some of them will be slower than the others. I also understand, that each method will have different pros and cons in different scenarios. To make this easier, let's say i want to store car keys (and each player can have more than one) and check them everytime player enters\exits\starts the vehicle. Suggestions? Thanks in advance!
  4. Hello again! As some people may have noticed, GTA:SA has several vehicles sharing one id and collision detection, but with different textures models. For example, NRG500 (id 522) spawns with or without vents and extra exausts, and the "Arctic" semitrailer (id 435) has different company logos. The model is random on each spawn. So i wonder, is there a way to control it? Thanks in advance
  5. to eAi Alright, so i can't just break execution of a function, wait for reply and then continue from that exact position. I got the "callback" idea, but on the second thought, moving all my functions to serverside, except for GUI and marker hits, will make my life a lot easier and, probably, will save some resources by not having to send that data back and forth. By the way, speaking of computational costs, are there any tips on script optimization? to robhol Actually, that tutorial was the first thing i read, when i started scripting. And thanks, it was very useful and a good thing to start.
  6. Thanks, eAi! Yes, that's what i thought about - writing my own client-server message dispatcher - but it's too complex for such a minor task. Now i see only two reasonable ways to deal with it - leave it as it is, with full sync and potentially a big waste of resources, or re-write the script, so all the checks are done on the serverside, and i'm leaning towards the last one. Still it would be nice to have a built-in function, that would allow "on-request" syncing (ie when you call it, it requests the data from the server, waits for the reply and then returns the requested data) - simple, like getElementData, but with no excessive syncing, when you don't actually need it.
  7. Thank you for replying, but setting cargo works fine, that's what i did already. I've got problems getting that data back. Let me explain what i mean: What i had: Client function setCargo(theTruck, cargoValue) return triggerServerEvent ( "onTruckUpdate", theTruck, cargoValue ) --for setting cargo value, i.e. when i load the truck end --and function getCargo(theTruck) return getElementData(theTruck,"cargo") -- to get my data back, easy, one line end Server addEvent("onTruckUpdate", true) addEventHandler( "onTruckUpdate", getRootElement(), setTruckCargo) function setTruckCargo ( theTruck, cargoValue ) setElementData(theTruck,"cargo",cargoValue, [b][color=#FF0000]true[/color][/b]) end This works just fine, except for that true, which means that data will be synced with all clients immediately. I simply don't need that, because it's not urgent and i don't need it on all the clients at the same time. But when i change it to false, switching the sync off, i can no longer use getElementData to retrieve the data from the server. To use the event system, i'll have to use two events ("query" and "reply") and lots of code instead of that simple <> line. Is there another way to grab my data from server without those two events? In other words, is it possible to "request" data from server by a convenient way? Or at least, is it possible to write an encapsulated function, that would make a request and return all the values i need? Like: function getMyData(theTruck) --get the data from the server-- return myData end
  8. Hello! I'm currently working on a trucking script and i think i'm a bit stuck. The current version of the script uses setElementData and getElementData for storing information about cargo in the vehicle elements. But the setElementData function syncs that data with all the players by default . That means - every player will sync his data with every other player, hence potentially we get N*N syncs, and that is a waste, because only the player currently driving the car and the server have need for that info. The good thing is: i can have a function, that is availible at the clientside and simply returns all information needed, like local a = simplyGetDataFromServer(vehicle) Now when i switch the ElementData sync off, i cannot use getElementData to retrieve it from the serverside. I thought about using the event system, but i can't think of a way to send a request and recieve a reply right in the body of one given function, something like this: function getData() triggerServerEvent("onDataRequest",...) local a a = ... --data from server return a end First i thought about something like local a function getData(vehicle) triggerServerEvent("onDataRequest",...) end addEvent("onDataReply",true) addEventHandler("onDataReply",getLocalPlayer(), function (newa) a = new a end) function someFunction() getData(vehicle1) local b = a*a ... end but it seems unreliable to me. Any ideas on how to "manually" sync that data, easy and reliable way?
×
×
  • Create New...