Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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
3 registered members (AbrahamR, AndrewAMD, ozgur), 763 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[ANet] Server-only function setup #264387
05/06/09 05:14
05/06/09 05:14
Joined: Oct 2006
Posts: 175
G
Gumby22don Offline OP
Member
Gumby22don  Offline OP
Member
G

Joined: Oct 2006
Posts: 175
Hi,

I've had a bit of fun playing with Anet, and quite like it smile

I was wondering if there is a quick explanation someone could give me of how to set up entity actions, or functions that run only on the server, for example bullet firing checks?

I created an enet_ent_create, but the action doesn't work for me, and I think I'm misunderstanding where things run, as I currently think it runs on all clients and hte server concurrently, and I may have to check if client_id == server_id and only run code if it does.

Is this on the right track?

Don
have a great day

Re: [ANet] Server-only function setup [Re: Gumby22don] #264466
05/06/09 12:22
05/06/09 12:22
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
First of all you have to know that 2 types of entities exit:

global entities:
+ created with enet_ent_create()
+ are automatically created on all clients and on the server
+ they have a global pointer, so they can be identified in the whole game everywhere
+ functions like enet_send_pos(),enet_send_skills()... only work with glob. ents
+ their function is started on all clients + server

local entities:
+ created with ent_create()
+ are only locally available (for client side effects etc.)
+ also the function is only started on the host that created the ent
+ enet_send_pos() etc. can't be used

You can split the function that is used in enet_ent_create() into several parts:

Code:
if(enet_ent_creator(enet_ent_globpointer(my)) == enet_get_clientid())
{//runs on the host that created an entity
}
if(enet_get_connection() == SERVER || enet_get_connection() == SERVER_CLIENT)
{//runs on the server and on the server+client
}
if(enet_get_connection() == CLIENT)
{//runs on the client only
}


If you want a normal function to run only server side, then do the following:
Code:
if(enet_get_connection() != SERVER)
{return();}


On my side (www.anet-plugin.com) is a tutorial "Simple 3D Chat Tutorial" that should explain everything.
Are you using the latest Beta of ANet? If not you have to use 1 instead of SERVER and 2 instead of CLIENT and 3 instead of SERVER_CLIENT.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: [ANet] Server-only function setup [Re: Dark_samurai] #264575
05/06/09 22:23
05/06/09 22:23
Joined: Oct 2006
Posts: 175
G
Gumby22don Offline OP
Member
Gumby22don  Offline OP
Member
G

Joined: Oct 2006
Posts: 175
Thanks heaps - that is most clear.

I had downloaded all the samples - should have realised that one would have what I needed. But what you just wrote here is most helpful, and hopefully for more than just me.

Don
have a great day


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