Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2008-07-23 16:42        
     
Hi guys
I have been trying to put the following script into my missions so that all units when killed respawn with the same weapons they had before dying.

http://www.armaholic.com/page.php?id=1864

but i cant get it to work, and i dont understand this bit 'Should be called in the init.sqs/sqf' do i just put 'sqs/sqf' in the init line?

i put the 'save_gear.sqf' file into my mission folder then enter the editor and save it to multiplayer but it still doesnt work can anyone help me tyvm in advance :)


Author Message

Dead3yez  

I am evil


Posts: 3113
Rank:


Level: Member

Country: en
Location: North Yorkshire
Occupation: dead3yez
Age: 29
In-game name: dead3yez

 
#2 Posted at 2008-07-23 18:38        
     
http://www.armaholic.com/page.php?id=1537

take a look at that, just use that one. put the script into a notepad and save as init.sqs in your mission folder.


Advertisement


Author Message


Posts: 2
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2008-07-23 18:58        
     
cheers Dead it worked and sorry if it was a noob question but i have only just got into mission making


Author Message


Posts: 123
Rank:


Level: Member

Country: us
Location: Ga.
Occupation: Disabled
Age: 58
In-game name: SpectrumWarrior

 
#4 Posted at 2008-10-06 22:40        
     
Hi: I already have an init.sqf file and this http://www.armaholic.com/page.php?id=1537
page tells me this
Launch this little script from the init.sqs/sqf.
But no matter where I have added this to my init file it crashes my game to my desktop and says init.sqf error 7. So my question is, Where do I add this code
#start
@ (! alive player)
_weapons = weapons player
_magazines = magazines player

@ (alive player)
removeallweapons player

{player addMagazine _x} foreach _magazines
{player addWeapon _x} foreach _weapons
goto "start"
to my init.sqf to make it work?
This is what my init.sqf looks like
//if (isServer && isClass (configFile >> "CfgPatches" >> "ARMAAC")) then {[] execVM "\ARMAAC\ARMAAC.sqf";};
setterraingrid 50;
setViewDistance 1000;
//Statics
[] exec "Karr-SquadMarkers.sqs";
GUER = RESISTANCE;
CIV = CIVILIAN;
//if(debug) exitWith {};


rank1 = 0;
rank2 = 30;
rank3 = 60;
rank4 = 100;
rank5 = 150;
rank6 = 200;
onmission=false;
sobj1=false;
sobj2=false;
//Dynamics
inpar=false;
incha=false;
insom=false;
inarc=false;
incay=false;
intib=false;
inigu=false;
indol=false;
inort=false;
incor=false;
ineve=false;
inmod=false;
inobr=false;
inmer=false;
inbag=false;
inepo=false;
incab=false;
inmas=false;
inpit=false;
rndmis=0;
debug=false;
mismin=true;
opar=false;
ocha=false;
osom=false;
oarc=false;
ocay=false;
otib=false;
oigu=false;
odol=false;
oort=false;
ocor=false;
oeve=false;
omod=false;
oobr=false;
omer=false;
obag=false;
oepo=false;
ocab=false;
omas=false;
opit=false;
spawn2=false;
vdist=1000;
avdist=1000;
gdel=0;
gdate = [2007,7,4,Param2,59];
scores = [];
Playerlist = [];
spawned=0;
lives=500;
allvar_packed = "";
wcam=0;
wcame=0;
end=false;
sop=objNull;
sot=objNull;
sor=0;
fattack=false;
mpoint=objNull;
epoint=objNull;
mbase=objNull;
mtime=0;
cbase=abase1;
dunit="none";
runit=objNull;
rtype="SoldierWB";
tunit=objNull;
junit = objNull;
lunit = objNull;
lpoint = 0;
jgroup=grpNull;
mgroupa=grpNull;
mgroupb=grpNull;
mgroupc=grpNull;
mgroupd=grpNull;
lastalert="mobj1";
placetag = "";
pmis=0;
punit=objNull;
prew=0;
pscore = -1;
aunit=objNull;
arank="NULL";
rscripts=0;
vscripts=0;
pallammo = ["30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag","M136","M136","M136","M136"];
pweapons = ["M4SPR","M136","binocular","NVGoggles"];
"0" objstatus "Active";
"1" objstatus "Active";
"2" objstatus "Active";
"3" objstatus "Active";
"4" objstatus "Active";
"5" objstatus "Active";
"6" objstatus "Active";
"7" objstatus "Active";
"8" objstatus "Active";
"9" objstatus "Active";
"10" objstatus "Active";
"11" objstatus "Active";
"12" objstatus "Active";
"13" objstatus "Active";
"14" objstatus "Active";
"15" objstatus "Active";
"16" objstatus "Active";
"17" objstatus "Active";
"18" objstatus "Active";
"19" objstatus "Active";
"20" objstatus "Active";


setDate gdate;

if (local Server) then 
{
	EVO_aamarker = "scripts\vecrespawna.sqf";
	parso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = parso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	chaso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = chaso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	somso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = somso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	arcso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = arcso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	cayso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = cayso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	tibso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = tibso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	iguso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = iguso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	dolso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = dolso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	ortso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = ortso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	corso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = corso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	eveso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = eveso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	modso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = modso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	obrso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = obrso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	merso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = merso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	bagso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = bagso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	eposo1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = eposo1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	cabso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = cabso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	masso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = masso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	pitso1 addEventHandler ["killed", {(_this select 0) removealleventhandlers "killed";sop = (_this select 1);sot = pitso1;sor = 10;publicVariable 

"sop";publicVariable "sot";publicVariable "sor"}];
	onplayerconnected "[_name] exec ""scripts\update.sqf"";if(dunit == _name) then {dunit = ""none""}";
	onPlayerDisconnected "
	dunit = _name;
	_mark = format[""%1mash"",dunit];
	deleteMarker _mark;
	_mark = format[""%1farp"",dunit];
	deleteMarker _mark;
	";
};

if ((local server) and not (local player)) exitWith {}; 
_cevents = [] execVM "scripts\EventsC.sqf";
_nul=[] execVM "Dialogs\Common\CommonDialogFunctions.sqf";

if !(debug) then {KEGsShownSides = [west]};
[] execVM "spect\specta_init.sqf";

//Client


waitUntil {allvar_packed != ""};

_temp = compile allvar_packed;
_vars = call _temp;
end = _vars select 0;
opar = _vars select 1;
ocha = _vars select 2;
osom = _vars select 3;
oarc = _vars select 4;
ocay = _vars select 5;
otib = _vars select 6;
oigu = _vars select 7;
odol = _vars select 8;
oort = _vars select 9;
ocor = _vars select 10;
oeve = _vars select 11;
omod = _vars select 12;
oobr = _vars select 13;
omer = _vars select 14;
obag = _vars select 15;
oepo = _vars select 16;
ocab = _vars select 17;
omas = _vars select 18;
opit = _vars select 19;
rndmis = _vars select 20;
lives = _vars select 21;
if !(debug) then {titleCut ["","black faded", 0]};


This post was edited by SpectrumWarrior (2008-10-06 22:58, ago)


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 49
In-game name: Myke

 
#5 Posted at 2008-10-06 23:42        
     
Never ever add loops into a init.sqs/sqf. This is a big no-no!

However, make a new script for the save gear code. Give it a name (save_my_gear.sqs) and launch this from the init.sqf:
[] exec "save_my_gear.sqs";
You may put this at the very end of your init.sqf.


Author Message


Posts: 123
Rank:


Level: Member

Country: us
Location: Ga.
Occupation: Disabled
Age: 58
In-game name: SpectrumWarrior

 
#6 Posted at 2008-10-07 00:13        
     
Hi: Myke, I am still respawning with the MK12SPR I entered the game with and not the M107 I took from the ammobox. I just tried the Mykes little helper code also and it gave me and error about genneric error error genneric expression or something like that lol. OK I fixed the error part I realized I typed it wrong in the init file, But I still am respawning with the gear I started the game with not the weapon I died with on your little helper script also.

This post was edited by SpectrumWarrior (2008-10-07 03:37, ago)


Author Message

Myke  

Mc Script


Posts: 1034
Rank:


Level: Member

Country: ch
Location: St. Gallen
Occupation: Armaholic addon tester
Age: 49
In-game name: Myke

 
#7 Posted at 2008-10-07 13:37        
     
Hmm...try this. At the very beginning of the save gear script, add this line (as first line):
@! (isnull player)

Seems i have to rewrite this whole thing one day.


Author Message


Posts: 123
Rank:


Level: Member

Country: us
Location: Ga.
Occupation: Disabled
Age: 58
In-game name: SpectrumWarrior

 
#8 Posted at 2008-10-08 18:57        
     
Hi Myke: Nope still respawning with the gear you start the game with. I tried the line on your Mykes little helper and on the script I mentioned above.


Author Message

Duke  



Posts: 401
Rank:


Level: Member

Country: ca
Location: Under your bed.
Occupation: Avid Gamer, Loving Father.
Age: 51
In-game name:

 
#9 Posted at 2008-12-16 06:25        
     
Hi Myke,

I too am using this script for an MP Mission I'm currently making and it works extremely well. The only issue I have is that upon respawn, player will automatically switch to secondary weapon (handgun if equipped).

Regardless of what weapon config player is carrying, player always respawns with no fire mode selected and thus has to hit the F key to actually shoot or use optics.

Any idea how to force a firemode upon respawn?

Thanks.


Author Message

Xeno  



Posts: 23
Rank:


Level: Member

Country: de
Location:
Occupation:
Age:
In-game name:

 
#10 Posted at 2008-12-16 22:37        
     
Try the following script, I wrote it some time ago and I use it in all my MP missions. It fixes the F problem (specially with GL weapons).

You can start it for example from a trigger, condition: local player, on activation: handle = [] execVM "weaponspawn.sqf"

while {true} do {
    waitUntil {!alive player};
    _p = player;
    _weapons = weapons _p;
    _magazines = magazines _p;
    waitUntil {alive player};
    _p = player;
    removeAllWeapons _p;
    {_p addMagazine _x;} forEach _magazines;
    {_p addWeapon _x;} forEach _weapons;
    _primw = primaryWeapon _p;
    if (_primw != "") then {
        _p selectWeapon _primw;
        // Fix for weapons with grenade launcher
        _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
        _p selectWeapon (_muzzles select 0);
    };
};

Xeno


Author Message

Duke  



Posts: 401
Rank:


Level: Member

Country: ca
Location: Under your bed.
Occupation: Avid Gamer, Loving Father.
Age: 51
In-game name:

 
#11 Posted at 2008-12-16 23:38        
     
Thanks Xeno, I'll give it a go tonight and report back.


[edit]
Xeno : Try the following script, I wrote it some time ago and I use it in all my MP missions. It fixes the F problem (specially with GL weapons).

You can start it for example from a trigger, condition: local player, on activation: handle = [] execVM "weaponspawn.sqf"

while {true} do {
    waitUntil {!alive player};
    _p = player;
    _weapons = weapons _p;
    _magazines = magazines _p;
    waitUntil {alive player};
    _p = player;
    removeAllWeapons _p;
    {_p addMagazine _x;} forEach _magazines;
    {_p addWeapon _x;} forEach _weapons;
    _primw = primaryWeapon _p;
    if (_primw != "") then {
        _p selectWeapon _primw;
        // Fix for weapons with grenade launcher
        _muzzles = getArray(configFile>>"cfgWeapons" >> _primw >> "muzzles");
        _p selectWeapon (_muzzles select 0);
    };
};

Xeno

Well Xeno I haven't done a lot of testing with it so far but it's looking really good. I'll definitely be using it in the next build of the mission I'm working on and let my buds give more input once they've had a chance to test as well.

I've added this little snippet prior to the code to give you proper credit of course:

// ************************************************************ //
// Respawn with your last weapond loadout before dying //
// Script by Xeno //
// put in your init.sqs/.sqf file : [] execVM "weaponspawn.sqf" //
// ************************************************************ //

Thanks again for the code.


[modedit]
Please try not to double post, you can edit your post with the edit button top right of your last post ;) [/modedit]

This post was edited by Foxhound (2008-12-17 08:05, ago)


Author Message


Posts: 126
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#12 Posted at 2009-01-11 21:03        
     
None of these work for me :|