Welcome, Guest Thursday 17th April 2014, 16:27:06
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: Multiplayer Scripting problems!  (Read 329 times)
0 Members and 1 Guest are viewing this topic.
haroon1992
*
Offline Offline

My life is hopeless...


« on: 24 Aug 2010, 11:38:29 »


I've been learning the MP scripting for a while....

And I've got some problems :

NOTE : Ignore errors in the scripts(such as missing semicolons).
All scripts are just examples.

Problem 1 :

============
In my zombie script ,
Code:
If (isServer) then
{
zombie setBehaviour "SAFE";
zombie setSpeedMode "LIMITED";

_selectedSound = ZSounds select (random (count ZSounds) - 0.5));
zombie say _selectedSound;

};

And as you can see, the sounds will not be played, because the SAY command is local.
How do I make it so that all players (clients) hear the sound in this situation?



Problem 2 :
==============

zombie_init.sqf
------------------
Code:
if (isServer) then
{

Hz_Shoot = TRUE;
Hz_Flee = TRUE;
};


shoot.sqf
-----------
Quote
if (not (IsServer)) exitWith {};

while {alive vicim} do
{
   if (Hz_Shoot) then
   {
   victim dofire zombie;
   }else
   {
   sleep 1;
      };
};


As you can see, both zombie_init.sqf and shoot.sqf are only running on the server.

Question : Do i need to use PublicVariable for the variables,Hz_Shoot and Hz_Flee?


Problem 3 :
================
Question : How do i run a script for all clients from a scope that is only running for the server?

For example :
Quote

if (isServer) then
{
   nil = [] execVM "script.sqf";
};

What I want to do is, script.sqf to be executed on ALL machines.


-------------------------------------------------------------------------------
Other questions :

Where can i find which eventhandler is local and which is global?

Regards,
haroon1992
Logged

Very busy with life, business, and other stuff. Away from OFP for months. Not sure if I could get back onto it. Sad
i0n0s
Moderator
*****
Offline Offline



« Reply #1 on: 24 Aug 2010, 12:32:47 »

To 1:
Use publicvariable to execute the say on all computers.

To 2:
No

To 3:
What do you exactly want to achieve with the script?
Because you can simple start it within the init.sqf

Code:
nil = [] execVM "script.sqf";
Never ever do 'nil = ...'!
Logged
kju
*
Offline Offline



WWW
« Reply #2 on: 24 Aug 2010, 15:15:35 »

Use _nul or _dump = ..

to 3) Use PV and PVEH to launch a script on all machines.
http://community.bistudio.com/wiki/addPublicVariableEventHandler
Logged

Pages: [1]   Go Up
  Send this topicPrint  
 
Jump to: