Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, degenerate_762), 1,309 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
functions server side or client #94557
10/15/06 10:52
10/15/06 10:52
Joined: Sep 2006
Posts: 108
J
Jered Offline OP
Member
Jered  Offline OP
Member
J

Joined: Sep 2006
Posts: 108
ok I got a question. by default is a function executed on the server side or the client side if not put in a ifdef server or else ifdef client part.

I mean if you had nothing but two scripts that only had the code needed to connect then added a function without saying where to execute it, does the server and the client both automatically execute it, or just the server or just the client? what?


3DGS (6.4) Commercial
Re: functions server side or client [Re: Jered] #94558
10/15/06 11:10
10/15/06 11:10
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
The main function is executed on the server if you start a server instance, and on the client when you start the client instance. If the main function (or any function) calls another function it is executed on the same place where the calling function is running.

If you create an entity with ent_create, its function is executed on the server.

If you create an entity with ent_createlocal, its function is executed on the creating client.

Actions run on the server by default, unless dplay_localfunction is on.

Re: functions server side or client [Re: Excessus] #94559
10/15/06 12:14
10/15/06 12:14
Joined: Sep 2006
Posts: 108
J
Jered Offline OP
Member
Jered  Offline OP
Member
J

Joined: Sep 2006
Posts: 108
ok, so if there is a function being called from main it is ran on both the server and the client if it is not set aside to just the server or just the client.

if I am getting this correctly, then main should really be set up in two sections....everything I want the server to perform in a ifdef server, or esle if (connection == 1); and anything i want the client to do without the server doing it has to be put in the ifedf client; or else if (connection == 2)....as far as the "main" function is concerned?

Looks to me if you do not split it up that way, hten you have the same function running on both the client and the server, when that is not always nessasry...is this all correct? if not I am trying to learn, so any help would be aprreciated.


3DGS (6.4) Commercial
Re: functions server side or client [Re: Jered] #94560
10/15/06 12:22
10/15/06 12:22
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
yes that's correct.

I have a main function where I set some general variables, then a few IFDEFs with the client and server code in them (seperated). In the client code I set the on_client function and on the server I set the on_server function. Then I continue to call functions that belong strictly to the client or server side.

Re: functions server side or client [Re: Excessus] #94561
10/15/06 12:31
10/15/06 12:31
Joined: Sep 2006
Posts: 108
J
Jered Offline OP
Member
Jered  Offline OP
Member
J

Joined: Sep 2006
Posts: 108
ok so would you set the code inside ifdef in a while(1) wait(1) or would the function main itself take care of it, or does it matter where you put it? like for me the first thing I do is use a ifdef to wait on a connection, after that I want to do another ifdef and do what you are doing. The function main would take care of going back through it time and time again or would I have to put everything in a while(1) wait (1)?


3DGS (6.4) Commercial
Re: functions server side or client [Re: Jered] #94562
10/15/06 12:34
10/15/06 12:34
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
The main function is only called once. If you want a piece of code to be repeated you must put it in a loop.

If you don't have alot of experience in programming I'd do some single player coding first.

Re: functions server side or client [Re: Excessus] #94563
10/15/06 12:38
10/15/06 12:38
Joined: Sep 2006
Posts: 108
J
Jered Offline OP
Member
Jered  Offline OP
Member
J

Joined: Sep 2006
Posts: 108
okey, I think I get it all now, thank you so much Excessus, very much aprreciated...if i have further questions i will post them back to this thread.


3DGS (6.4) Commercial

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1