OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting Multiplayer => Topic started by: haroon1992 on 24 Aug 2010, 12: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 ,
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
------------------if (isServer) then
{
Hz_Shoot = TRUE;
Hz_Flee = TRUE;
};
shoot.sqf
-----------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 :
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
-
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
nil = [] execVM "script.sqf";
Never ever do 'nil = ...'!
-
Use _nul or _dump = ..
to 3) Use PV and PVEH to launch a script on all machines.
http://community.bistudio.com/wiki/addPublicVariableEventHandler