Jump to content
Sign in to follow this  
exall

Need help with some kind of mobile respawn

Recommended Posts

Hello everyone ))

I think I'm in the dead-end with my scripting knowledge. The idea is that a group leader can make a camp, and if the camp exist other group members can respawn there or at the base at choice. Then, if the camp respawn point need to be moved, group leader should go to it and pick up/dismantle the camp. The spawn point is a marker which follows the camp

So I made some scripts for it. But they don't work of course or I won't be here )))

camp.sqf (the main script)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

CampCA = p1 addAction ["Make Camp","campcreate.sqf"];

if (alive Camp) then {

p1 removeAction _CampCA;

_Trg = createTrigger ["EmptyDetector", position Camp];

_Trg setTriggerArea [2, 2, 0, False];

_Trg setTriggerActivation ["NONE", "PRESENT", true];

_Trg setTriggerStatements ["this", "ok = true", "ok = False"];

_camppos = position Camp;

_p1pos = position p1;

if (_p1pos==_camppos) then {

CampDA = p1 addAction ["Remove Camp","campremove.sqf"];

};

}

else {

deleteVehicle _Trg;

p1 removeAction CampDA;

p1 addAction CampCA;

};

campcreate.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Camp="ACamp" createVehicle position p1;

campremove.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">deleteVehicle Camp;

campspawn.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#start

"Respawn_Camp" setMarkerPos getpos Camp

~5

goto "start";

What i've achieved for now: player make camp and make and make.. the action keeps accesible. And there's no "Remove Camp" at all.

As I can see the whole that scripting is wrong

Share this post


Link to post
Share on other sites

My suggestion:

add the action to the leader (p1) on init:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">CampCA = p1 addAction ["Make Camp","campcreate.sqf"];

then, on the script that creates the camp add the action to remove it and remove the old one (the action, I mean):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Camp="ACamp" createVehicle position p1;

CampDA = p1 addAction ["Remove Camp","campremove.sqf"];

p1 removeAction CampCA;

And on the script that removes the camp add again the action to create it:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">deleteVehicle Camp;

CampCA = p1 addAction ["Make Camp","campcreate.sqf"];

p1 removeAction CampDA;

now the script that checks the position of the marker should be:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#start

?(!isNull Camp): "Respawn_Camp" setMarkerPos getpos Camp else "Respawn_Camp" setMarkerPos markerPos "respawn_west"

~5

goto "start";

so this way you avoid the marker to appear on the corner of the map (pos [0,0,0,]). Now the only thing you have to do is for example to add an action somewhere in base to teleport to that position, and it'll do the trick. Of course you can also create and delete that marker on the scripts, so if camp is not created it doesn't appear on map, but that's up to you.

hope this helps

Share this post


Link to post
Share on other sites

Thanks a lot, YO!!

I'll definately try it out. I believe that it will be much better ))

Just one thing that I didn't tell in topic is that I want to add the action "Remove Camp" only when the player is near the camp. What do you think?? Will the script about trigger in camp.sqf work?? I think that

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _camppos = position Camp;

_p1pos = position p1;

if (_p1pos==_camppos) then

is not what will work but I can't imagine smth else with it

Share this post


Link to post
Share on other sites

Thanks again!!

All is working like machine. I've just changed your campspawn.sqs a little:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#start

if (!isNull Camp) then {"Respawn_Camp" setMarkerPos getPos Camp} else {"Respawn_Camp" setMarkerPos markerPos "Respawn_Start"}

~5

goto "start"

There was an error (I don't know why) with "?:". I've just tried and now it works.

All that I need now is "remove camp" activation only in near of a camp

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(p1 distance Camp) <= 20should be enought

Share this post


Link to post
Share on other sites

And where I should implement it?? I tried it in campcreate.sqf with "if-then" construction but it doesn't work:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">Camp="ACamp" createVehicle p1;

p1 removeAction CampCA;

if ((p1 distance Camp) <= 5) then {

CampDA = p1 addAction ["Remove Camp","campremove.sqf"];

} else {

p1 removeAction CampDA;

};

I'm not convinced in the syntax of condition

Share this post


Link to post
Share on other sites

I've got it at last!! Thank you very much, YO!! I've just got little help from flashpoint.ru, so I've mixed your help and his help, so here what we've got (3 scripts):

campcreate.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_pos = [(getpos p1 select 0)+5*(sin getDir p1),(getpos p1 select 1)+5*(cos getDir p1),0];

Camp="ACamp" createVehicle _pos;

p1 removeAction _makeCamp;

campremove.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

if ((_this select 1 != p1)) exitWith {};

deleteVehicle Camp;

p1 removeAction _remCamp;

_makeCamp = p1 addAction ["Make Camp","campcreate.sqf"];

campspawn.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_action=false

#start

if (!isNull Camp) then {"Respawn_Camp" setMarkerPos getPos Camp} else {"Respawn_Camp" setMarkerPos markerPos "Respawn_Start"}

?(p1 Distance getMarkerPos "Respawn_Camp") < 5 && !(_action) :_remCamp = p1 addAction ["Remove Camp","campremove.sqf"];_action = true

?(p1 Distance getMarkerPos "Respawn_Camp") > 5 && _action :p1 removeAction _remCamp;_action = false

~2

goto "start"

Notice that all actions not in "_this select" construction (in version from flashpoint.ru the were) and are named so it will be useful with "respawn with actions" scripts.

Maybe it will help other guys like me which are new to scripting. Thanks again, YO!!!!

Share this post


Link to post
Share on other sites

Unfortunately, now I face problem with using it in mp..

First, the actions are dublicated in actions menu when I use them sometimes. Besides, if they are dublicted they keep staying in action menu, so the "remove camp" work everywhere.

Second, I can't save actions for this player after respawn. I serfed for two days around arma forums and didn't get normal script for this.

So I'm trying to use smth like this:

actionspawn.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0;

_actionname = _this select 1;

_actionscript = _this select 2;

If (!isplayer _unit) exitwith {};

_nul = player addaction [_actionname, _actionscript];

while {true} do {

if (!alive player) then {

waituntil {

alive player;

sleep 1;

};

_nul = player addaction [_actionname, _actionscript];

};

};

As for this actionspawn it works normally for other players with actions (in my role-based mission the radio operator has 2 actions - artillery and air control, and they are spawning with him). But I don't have idea why it doesn't work with this player.

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  

×