Community Forum

calculate correct price in multiplayer?

Forum Overview >> Scripting

Created30.12.2018 15:24

Unknown 30.12.2018 15:24

i want calculate the price for fill types, but in mp its dont work for non host players.

my formula to calculate the fill type price (1000l):

"sellStation" is a station from "g_currentMission.storageSystem.unloadingStations"
(sellingStation.originalFillTypePrices[fillType] + sellingStation.fillTypePriceRandomDelta[fillType]) * sellingStation.priceMultipliers[fillType] * EconomyManager.getPriceMultiplier() * 1000

in singleplayer and for the multiplayer host is this correct.
but for non host players is that wrong because "sellingStation.fillTypePriceRandomDelta" is always 0...

exists another way to calculate the correct filltype price?

- sry for bad english :D

Bilbo Beutlin (BBeutlin) 30.12.2018 16:53
I'd assume 'getPriceMultiplier()' needs additional arguments. But so far I didn't find examples for usage.
Perhaps the economy issue is still in work and published later (hopefully).

Espen K. (estyx) 30.12.2018 20:27
It's most likely because you have to calculate it server-side (in MP) and send it to the client and update price in GUI somehow. You can probably find some info on the GUI part by looking at reference docs @ /

I have uploaded a mod I extended to support multiplayer (server<>client) to learn some of it myself, and I tried to comment some code to help others who are learning scripting. Maybe it will help you figure some of it out.

Unknown 31.12.2018 00:48
this was a great help!
i have now synced the prices (only the delta values, stationID and fillTypeID of the best fill types to reduce network traffic) if a player connect to the server and every 10 seconds.
and it works :)

now my question is in which interval should i update these values (19 * 2 (fill type ids and station ids) + 1 (dataset count) int values + 19 float values (delta values) = 58 values to update)?
i send the dataset every 10 seconds. is that a good idea? too much? too little?
im a noob in (sync) network stuff and i dont know what interval is the best for my case :D

-> another question about timer: should i call removeTimer in deleteMap?

and again sorry for my english :D

Note: Log in to post. Create a new account here.