Jump to content
Sign in to follow this  
Kolmain

Flag capture?

Recommended Posts

Any idea how to allow players to take the flag down a flag pole and hang up the american flag? Ive seen it done in PVP like CTF but never figured out how they did it... :confused:

Share this post


Link to post
Share on other sites

i only know of a workaround for this,

1 * make a flagpole with wanted flagtype

2 * make a empty flagpole. set the position exatly ontop on the flagpole with flag

3 * a script that uses setpos in z axis to lower/raise the flag

Share this post


Link to post
Share on other sites

So how would i remove the flag from my back and also reverse it to hang the US flag?

Share this post


Link to post
Share on other sites

Ok,

something you must know first it that a flag is always attached to a flagpole where it is first created. A little example to create a flag then give it to a unit :

create an empty flagpole and name it "flagpole".

To give a flag to the flag pole :

FlagPole [url="http://community.bistudio.com/wiki/setflagtexture"]SetFlagTexture[/url] (name of the texture); (see flag textures names [url="http://community.bistudio.com/wiki/Flag_Textures"]here[/url])

To take the flag from the flag pole and give it to a unit (same effect as the TakeFlag action) :

FlagPole [url="http://community.bistudio.com/wiki/setFlagOwner"]setflagowner[/url] NameOfUnit;

To put the flag back to the flagpole (same as the ReturnFlag action) :

FlagPole [url="http://community.bistudio.com/wiki/setFlagOwner"]setflagowner[/url] ObjNull;

Edited by ProfTournesol

Share this post


Link to post
Share on other sites

So if takeFlag takes it down, what strings the flag back up?

Share this post


Link to post
Share on other sites

this is exactly why i dont like to use the ingame actions. i find them messy. besides i dont like having a flag on my back unless its like real ctf. where you have to go home with the captured flag.

to only lower/raise the flag to change the side i like the 2 poles + setpos methode best. in other words. 2 poles for each flag or sone.

in editor name:

poleWhite -> sone_1

poleEmpty -> sone_1_dummy

then use a set of script/function

1st init all flags to CIV "type/side". this should be run by init or some other methode upon gamestart.

altho rewriting the function to set spesific sone to a spesific faction isnt much hazzle.

// define how many flag/sones you got.
#define    sones [sone_1,sone_2,sone_3,sone_4,sone_5,sone_6,sone_7]
InitFlagPoles =
{
   _sones = sones;
   for "_i" from 0 to (count _sones - 1) do 
   {
       _sone = _sones select _i;
       _varname = format["%1",_sone];
       _sone setVariable [_varname,"CIV",true];
       _sone allowDamage false;

       _sone execvm "scripts\setflag.sqf";
       _dummypolePos = call compile format["%1_dummy setpos [getpos _sone select 0,getpos _sone select 1,getpos _sone select 2];%1_dummy allowDamage false;",_sone];
   };
};

the setflag script.

:

// three sides defined here.
#define Gfaction    "BIS_TK_GUE"
#define Efaction    "RU"
#define Wfaction    "BIS_US"

// to make it work in editor
if (isMultiplayer) then { if ((!isServer) || (!isDedicated)) exitwith {};};

_flagpole = _this;
_varname = format["%1",_flagpole];
sleep 3;
SetFlag = 
{
   _sone = _this select 0;
   _side = _this select 1;
   switch (_side) do
   {
       case "CIV" : {_sone setFlagTexture "\ca\ca_e\data\flag_white_co.paa";};
       case Wfaction : { _sone setFlagTexture "\ca\ca_e\data\flag_blufor_co.paa" ;};
       case Efaction : { _sone setFlagTexture "\ca\ca_e\data\flag_opfor_co.paa";};
       case Gfaction : { _sone setFlagTexture "\ca\ca_e\data\flag_indfor_co.paa" ;};
   };
};

while {true} do
{
   _flagowner = _flagpole getVariable _varname;
   _objects = nearestObjects [_flagpole, ["Man"], 5];
   _aobjects = [];
   {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
   _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
   _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
   _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;


   // lower the flag for us players
   if ((_westnum > _eastnum) && (_westnum > _guernum) && (_flagowner != Wfaction)) then
   {
       _fz = getposatl _flagpole select 2;
       while {((_westnum > _eastnum) && (_westnum > _guernum) && (_fz > -5))} do
       {
           _objects = nearestObjects [_flagpole, ["Man"], 5];
           _aobjects = [];
           {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
           _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
           _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
           _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;

           _fx = getposatl _flagpole select 0;
           _fy = getposatl _flagpole select 1;    
           _fz = getposatl _flagpole select 2;
           _fz = _fz - 0.01;
           _flagpole setposatl [_fx, _fy, _fz];
           sleep 0.01;
       };
       sleep 2;
       if (_fz <= -5) then 
       {
           [_flagpole,Wfaction] call SetFlag;
           _flagpole setVariable [format["%1",_flagpole],Wfaction,true];    
       };
   };
   // lower the flag for ru players
   if (( _eastnum > _westnum) && (_eastnum > _guernum) && (_flagowner != Efaction)) then
   {
       _fz = getposatl _flagpole select 2;
       while {((_eastnum > _westnum) && (_eastnum > _guernum) && (_fz > -5))} do
       {
           _objects = nearestObjects [_flagpole, ["Man"], 5];
           _aobjects = [];
           {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
           _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
           _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
           _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;

           _fx = getposatl _flagpole select 0;
           _fy = getposatl _flagpole select 1;    
           _fz = getposatl _flagpole select 2;
           _fz = _fz - 0.01;
           _flagpole setposatl [_fx, _fy, _fz];
           sleep 0.01;
       };
       sleep 2;
       if ((_fz <= -5)) then 
       {
           [_flagpole,Efaction] call SetFlag;
           _flagpole setVariable [format["%1",_flagpole],Efaction,true];    
       };
   };
   // lower the flag for gu players
   if ((_guernum > _westnum) && (_guernum > _eastnum) && (_flagowner != Gfaction)) then
   {
       _fz = getposatl _flagpole select 2;
       while {((_guernum > _westnum) && (_guernum > _eastnum) && (_fz > -5))} do
       {
           _objects = nearestObjects [_flagpole, ["Man"], 5];
           _aobjects = [];
           {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
           _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
           _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
           _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;

           _fx = getposatl _flagpole select 0;
           _fy = getposatl _flagpole select 1;    
           _fz = getposatl _flagpole select 2;
           _fz = _fz - 0.01;
           _flagpole setposatl [_fx, _fy, _fz];
           sleep 0.01;
       };
       sleep 2;
       if ((_fz <= -5)) then 
       {
           [_flagpole,Gfaction] call SetFlag;
           _flagpole setVariable [format["%1",_flagpole],Gfaction,true];    
       };
   };
   //rais the flag for  us
   if ((_westnum > _eastnum) && (_westnum > _guernum) && (_flagowner == Wfaction) && (getpos _flagpole select 2 < 0)) then
   {
       _fz = getposatl _flagpole select 2;
       while {((_westnum > _guernum) && (_westnum > _eastnum) && (_fz < 0))} do
       {
           _objects = nearestObjects [_flagpole, ["Man","Car","Tank"], 5];
           _aobjects = [];
           {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
           _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
           _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
           _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;
           _fx = getposatl _flagpole select 0;
           _fy = getposatl _flagpole select 1;    
           _fz = getposatl _flagpole select 2;
           _fz = _fz + 0.01;
           _flagpole setposatl [_fx, _fy, _fz];
           sleep 0.01;

       };    
   };
   //rais the flag for ru
   if ((_eastnum > _westnum) && (_eastnum > _guernum) && (_flagowner == Efaction) && (getpos _flagpole select 2 < 0)) then
   {
       _fz = getposatl _flagpole select 2;
       while {((_eastnum > _westnum) && (_eastnum > _guernum) && (_fz < 0))} do
       {
           _objects = nearestObjects [_flagpole, ["Man","Car","Tank"], 5];
           _aobjects = [];
           {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
           _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
           _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
           _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;
           _fx = getposatl _flagpole select 0;
           _fy = getposatl _flagpole select 1;    
           _fz = getposatl _flagpole select 2;
           _fz = _fz + 0.01;
           _flagpole setposatl [_fx, _fy, _fz];
           sleep 0.01;

       };    
   };
   //rais the flag guer
   if ((_guernum > _westnum) && (_guernum > _eastnum) && (_flagowner == Gfaction) && (getpos _flagpole select 2 < 0)) then
   {
       _fz = getposatl _flagpole select 2;
       while {((_guernum > _westnum) && (_guernum > _eastnum) && (_fz < 0))} do
       {
           _objects = nearestObjects [_flagpole, ["Man","Car","Tank"], 5];
           _aobjects = [];
           {(if alive _x) then {_aobjects = _aobjects + [_x];};} foreach _objects;
           _westnum = 0; { if (faction _x == Wfaction) then {_westnum = _westnum + 1;};} foreach _aobjects;
           _eastnum = 0; { if (faction _x == Efaction) then {_eastnum = _eastnum + 1;};} foreach _aobjects;
           _guernum = 0; { if (faction _x == Gfaction) then {_guernum = _guernum + 1;};} foreach _aobjects;
           _fx = getposatl _flagpole select 0;
           _fy = getposatl _flagpole select 1;    
           _fz = getposatl _flagpole select 2;
           _fz = _fz + 0.01;
           _flagpole setposatl [_fx, _fy, _fz];
           sleep 0.01;
       };    
   };
   sleep 1;
};

this script may seams a bit messy but it has worked for me.

whith this script you have to be within 5 meters of the flag pole to lower current flag then raise your own flag.

Edited by nuxil

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  

×