Home   Help Search Login Register  

Author Topic: SP vs MP scripting  (Read 2610 times)

0 Members and 1 Guest are viewing this topic.

Offline Proxemo

  • Members
  • *
SP vs MP scripting
« on: 27 Sep 2007, 03:18:42 »
Ok. So I decided that I wanted to test my map that I made. Got all the scripts working fine and everything. I've only tested this in the editor though. I decide to host it online on my box and now crap hits the fan. None of my scripts work, I received an error where I needed to add a gamelogic and call it server (which I did) and it is saying that one of my scripts (xxx.sqs is not found) when it is in the folder. I have no idea what the deal is.

A quick search resulted in the differences between local and server. I'm a noob at this so please explain this to me in english and not refer me to another link unless the link is server scripting for dummies. I have searched and found the link that explains it but it didn't help me as far as coding it to get this to work.

My problem is:

Why are my scripts not working? (I know there is a difference between local vs server) but I have no clue. Something to do with this perhaps?
?(!isServer): exit

Why is it saying I'm missing a script file when it is in there?
« Last Edit: 27 Sep 2007, 03:32:22 by Proxemo »

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: SP vs MP scripting
« Reply #1 on: 27 Sep 2007, 06:39:28 »
Are you by any chance using baf_f & included (or intended to) the spectator scirpt?
if so check for onPlayerRespawnAsSeagull.xxx and rename it to onPlayerRespawnAsSeagull.sqs

Offline Proxemo

  • Members
  • *
Re: SP vs MP scripting
« Reply #2 on: 27 Sep 2007, 09:01:59 »
No BAF here. I have the map pack thing but that's about it.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SP vs MP scripting
« Reply #3 on: 27 Sep 2007, 12:29:31 »
He means "BAS f", which is a suite of files (scripts, config, html) which are very useful for putting in any mission to get you started.

The command isServer is true if the script is running on the dedicated MP server or if you are in an SP game. This command was added to replace the old workaround, which was to create a gamelogic in the editor called "server", which would allow you to use the code "local server" in order to find out if the script was being run on the server.

The effect of:
Code: [Select]
?(!isServer): exit
is to stop the rest of the script being run on clients in MP. What you may not realise is that the rest of the script on't run at all in SP, so that may be your problem; if the rest of that script contains errors, they won't be apparent in SP mode (in SP games, your scripts are running on something that is both a client and a server). Unless you give us some more details about what the script you are writing is attempting to do, possibly giving us a link to it or pasting up some of the code in the forum, we can't really be a lot more helpful than that.

One extra comment (based on the fact that you have the SQS code "?(!isServer): exit" in your script): If you are new to scripting, learn the SQF syntax rather than the SQS one. Although the game happily runs it, SQS is pretty much deprecated and is a lot slower to run and harder to read or write.
« Last Edit: 27 Sep 2007, 12:31:39 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Proxemo

  • Members
  • *
Re: SP vs MP scripting
« Reply #4 on: 28 Sep 2007, 01:52:45 »
Thnx for the reply. It's funny that you say sqf is easier to learn. When I decided to do this project, I found sqs much, much easier to pick up. That is why I used it. I am self taught and I was going the easy way out. :P All this stuff about sp vs mp, dedicated vs non-dedicated box is all news to me.

Well with regards to my scripts:

The only scripts that work are the radio commands ones, which are in sqs.

Lets take a couple my hint scripts.

These are basic hint/hintC commands that are activated by a trigger and thats it. I would like this to run on all clients when someone activates it which is to say, when someone activates it, I want the hint command to display on all boxes. That simple. Again in SP, they work fine. In MP (would like this to work on both my box as server and our dedicated server), when I activate the trigger to display the hint/hintC commands, nothing happens.

Thanks in advance

Also, will downloading this BAS F thing configure everything for multiplayer or will it just add extra crap to the ingame editor?


Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: SP vs MP scripting
« Reply #5 on: 28 Sep 2007, 02:04:43 »
sqs is to sqf as (old ANSI)BASIC is to C.  It is easier for people with no programming background to get into sqs, but sqf forces you to learn to program in a better style. If you learn sqf it will go a long way towards helping you understand the basic principles of most programming languages.
urp!

Offline Proxemo

  • Members
  • *
Re: SP vs MP scripting
« Reply #6 on: 28 Sep 2007, 02:20:13 »
Will it allow me to play MP?

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SP vs MP scripting
« Reply #7 on: 28 Sep 2007, 13:44:05 »
Sorry, I didn't mean to push the thread quite so off-topic :whistle:

SP/MP issues are not affected in any way by whether you use SQS or SQF. SQS will actually allow you to do anything that SQF does, but SQS makes simple things easier and complex things harder. Thus, if anyone intends to take scripting seriously, they really should be using SQF because it will pay off in the long-term, not the short-term.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: SP vs MP scripting
« Reply #8 on: 28 Sep 2007, 16:53:36 »
bas_f won't change anything to ur editor, it's just a heap of premade scripts that are for you to use; it's documented so you can check it out without any harm  :D

Offline Proxemo

  • Members
  • *
Re: SP vs MP scripting
« Reply #9 on: 28 Sep 2007, 21:12:30 »
I'm not even going to try it if I can't even get my scripts working. This is my priority. I'm not going to add anything more until I get this stuff working.


Anyone know how to fix this problem? Is it a simple code I need to add before each script or something else? I just want my scripts to run on all clients.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SP vs MP scripting
« Reply #10 on: 28 Sep 2007, 22:29:51 »
isServer is true in any SP game or on the dedicated server in MP. Because of this, you can't use just isServer to see if you are on a dedicated server, because the SP game is both a client and a server. The difference between a SP game and a MP server is that on the dedicated server, player is objNull.

Code: [Select]
<code run on all machines>
? (isServer && (isNull player)) : exit
<code run on clients in SP/MP but not on a dedicated MP server>
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Proxemo

  • Members
  • *
Re: SP vs MP scripting
« Reply #11 on: 28 Sep 2007, 22:37:13 »
Well that explains why putting ?!(isServer): exit  at the beginning of all my scripts didn't work >:(


So are you saying that if I were to run my scripts (unmodified from SP) on a dedicated server that they would work?

And that if I were just to host it, I would have to put the code you included (? (isServer && (isNull player)) : exit) at the beginning of each script?


*I cannot believe there are two different ways of coding sp/mp. This stuff is driving me insane. Not only does BIS not include a manual for this crap but they don't explain that what you run in sp may not work in mp. Then there is the sqs/sqf thing I never knew about. For someone like me who is trying this out for the first time (never had ofp), this crap makes you want to give up.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SP vs MP scripting
« Reply #12 on: 28 Sep 2007, 23:14:18 »
Quote from: Proxemo
So are you saying that if I were to run my scripts (unmodified from SP) on a dedicated server that they would work?

And that if I were just to host it, I would have to put the code you included (? (isServer && (isNull player)) : exit) at the beginning of each script?
Well, I haven't seen your scripts, so I can't say what would "fix" them. If your intention is that the scripts are only run in SP or by clients in MP, then yes, that would be the code to use.

Yeah, the way things work isn't really very clear, especially for people who can script in SP moving to MP. The thing is that if you are coding for SP then the BIS simplification (having just a single process, not a separate client and server) makes SP scripting a whole lot easier to work with. If they didn't have it this way, then even an SP game would have all the complexity of a one-player MP game, so most people wouldn't even be able to get SP working.

To summarise, it isn't that MP scripting is more difficult than it could be, it is that SP scripting is easier than it could be. So you should be thanking BIS for that ;P
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Seven

  • Members
  • *
  • Am I a llama?
Re: SP vs MP scripting
« Reply #13 on: 29 Sep 2007, 05:46:58 »
I'm not even going to try it if I can't even get my scripts working. This is my priority. I'm not going to add anything more until I get this stuff working.


Anyone know how to fix this problem? Is it a simple code I need to add before each script or something else? I just want my scripts to run on all clients.

Reading a lot makes you better in writing whatever language that is  :D
So using or looking at other ppl's scripts will increase ur abillity to understand and apply or even write them urself ;)

Offline Proxemo

  • Members
  • *
Re: SP vs MP scripting
« Reply #14 on: 29 Sep 2007, 08:08:12 »
Well, I haven't seen your scripts, so I can't say what would "fix" them. If your intention is that the scripts are only run in SP or by clients in MP, then yes, that would be the code to use.

Yeah, the way things work isn't really very clear, especially for people who can script in SP moving to MP. The thing is that if you are coding for SP then the BIS simplification (having just a single process, not a separate client and server) makes SP scripting a whole lot easier to work with. If they didn't have it this way, then even an SP game would have all the complexity of a one-player MP game, so most people wouldn't even be able to get SP working.

To summarise, it isn't that MP scripting is more difficult than it could be, it is that SP scripting is easier than it could be. So you should be thanking BIS for that ;P


Like I mentioned earlier, all my scripts from a simple "hintC/hint" commands to the more complex (which are not all that complex) are not working. Only the radio triggers work.

i.e.
--------------------------------------------
test.sqs:

hintC "blah blah blah."

I then create a trigger, set parameters (act. by blufor, etc) and in the activation line put:

this exec [test.sqs];
----------------------------------------
I want the hintC command to be read on everyone's PC even if they do not activate it themself.

In SP, it works great. In MP, I could walk and do backflips over the trigger and nothing happens. This is a simple script.
I am using Arma Edit for this. I also just noticed that my "wizard created custom crates" in Arma edit do not work. NOTHING WORKS.

Reading a lot makes you better in writing whatever language that is  :D
So using or looking at other ppl's scripts will increase ur abillity to understand and apply or even write them urself ;)

Yeah that's what I did to learn sqs. Thanks to this website, a few others and hours upon hours of breaking down the arma missions, I was able to write my first script which was a hintC command.  :D