Jump to content
Sign in to follow this  
bigshotking

Creating Tasks through script in MP

Recommended Posts

Ok I'm having some issues with this script I made, the part of the script I'm having a problem with is creating a task.

To be more precise, the task shows up for me (the host), but anyone else that is connected, they don't see it at all.

this is the code I'm using;

tsk1 = player createSimpleTask ["Destroy"];
tsk1 setSimpleTaskDescription ["Destroy the AA Gun!", "Destroy", "Destroy"];
tsk1 setSimpleTaskDestination (getMarkerPos "bmp_2");
taskhint ["New Objective...\nDestroy AA Gun", [1, 1, 1, 1], "taskNew"];

I had heard before that maybe the "player" part in the script could be causing a error.

I also have this at the top of the script:

if (!isServer) exitWith {};

Thanks in advance for the help.

-Bigshot

P.S. I'm also curious on how to create a gamelogic with a custom init in the script as well.

Share this post


Link to post
Share on other sites

How is the part where "player" is assigned the task executed? In init, trigger, what? "player" is not your issue here. The !isServer may be your problem though. Biki says -

You can use isServer inside the condition of a trigger to have the trigger activate only for the server. All other conditions for the trigger will be checked across all machines, but it will only activate the trigger created on the server.

Try it without.

Share this post


Link to post
Share on other sites
P.S. I'm also curious on how to create a gamelogic with a custom init in the script as well.

createUnit array, setVehicleInit, processInitCommands

make sure that you use ""double"" or 'single' inside the outer "quotes" in setVehicleInit.

_gamelogic = createUnit........................blah....;
_gamelogic setVehicleInit "_null = this execVM [b]'somescript.sqf'[/b]";
processInitCommands;

Share this post


Link to post
Share on other sites

The task is created for just 1 player, so i guess your script needs to run on every connected client as well, but since you added

if (!isServer) exitWith {};

on top the script runs only on a local server.

It also won't run on a dedicated server since there's no player on that.

I'm no MP scripting expert though.

Share this post


Link to post
Share on other sites

So how can I make it work on all machines?

EDIT: I think I got it, i just moved the if (!isServer) exitWith {}; under the task create lines and it seems to have worked.

Edited by bigshotking

Share this post


Link to post
Share on other sites

You only make use of isServer, when you want something to run on the server only. If you are the host you are the server, but all other clients/players will exit the script on that line.

You should also add this line to the top of your init.sqf:

waitUntil {(isDedicated) || !(isNull player)};

Without it, players sometimes skip the init.sqf completely.

Share this post


Link to post
Share on other sites

Oh one more question.

Do I need to delete the triggers I created through the script? Or will it automatically be deleted when the trigger is fired?

Thanks in advance

-Bigshot

Share this post


Link to post
Share on other sites

And yes, you should delete them, if they should only fire once - Not for JIP that is.

Or set the condition back to false. But deleting them is just fine.

Share this post


Link to post
Share on other sites

Can I do the same with Task as well?

Like this?

deletevehicle _tsk;

Thanks for any feedback

-Bigshot

Share this post


Link to post
Share on other sites

Well, usually you'd use:

_tskWhatever setTaskState "Canceled";

So canceling rather than deleting a task. To remove one, just:

player removeSimpleTask _tskwhatever;

Share this post


Link to post
Share on other sites

Well this mission is going to have many objectives so I do not believe there will be room in the tasks list.

thanks for the code Kylania

-bigshot

Share this post


Link to post
Share on other sites

_gamelogic = createUnit........................blah....;
_gamelogic setVehicleInit "_null = this execVM 'somescript.sqf'";
processInitCommands;

The above code I'm a little confused about,

I want to create a gamelogic on a empty marker already placed on the map.

Any ideas?

-Bigshot

Share this post


Link to post
Share on other sites

look at the link i posted aswell, change classname for your gamelogic, and make it in a group sidelogic.

all info is in the links.

place this in any object to get its classname.

copyToClipBoard format["%1",(typeOf this)];

Share this post


Link to post
Share on other sites

Thanks for the help Demonized, I've given up on trying to spawn the gamelogic... I'm completely lost on it, right now I've decided to put one down on the map, but I only want it's condition of presence to be true when a script is called on.

Any ideas?

-Bigshot

Share this post


Link to post
Share on other sites

Thanks for the help, I'll try and find a way to make a trigger activate properly in the script.

-Bigshot

---------- Post added at 12:17 AM ---------- Previous post was Yesterday at 11:50 PM ----------

Ok I'm still having issue with this...

This is my Gamelogic:

Name:

c1

Init:

null = [this,EAST,["wp1","wp2","wp3"],false,0,7,["LandRover_MG_TK_EP1","UralRepair_TK_EP1","UralRefuel_TK_EP1","UralReammo_TK_EP1","LandRover_MG_TK_EP1"],[],true,false] execvm "scripts\convoy.sqf";

Condition of Presence:

triggerActivated convoy1;

This is the part of the script that is creating a trigger on a empty marker already on the map:

_trg3 = createTrigger["EmptyDetector", getMarkerPos "m3_3"];
_trg3 setTriggerArea[0,0,0,false];
_trg3 setTriggerActivation["NONE","PRESENT",false];
_trg3 setTriggerStatements["alive player","",""];
_VarName = "convoy1";
_trg3 SetVehicleVarName _VarName;

What's the issue I'm having?

-Bigshot

Share this post


Link to post
Share on other sites

just incase here is how to script create a gamelogic when there is no logics in mission.

thats why we use createcenter, if you already have a logic in mission you dont need createCenter line.

_center = createCenter sideLogic;
_glGrp = createGroup sideLogic;
_gamelogic = _glGrp createUnit ["Logic", [0,0,0], [], 0, "NONE"];
_gamelogic setVehicleInit "myGl1 = this;";
processInitCommands;

here gamelogic is created at position [0,0,0] wich is lower left of map, its named myGl1 in its init and you can verify it by having a radio trigger and teleport player to getpos myGl1.

Share this post


Link to post
Share on other sites

Well the gamelogic is being used to spawn a Enemg convoy at the gamelogics position. So I need it it in a specific place, is there a way can spawn the Gamelogic on a empty marker on the map I.e. Mrkr1

How can I change it, or is it not possible?

Thanks for the example though,

-Bigshot

Share this post


Link to post
Share on other sites

If there's already a marker there why would you need a gamelogic? You already know that location via

getMarkerPos "Mrk1"

Share this post


Link to post
Share on other sites

Well the script says to use a gamelogic, but then again I have used other scripts that ask that and yet i've used Markers.....

Dugh..... I'm an idiot thanks for reminding me Kylania. :o

Oh and Demonized thanks for the help you've given me as well, you may never know when I might need that, thanks!

-Bigshot

---------- Post added at 10:46 PM ---------- Previous post was at 10:17 PM ----------

Ok it's still not working....

In the script, I have the following code placed:

null = [getMarkerPos "m3_3", EAST, ["wp1", "wp2", "wp3"], false, 0, 7, ["LandRover_MG_TK_EP1", "UralRepair_TK_EP1", "UralRefuel_TK_EP1", "UralReammo_TK_EP1", "LandRover_MG_TK_EP1"], [], true, false] 
execvm "scripts\convoy.sqf";

That is the code I'm using to spawn the convoy... I don't see an issue with it at all, I put that code in the Gamelogic, but changed the "getMarkerPos" with "this", and it worked flawlessly.

I don't know whats wrong....

Any Ideas?

-Bigshot

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  

×