Raised This Month: $32 Target: $400
 8% 

2 severs, same amount of money


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-13-2022 , 19:16   2 severs, same amount of money
Reply With Quote #1

hi there, so i saw somewhere that in like 5,6 servers (community servers) you've got the same amount of cash ($), and there weren't like round money, kill money (by default of cs).. you just got to do some jobs (depents on the mode) do gain money! If you've done like 50$ on first server, if you connect to second server, you have 50$ as well and so further!
1. How to make that? "connecting" two servers plugins?
2. Does anyone knows a plugin that do that with money? like, more than 16000, no rounds money, start money, etc (smth like all in one, money management) because i've searched before but didnt found, just for each but couldn't merge them
thank you!
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 03-13-2022 , 21:04   Re: 2 severs, same amount of money
Reply With Quote #2

mysql?
bigdaddy424 is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-14-2022 , 09:38   Re: 2 severs, same amount of money
Reply With Quote #3

You just need the ability to allow the servers to communicate with each other, or access the same database/files. An SQL server would be the simplest.

You could also handle this with sockets. One game server could also function as the data server for the other plugins/servers. UDP transactions I think would be pretty simple. Assume server 1 is the primary..server 2 connects, sends server 1 the players steam id, and server 1 responds with their money. When disconnecting from server 2, send server 1 the new money amount. Server 1 handles all data saving using nVault, or something
__________________

Last edited by Bugsy; 03-14-2022 at 09:50.
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-14-2022 , 22:30   Re: 2 severs, same amount of money
Reply With Quote #4

(My)SQL is certainly the best option here.

UDP is an unreliable mechanism for data transfer so you might lose data. If the servers on are the same machine, might not be as big of an issue but you still have to build and maintain your own plugin-based database and communication protocol.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-14-2022 , 22:38   Re: 2 severs, same amount of money
Reply With Quote #5

Agree, UDP isn't ideal, but probably enough for this. There can be an acknowledgement system where a client sends the server a request and if no response is received after an interval, re-send. There would be an issue when a client disconnects and his 'new' money value is transmitted but not received by the server, it'd be forgotten.
__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-14-2022 , 22:44   Re: 2 severs, same amount of money
Reply With Quote #6

You just described TCP, basically. Though not sure if TCP adds much delay to the thread execution.
__________________

Last edited by fysiks; 03-14-2022 at 22:45.
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-15-2022 , 00:09   Re: 2 severs, same amount of money
Reply With Quote #7

Yeah, that's where my head was at, I think UDP is more simplistic as you do not need to establish a formal connection, assuming this is more efficient. The game itself runs on UDP packets, so it has to be relatively reliable.
__________________

Last edited by Bugsy; 03-15-2022 at 00:10.
Bugsy is offline
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 03-15-2022 , 11:54   Re: 2 severs, same amount of money
Reply With Quote #8

thank you for your answers! gonna learn more about mysql
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-15-2022 , 14:45   Re: 2 severs, same amount of money
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
Yeah, that's where my head was at, I think UDP is more simplistic as you do not need to establish a formal connection, assuming this is more efficient. The game itself runs on UDP packets, so it has to be relatively reliable.
Games, in general, run on UDP not because it is relatively reliable, but because TCP is a terrible idea in this case. TCP must maintain the order of packets so for example, if packets 1,2,3 are received, packet 4 is lost and packets 5-1000 are received, packets 5-1000 will be held back until it receives packet 4 which can really disrupt gameplay. Imagine freezing the entire game because one meaningless packet was lost. This is a big no-no.
Moreover, games have advanced prediction algorithms on the client which can account for a few lost packets.

UDP is not reliable, at all, but this is by design. UDP sends the packet and after that, you are at the mercy of the network. If something goes wrong, tough luck. UDP won't assist in any way.
The question is about the reliability of the network(not UDP) and you can not make any assumptions about that. There are 2 choices:
-you need reliable communication: use TCP
-you are fine with losing packets from time to time(for example a video player, a game, etc): use UDP

Long story short, TCP does way too many things to maintain a stable communication channel which can end up hurting the game experience way more than it helps.

Delaying the main thread is also irrelevant, never run blocking calls in the main thread. Use threaded/asynchronous calls and delegate the work to a worker thread.
See threaded sockets module.

If the servers are on the same machine then there shouldn't be any packet loss using UDP as the packets will be routed locally thru the loopback interface, no potentially unstable network to mess with your packets.
__________________

Last edited by HamletEagle; 03-15-2022 at 14:56.
HamletEagle is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode