Jump to content
Sign in to follow this  
LightWalker

Local Server in AddOn

Recommended Posts

I searched the forum but coulnd find a proper anwer to my question:

Building an AddOn in which I want a script to run on the Server only (Multiplayer) and not on any client. Some how I am lost here (or spent too much time on the AddOn) but I could use some help on this.

How do I determine if the script is running on the server only?

Share this post


Link to post
Share on other sites

Hmm... Well you need to have a gamelogic named server to have the following work:

At the start of the script you want to run for the server ONLY, put

?!(local Server): exit

Simple. smile_o.gif

What most addon makers do (at least from what I've seen) they put a note in the readme to put in a gamelogic named Server in the mission editor. I'm not aware of any other way of doing it.

EDIT:

And to get more in detail (goddamn I love mission editing :P ) you can have a certain part of the script to run for the server only, for example if you want a unit to join a group and do it like you do in SP:

[man] join group sam

The leader of the group will "report" the join as many times as there's players on the server. At least that's what happens on non-dedicated servers, which we almost every time play on. TO get him report it once:

?(local Server): [man] join group sam

I wont guarantee that this will work on dedicated servers, never really played any of my missions on dedi servers... smile_o.gif

Share this post


Link to post
Share on other sites

Thanks HawkinsDaFin - that's what I use for editing too.

But for this I want the AddOn scripts independantly check if they are running locally on a server (dedi), and if not : exit.

But again, thanks for your reply!

Share this post


Link to post
Share on other sites

No problem. smile_o.gif

I haven't come accross to this kind of problem in my addon editing days yet. Though, one way which might work, would be to somehow detect something... Like FDF does in it's UAV Ranger for example. It checks if the UAV is on the players "hands" so to speak. Haven't looked into it though. Not sure but it might be helpful if I/we knew what it is exactly you want to do in the script? What executes it and such. smile_o.gif Maybe if you execute it on a unit, check if it's local with the same command? Not sure if that will work though. wow_o.gif

Share this post


Link to post
Share on other sites
Thanks HawkinsDaFin - that's what I use for editing too.

But for this I want the AddOn scripts independantly check if they are running locally on a server (dedi), and if not : exit.

But again, thanks for your reply!

Check the ECP scripts, we have a workaround that you might like to look at.

RED

Share this post


Link to post
Share on other sites

The point is that i am scripting serveral crash situations in the addon itself where the vehicle is replaced by a crashed version. You can imagine I dont want all clients (players) do this.

Quote[/b] ]Check the ECP scripts, we have a workaround that you might like to look at.

Is there a more easy way to find that workaround. That would be helpfull biggrin_o.gif

Share this post


Link to post
Share on other sites

Well, the simpliest way to check if it dedi or not:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?isNull player: code that should be runned only on dedicated serv.

This principle is based on that on dedi we doesn' have a human player, so... you understand that I want to say wink_o.gif

Share this post


Link to post
Share on other sites

Wouldn't it cause problems then when running hosted game where there is player on server...

There usually isn't too much difference whether scripts runs at server or where addon vehicle is local... Vehicle local method is what OFP likes anyway in most cases, as most script functions do not work on non-local stuff.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×