Jump to content
Sign in to follow this  
iceman77

isServer & createvehicle problem

Recommended Posts

I have a script that creates 2 vehicles.While on a dedicated server, in order to spawn the correct amount of vehicles I use isServer command so it dosent create 1 vehicle for every client. However when I destroy the vehicle(s) it dosent display the hints or sidechat.How do I broadcast the hints and sidechat to the clients?:681:

Private ["_objs"];

if (isServer) then
{
obj1 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c1",[], 0, "NONE"];
obj2 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c2",[], 0, "NONE"]; 

_objs = [obj1, obj2];

waituntil {sleep 0.3;{alive _x} count _objs == 1};
hint"1/2 caches destroyed";
if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
waituntil {sleep 0.3;{alive _x} count _objs == 0};
if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
if (!alive obj2) then {deletemarker "cache2"} else {deletemarker "cache1"};
hint"2/2 caches destroyed";
sleep 5;
Xray = player sidechat "Xray to HQ, the ammo caches have been destroyed, Xray out.";
sleep 10;
Headquarters=[West,"HQ"]; Headquarters SideChat "Copy Xray, good job.";
sleep 5;
Xray = player sidechat "Were on our way to HQ";

};

If someone could provide me an example (using my script) of how to broadcast the hints and sidechat to the clients I would be greatful.:218:

-david

Edited by Iceman77
Shortened the original post to tolerable length

Share this post


Link to post
Share on other sites

createvehicle, deleting stuff etc in server, then you send a publicvariable to everyone, on clients catch it with pubvar eventhandler and run task update, sidechat etc from that.

Share this post


Link to post
Share on other sites

Hi Shuko.Thanks for the reply. Could I bother you to give an example in relation to my scripts + what you just posted?That would be appreciated:bigglasses:

-david

Share this post


Link to post
Share on other sites

I began to cover some of what you would need to do in this other thread of yours:

http://forums.bistudio.com/showthread.php?t=125548

I can give you some example code, but first...is there any reason you do not want to use the normal task system (createSimpleTask, setTaskState, etc.)? It is by no means mandatory but it is "cleaner" and is what players expect?

--Edit--

Anyway, using your existing code, you could use public variables and event handlers but since you are only monitoring "alive", you probably don't need to use PVs at all:

Run this on your server:

if (isServer) then
{
   obj1 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c1",[], 0, "NONE"];
   obj2 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c2",[], 0, "NONE"];
};

Run this on your clients:

private ["_objs"];
_objs = [obj1, obj2];


//Wait until one object is dead.
waituntil {sleep 0.3;{alive _x} count _objs == 1};
hint"1/2 caches destroyed";
if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};


// Wait until the other object is dead.
waituntil {sleep 0.3;{alive _x} count _objs == 0};
if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
if (!alive obj2) then {deletemarker "cache2"} else {deletemarker "cache1"};
hint"2/2 caches destroyed";


// Send Chat Messages
sleep 5;
Xray = player sidechat "Xray to HQ, the ammo caches have been destroyed, Xray out.";
sleep 10;
Headquarters=[West,"HQ"]; Headquarters SideChat "Copy Xray, good job.";
sleep 5;
Xray = player sidechat "Were on our way to HQ";

That should do the trick. Basically, the server creates the vehicles and the clients wait until one of the objects is "dead" and progresses to the next waitUntil and so on. Since deleteMarker and sideChate are local commands they should run on the client since the monitoring scripts is running on them.

The same effect could also be done with triggers.

Edited by Loyalguard
Added examples

Share this post


Link to post
Share on other sites

I can give you some example code, but first...is there any reason you do not want to use the normal task system (createSimpleTask, setTaskState, etc.)? It is by no means mandatory but it is "cleaner" and is what players expect?

--Edit--

Anyway, using your existing code, you could use public variables and event handlers but since you are only monitoring "alive", you probably don't need to use PVs at all:

The same effect could also be done with triggers.

thanks for the relpy. Iam using the task commands. In the OP i simply left all uneeded code out to simplify my question as much as posssible. i just need to know how to create the vehicles on the server only and then when their dead, broadcast the messages to alal clients.

Ive already tried running the vehicles on the server by:

//Objective2 - summary:destroy 2 ammo caches, each in a diff location 

//Creates 2 markers and 2 objective targets for objective/task # 2. Aswell as adding 3d text above an (pre placed)invisible marker.

obj13DText = ["<t color = '#66FF00't/><t size='0.450'>Objective</t>",getmarkerpos "c1",40,0] spawn Objectives_3DText; 
obj23DText = ["<t color = '#66FF00't/><t size='0.450'>Objective</t>",getmarkerpos "c2",40,0] spawn Objectives_3DText; 

Private ["_marker1","_marker2","_objs","_x"];

_marker1 = createMarker ["cache1",getmarkerpos "c1" ];
_marker1 setMarkerShape "ICON";
"cache1" setMarkerType "DESTROY";
"cache1" setmarkersize [1,1];
_marker2 = createMarker ["cache2",getmarkerpos "c2" ];
_marker2 setMarkerShape "ICON";
"cache2" setMarkerType "DESTROY";
"cache2" setmarkersize [1,1];

//creates vehicles on server
[color="Blue"]if (isServer) then
{
obj1 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c1",[], 0, "NONE"];
obj2 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c2",[], 0, "NONE"]; 
};[/color]

//Waits until the objective/task target(s) have been destroyed so it can update the task and objective marker deletion

_objs = [obj1, obj2];

waituntil {sleep 0.3;{alive _x} count _objs == 1};
hint"1/2 caches destroyed";

if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
waituntil {sleep 0.3;{alive _x} count _objs == 0};
if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
if (!alive obj2) then {deletemarker "cache2"} else {deletemarker "cache1"};
"2" objStatus "done";
tskobj_2 settaskstate "succeeded";
obj_2 = true;
publicvariable "obj_2";
hint"2/2 caches destroyed";
objcompleted1 = ["Objective", "Completed"] spawn BIS_fnc_infoText;
sleep 1;
Xray = player sidechat "Xray to HQ, the ammo caches have been destroyed and all hostiles in Feruz Abad have been neutralized.Awaiting further orders, Xray out.";
sleep 1;
Headquarters=[West,"HQ"]; Headquarters SideChat "Copy Xray...intel reports 2 known AA nests in your area, advance on their locations and takem out.Once their eleminated proceed to mulladost, we'll be needing mull for a new FOB.Expect heavy resistance.The AA nest locations have been uploaded to your map. HQ out.";
sleep 1;
Xray = player sidechat "Copy HQ.We'll exterminate those nests, Xray out.";


//Executes a new briefing for the next task aswell as the script that will create the next objective object, marker and location.

execvm "tasks\briefing3.sqf";
execvm "objectives\AAnests.sqf";

This dosent work, it gives me error undefined variable _x as soon as the vehicles are created.

And iv'e made this mission using triggers only (several missions) achieving the same efffects iam after. I just wanted to make one with external scripts

Edited by Iceman77

Share this post


Link to post
Share on other sites

You should use the Multi-player frame work makes stuff like this so much easier.

http://community.bistudio.com/wiki/Multiplayer_framework

I also edited your code around a little, you had several errors.(I dont think you can use sleep in a waitUntil statement.)

// Make sure you place a functions module on the map.

If (!isServer) exitWith {};

// Create the vehicles.
obj1 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c1",[], 0, "NONE"];
obj2 = createVehicle ["UralReammo_TK_EP1",getMarkerPos "c2",[], 0, "NONE"];

// Wait until one or the other is destryoed.
waitUntil {(!alive obj1) || (!alive obj2)};

if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
if (!alive obj2) then {deletemarker "cache2"} else {deletemarker "cache1"};

// Wait untill the second one is destryoed.
waitUntil {(!alive obj1) && (!alive obj2)};

if (!alive obj1) then {deletemarker "cache1"} else {deletemarker "cache2"};
if (!alive obj2) then {deletemarker "cache2"} else {deletemarker "cache1"};


// You can add in all your task info here.




// Hint to all players in the MP game.
[color="red"][nil,nil,rHINT,"2/2 caches destroyed"] call RE;[/color]

// Send the side chats out.
// Name your team leader in the editor, im my example they are named gamma.

[color="red"][gamma,nil,rSIDECHAT,'Xray to HQ, the ammo caches have been destroyed, Xray out.'] call RE;[/color]

sleep 5;

[color="red"][[west,'HQ'],nil,rSIDECHAT,'Headquarters SideChat "Copy Xray, good job.'] call RE;[/color]

sleep 5;

[color="Red"][gamma,nil,rSIDECHAT,'Were on our way to HQ'] call RE;[/color]

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  

×