Jump to content
Sign in to follow this  
J. Schmidt

Ranked Weapons Crate not creating Correct Weapons

Recommended Posts

I've been working on this for about 6 hrs now and it's not creating the correct weapons for any of the ranks. Instead it just spawns a crate which has the default load-out, I've searched on Google for hours, the only thing that I wasn't able to find is how to correctly create the ranking system. Here are my scripts that I'm using.

Init.sqf:

// Begin init.sqf

// Add Mission Scripts
[]execVM "briefing.sqf";
[]execVM "scr\triggers.sqf";
[]execVM "scr\rank_sys\rank_system.sqf";

enableTeamSwitch true;

waitUntil{!(isNil "BIS_fnc_init")};

[str ("Revolution v0.1") , str ("Takistan, 2012") , str ("10:00:00hrs")] spawn BIS_fnc_infoText;

if(true) exitWith {};

Rank_System.sqf:

while {(local player)} do {	

if (score player >= 125 AND rankid player == 5) then {
	Player setRank "Colonel";
	hint format ["You have been promoted to %1",rank Player];
};

if (score player >= 100 AND rankid player == 4) then {
	Player setRank "Major";
	hint format ["You have been promoted to %1",rank Player];
};

if (score player >= 75 AND rankid player == 3) then {
	Player setRank "Captain";
	hint format ["You have been promoted to %1",rank Player];
};

if (score player >= 50 AND rankid player == 2) then {
	Player setRank "Lieutenant";
	hint format ["You have been promoted to %1",rank Player];
};

if (score player >= 25 AND rankid player == 1) then {
	Player setRank "Sergeant";
	hint format ["You have been promoted to %1",rank Player];
};

if (score player >= 5 AND rankid player == 0) then {
	Player setRank "Corporal";
	hint format ["You have been promoted to %1",rank Player];
};

sleep 60;
};

Jip.sqf:

private ["_cr01"];
_cr01 = "USBasicWeapons_EP1" createvehiclelocal (getMarkerPos "ammo1");
_cr01 allowdamage false;
nul = [_cr01] execVM "scr\rank_sys\ammo.sqf";

Ammo.sqf:

private ["_unit", "_ammostuff", "_playrank", "_privweapons", "_corpweapons", "_sgtweapons", "_ltnweapons", "_captweapons", "_majweapons", "_colweapons"];
_unit = _this select 0;
_ammostuff = _this select 1;
_playrank = rank player;

_privweapons =
[
	"ACE_M16A4_Iron", "ACE_M16A4_GL_UP", "M4A1","ACE_M4A1_GL_UP", "M249_EP1", "M9", "M136"
];

_corpweapons = 
[
	"M16A4", "ACE_M16A4_CCO_GL_UP", "ACE_M4_Aim", "ACE_M4_AIM_GL_UP", "ACE_M249_AIM", "ACE_Mk12mod1", "ACE_Javelin_CLU", "Javelin" 
];

_sgtweapons = 
[
	"ACE_M16A4_EOT", "ACE_M16A4_EOT_GL_UP", "ACE_M4_Eotech", "ACE_M4_Eotech_GL_UP", "M249_m145_EP1", "M24" 	
];


_ltnweapons = 
[
	"M16A4_ACG", "ACE_M16A4_ACG_GL_UP", "ACE_M4_RCO_GL_UP", "ACE_M4A1_ACOG", "ACE_M249_PIP_ACOG", "Stinger"
];

_captweapons = 
[
	"ACE_SOC_M4A1", "ACE_SOC_M4A1_GL", "ACE_SOC_M4A1_Aim", "ACE_SOC_M4A1_GL_AIMPOINT", "m107"
];

_majweapons = 
[
	"ACE_SOC_M4A1_Eotech", "ACE_SOC_M4A1_GL_EOTECH", "ACE_SOC_M4A1_Eotech_4x", "ACE_SOC_M4A1_RCO_GL", "ACE_SOC_M4A1_SHORTDOT"
];

_colweapons = 
[
	 "ACE_M4A1_Aim_SD", "ACE_M4A1_EOT_SD", "ACE_M4A1_ACOG_SD", "M249_TWS_EP1", "ACE_SOC_M4A1_TWS", "M9SD", "ACE_M109"
];	

while {alive _ammostuff} do 
{    

if (_playrank == "PRIVATE") then 
	{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
};

if (_playrank == "CORPORAL") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
};

if (_playrank == "SERGEANT") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
};

if (_playrank == "LIEUTENANT")then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
};

if (_playrank == "CAPTAIN") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
};

if (_playrank == "MAJOR") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _majweapons;
};

if (_playrank == "COLONEL") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _majweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _colweapons;
};
sleep 20; 
}; // Linked to While do

Triggers.sqf

private ["_trg1","_trg2","_trg3"];

_trg1 = createTrigger ["EmptyDetector", getPos player];
_trg1 setTriggerArea [5, 5, 0, false];
_trg1 setTriggerActivation ["WEST", "PRESENT", true];
_trg1 setTriggerStatements ["local player", "nul = [] execVM ""scr\rank_sys\jip.sqf""", ""];

_trg2 = createTrigger ["EmptyDetector", getPos player];
_trg2 setTriggerArea [0, 0, 0, false];
_trg2 setTriggerActivation ["WEST", "PRESENT", true];
_trg2 setTriggerStatements ["this", "nul = [""mrkr_1""] execVM ""scr\missions\mission1.sqf""", ""];

_trg3 = createTrigger ["EmptyDetector", getMarkerPos "mrkr_2"];
_trg3 setTriggerArea [0, 0, 0, false];
_trg3 setTriggerActivation ["WEST", "PRESENT", true];
_trg3 setTriggerStatements ["player distance mrkr_2<= 300", "nul = [""mrkr_2""] execVM ""scr\missions\mission2.sqf""", ""];

Did I forget something? Do I have it sat up incorrectly? Any help will be greatly appreciated.

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

Are you sure it doesn't break at some point? If you have an error, such as a missing semi-colon, then the script won't execute properly or at all. That would explain why the weapon cargo isn't even cleared? Try adding random hint commands to debug it, if they stop at some point, then your problem is between that hint and the next one that should've executed?

[str ("Revolution v0.1") , str ("Takistan, 2012") , str ("10:00:00hrs")] spawn BIS_fnc_infoText;
if(true) exitWith {};

You are turning strings into strings in init. str() is meant to convert different types, such as numbers or booleans into strings?

Also the last line isn't required in sqf files.

I also believe you want to use the rating command, which increases with kills? Or perhaps both, if you have tasks which add to the player's score specifically.

Also I'd place these in brackets like so:

if ((score player >= 125) AND (rankid player == 5)) then
{
       Player setRank "Colonel";
       hint format ["You have been promoted to %1",rank Player];
};

In Ammo.sqf the player's rank never refreshes. It needs to refresh inside the loop or else it's always the same.

Lots of problems, I'm afraid. Start with those.

Continued

One error and one suggestion:

If you haven't already specified that the variable "mrkr_2" is actually a position then you have an error there as well. It should be as follows.

Also you should have, at least, trigger activation fields well specified with brackets. They often read what you're writing incorrectly. And, not a problem per se, but a readability question, you can use apostrophes inside your quotation marks.

_trg3 setTriggerStatements ["((player distance (getMarkerPos 'mrkr_2')) <= 300)", "nul = ['mrkr_2'] execVM 'scr\missions\mission2.sqf'", ""];  

Edited by Weirdo10o4

Share this post


Link to post
Share on other sites

@Iceman77 I'll post my rpt in a couple of minuets I have to find it.

---------- Post added at 01:19 PM ---------- Previous post was at 01:10 PM ----------

Here's my ArmA 2 OA rpt file.

ArmA2OA.rpt:


=====================================================================
== c:\program files (x86)\steam\steamapps\common\arma 2 operation arrowhead\expansion\beta\arma2oa.exe
== "c:\program files (x86)\steam\steamapps\common\arma 2 operation arrowhead\expansion\beta\arma2oa.exe"  -showscripterrors "-cpucount=4" "-name=JSF 82nd Reaper" "-mod=C:\Program Files (x86)\Steam\SteamApps\Common\ArmA 2;expansion;expansion\beta;expansion\beta\expansion;@CBA_A2;@CBA_OA;@CBA;@ACE;BAF;ACR;@ACEX;@ACEX_USNavy;@ACEX_SM;PMC;@ACEX_RU;@JayArma2Lib;@ACRE"
=====================================================================
Exe timestamp: 2012/12/20 02:43:59
Current time:  2012/12/21 13:05:26

Version 1.62.100257
Error: Audio - enumeration output devices failed.
Warning: Audio device creation failed, attempt to create default audio:
SamplesPerSec: 44100, channels: 2, bitsPerSample: 16
Audio device successfully created with default settings.
Warning: looped for animation: ca\anims\characters\data\anim\sdr\mov\erc\wlk\non\non\amovpercmwlksnonwnondf.rtm differs (looped now 0)! MoveName: amovpercmstpsnonwnondnon_amovpercmstpsraswpstdnon
Warning: looped for animation: ca\anims\characters\data\anim\sdr\mov\erc\wlk\non\non\amovpercmwlksnonwnondf.rtm differs (looped now 1)! MoveName: amovpercmrunsnonwbindf_rfl
[1386,85.663,0,"XEH: PreInit Started. v1.0.0.189. MISSINIT: missionName=intro, worldName=Bootcamp_ACR, isMultiplayer=false, isServer=true, isDedicated=false"]
[1386,98.686,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_disable_cache.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
[1386,96.79,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[1389,106.253,0.133,"XEH: PostInit Started"]
[1389,106.662,0.133,"CBA_VERSIONING: cba=1.0.0.190, cba_a2=1.0.0.8, cba_oa=1.0.0.6, ace=1.14.0.588, acex=1.14.0.370, acex_ru=1.14.0.76, acex_usnavy=1.14.0.77, "]
[1389,108.106,0.133,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=true, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=1, _sessionId=1, _level=0, _timeOut=false, _game=1, BIS_functions=L 1-1-A:1, group=L 1-1-A, player=<NULL-object>, _playerType="", _playerGroup=<NULL-group>"]
"JayArmA2Lib: ACTIVE"
[7350,152.359,0,"XEH: PreInit Started. v1.0.0.189. MISSINIT: missionName=revolution_v0%2e1, worldName=Takistan, isMultiplayer=false, isServer=true, isDedicated=false"]
[7350,153.262,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_disable_cache.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
Strange convex component01 in x\ace\addons\sys_ruck\backpack_data\ace_backpack_small_baf.p3d:geometryView
"JayArmA2Lib: ACTIVE"
[7350,153.223,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[8889,166.081,0,"XEH: PostInit Started"]
[8889,166.139,0,"CBA_VERSIONING: cba=1.0.0.190, cba_a2=1.0.0.8, cba_oa=1.0.0.6, ace=1.14.0.588, acex=1.14.0.370, acex_ru=1.14.0.76, acex_usnavy=1.14.0.77, "]
[8889,166.322,0,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=true, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=1, _sessionId=2, _level=0, _timeOut=false, _game=1, BIS_functions=L 1-1-A:1, group=L 1-1-A, player=B 1-1-A:1 (JSF 82nd Reaper), _playerType="US_Soldier_EP1", _playerGroup=B 1-1-A"]
[10517,212.507,0,"XEH: PreInit Started. v1.0.0.189. MISSINIT: missionName=intro, worldName=takistan, isMultiplayer=false, isServer=true, isDedicated=false"]
[10517,213.405,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_disable_cache.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
"JayArmA2Lib: ACTIVE"
[10517,213.365,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[10519,220.128,0,"XEH: PostInit Started"]
[10519,220.187,0,"CBA_VERSIONING: cba=1.0.0.190, cba_a2=1.0.0.8, cba_oa=1.0.0.6, ace=1.14.0.588, acex=1.14.0.370, acex_ru=1.14.0.76, acex_usnavy=1.14.0.77, "]
[10519,220.363,0,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=true, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=1, _sessionId=3, _level=0, _timeOut=false, _game=1, BIS_functions=L 1-1-A:2, group=L 1-1-A, player=<NULL-object>, _playerType="", _playerGroup=<NULL-group>"]
ca\missions\MPScenarios\MP_Deathmatch.chernarus: string @str_mpdeathmatch_subname cannot be localized client-side - move to global stringtable
"############################# Start intro #############################"
Mission revolution_v0%2e1.Takistan: Number of roles (1) is different from 'description.ext::Header::maxPlayer' (32)
[11086,261.881,0,"XEH: PreInit Started. v1.0.0.189. MISSINIT: missionName=revolution_v0%2e1, worldName=Takistan, isMultiplayer=true, isServer=true, isDedicated=false"]
[11086,272.269,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_disable_cache.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
"JayArmA2Lib: ACTIVE"
[11086,270.764,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[11088,273.187,0,"XEH: PostInit Started"]
[11088,273.267,0,"CBA_VERSIONING: cba=1.0.0.190, cba_a2=1.0.0.8, cba_oa=1.0.0.6, ace=1.14.0.588, acex=1.14.0.370, acex_ru=1.14.0.76, acex_usnavy=1.14.0.77, "]
[11088,274.22,0,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=false, _startInitDone=true, _postInitDone=true, _mpRespawn=true, _machineType=1, _sessionId=4, _level=0, _timeOut=false, _game=1, BIS_functions=L 1-1-A:1, group=L 1-1-A, player=B 1-1-A:1 (JSF 82nd Reaper), _playerType="US_Soldier_EP1", _playerGroup=B 1-1-A"]
Ref to nonnetwork object 2bc26b00# 438941: empty.p3d
Ref to nonnetwork object 2c6c8800# 438971: usbasicweapons.p3d
Ref to nonnetwork object 2c6c8800# 438971: usbasicweapons.p3d
Mission revolution_v0%2e1.Takistan: Number of roles (1) is different from 'description.ext::Header::maxPlayer' (32)
[12566,325.92,0,"XEH: PreInit Started. v1.0.0.189. MISSINIT: missionName=intro, worldName=takistan, isMultiplayer=false, isServer=true, isDedicated=false"]
[12566,326.827,0,"XEH: PreInit Finished. CACHE DISABLED? (Disable caching with cba_disable_cache.pbo): SLX_XEH_RECOMPILE=false, CBA_COMPILE_RECOMPILE=false, CBA_FUNC_RECOMPILE=false"]
"JayArmA2Lib: ACTIVE"
[12566,326.787,0,"x\ace\addons\sys_wounds\XEH_preInit.sqf:8","WARNING: Enhanced Armor difficulty options enabled - this is not recommended in conjunction with ACE Wounds!"]
[12568,328.93,0.028,"XEH: PostInit Started"]
[12568,328.997,0.028,"CBA_VERSIONING: cba=1.0.0.190, cba_a2=1.0.0.8, cba_oa=1.0.0.6, ace=1.14.0.588, acex=1.14.0.370, acex_ru=1.14.0.76, acex_usnavy=1.14.0.77, "]
[12568,329.157,0.028,"XEH: PostInit Finished. State: _isClient=true, _isJip=false, _isDedClient=false, _isServer=true, _isDedServer=false, _playerCheckDone=true, _sp=true, _startInitDone=true, _postInitDone=true, _mpRespawn=false, _machineType=1, _sessionId=5, _level=0, _timeOut=false, _game=1, BIS_functions=L 1-1-A:2, group=L 1-1-A, player=<NULL-object>, _playerType="", _playerGroup=<NULL-group>"]

---------- Post added at 01:38 PM ---------- Previous post was at 01:19 PM ----------

@Weirdo10o4 I just went through and replaced the things you suggested, and used your suggestions for the rest of the scripts. I haven't tested it out yet, but I do have one question; How would I get the players rank to refresh? I know it's to do with looping but I don't know how to do that, and how would I incorporate the rating system in the script as well?

Share this post


Link to post
Share on other sites

@Weirdo10o4 I tested the mission after changing everything you asked me to change, and even then some, and still no luck. If need be I can upload the mission and have it in a link for you to check.

I still haven't figured out how to incorporate the rating system or the loop for the players rank within the ammo.sqf yet. I've done a little bit of the "hint" statements and so far so good. For the Rank_System.sqf as far as I know it's working, for when I get 5 kills or more I then am promoted to Corporal. I also have some questions with the other scripts I'm using in the mission, but I'll wait until this is fixed before I move on. Here are the updated scripts...

Trigger.sqf

private ["_trg1","_trg2","_trg3", "mrkr_1", "mrkr_2"];

_trg1 = createTrigger ["EmptyDetector", getPos player];
_trg1 setTriggerArea [5, 5, 0, false];
_trg1 setTriggerActivation ["WEST", "PRESENT", true];
_trg1 setTriggerStatements ["local player", "nul = [] execVM 'scr\rank_sys\jip.sqf'", ""];

_trg2 = createTrigger ["EmptyDetector", getMarkerPos "mrkr_1"];
_trg2 setTriggerArea [0, 0, 0, false];
_trg2 setTriggerActivation ["WEST", "PRESENT", true];
_trg2 setTriggerStatements ["((player distance (getMarkerPos 'mrkr_1')) <= 200)", "nul = ['mrkr_1'] execVM 'scr\missions\mission1.sqf'", ""];

_trg3 = createTrigger ["EmptyDetector", getMarkerPos "mrkr_2"];
_trg3 setTriggerArea [0, 0, 0, false];
_trg3 setTriggerActivation ["WEST", "PRESENT", true];
_trg3 setTriggerStatements ["((player distance (getMarkerPos 'mrkr_2')) <= 200)", "nul = ['mrkr_2'] execVM 'scr\missions\mission2.sqf'", ""];

Rank_System.sqf

while {(local player)} do {	

if ((score player >= 125) AND (rankid player == 5)) then {
       Player setRank "Colonel";
       hint format ["You have been promoted to %1", rank Player];
};

if ((score player >= 100) AND (rankid player == 4)) then {
	Player setRank "Major";
	hint format ["You have been promoted to %1", rank Player];
};

if ((score player >= 75) AND (rankid player == 3)) then {
	Player setRank "Captain";
	hint format ["You have been promoted to %1", rank Player];
};

if ((score player >= 50) AND (rankid player == 2)) then {
	Player setRank "Lieutenant";
	hint format ["You have been promoted to %1", rank Player];
};

if ((score player >= 25) AND (rankid player == 1)) then {
	Player setRank "Sergeant";
	hint format ["You have been promoted to %1", rank Player];
};

if ((score player >= 5) AND (rankid player == 0)) then {
	Player setRank "Corporal";
	hint format ["You have been promoted to %1", rank Player];
};

sleep 60;
};

Jip.sqf

private ["_cr01"];
_cr01 = "USBasicWeapons_EP1" createvehiclelocal (getMarkerPos "ammo1");
_cr01 allowdamage false;
nul = [_cr01] execVM "scr\rank_sys\ammo.sqf";

Ammo.sqf

private ["_unit", "_ammostuff", "_playrank", "_privweapons", "_corpweapons", "_sgtweapons", "_ltnweapons", "_captweapons", "_majweapons", "_colweapons"];
_unit = _this select 0;
_ammostuff = _this select 1;
_playrank = rank player;

_privweapons =
[
	"ACE_M16A4_Iron", "ACE_M16A4_GL_UP", "M4A1","ACE_M4A1_GL_UP", "M249_EP1", "M9", "M136"
];
hint "Your rank determines what weapons you get.";
_corpweapons = 
[
	"M16A4", "ACE_M16A4_CCO_GL_UP", "ACE_M4_Aim", "ACE_M4_AIM_GL_UP", "ACE_M249_AIM", "ACE_Mk12mod1", "ACE_Javelin_CLU", "Javelin" 
];

_sgtweapons = 
[
	"ACE_M16A4_EOT", "ACE_M16A4_EOT_GL_UP", "ACE_M4_Eotech", "ACE_M4_Eotech_GL_UP", "M249_m145_EP1", "M24" 	
];


_ltnweapons = 
[
	"M16A4_ACG", "ACE_M16A4_ACG_GL_UP", "ACE_M4_RCO_GL_UP", "ACE_M4A1_ACOG", "ACE_M249_PIP_ACOG", "Stinger"
];

_captweapons = 
[
	"ACE_SOC_M4A1", "ACE_SOC_M4A1_GL", "ACE_SOC_M4A1_Aim", "ACE_SOC_M4A1_GL_AIMPOINT", "m107"
];

_majweapons = 
[
	"ACE_SOC_M4A1_Eotech", "ACE_SOC_M4A1_GL_EOTECH", "ACE_SOC_M4A1_Eotech_4x", "ACE_SOC_M4A1_RCO_GL", "ACE_SOC_M4A1_SHORTDOT"
];

_colweapons = 
[
	 "ACE_M4A1_Aim_SD", "ACE_M4A1_EOT_SD", "ACE_M4A1_ACOG_SD", "M249_TWS_EP1", "ACE_SOC_M4A1_TWS", "M9SD", "ACE_M109"
];	

while {alive _ammostuff} do 
{    

if (_playrank == "PRIVATE") then 
	{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
};

if (_playrank == "CORPORAL") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
};

if (_playrank == "SERGEANT") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
};

if (_playrank == "LIEUTENANT")then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
};

if (_playrank == "CAPTAIN") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
};

if (_playrank == "MAJOR") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _majweapons;
};

if (_playrank == "COLONEL") then
{
	clearMagazineCargoglobal _ammostuff;
	clearWeaponCargoglobal _ammostuff;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sgtweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _ltnweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _majweapons;
	{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _colweapons;
};
sleep 20; 
}; // Linked to While do

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

This is taken from Fockers Most wanted - tear it apart and you will see - if not heres the basics of it

for some reason it only worked with switch and not if statements

markers in game for where crate spawns - Ammocrate_start

weaponscratejip.sqf

_Ammocrate_0 = "USBasicWeapons_EP1" createvehiclelocal (getMarkerPos "Ammocrate_start");
_Ammocrate_0 allowdamage false;
nul=[_Ammocrate_0] execVM "weaponsfiller.sqf";

weaponsfiller.sqf

/////////////////////////////////////////////////////////////
// [FOCK] Mikie J  - http://fockers.moonfruit.com
// Part of the ranking files created by [FOCK] Mikie J 
/////////////////////////////////////////////////////////////

//_null = [this,this] execVM "weaponsfiller.sqf";

if (!isdedicated) then                                   //not run on the dedicated server - client side 
{

waituntil {!isnull player};


//_unit = _this select 0;
_ammostuff = _this select 0;

_playrank = rank player;

//Ranking of the weapons 

_privweapons =
[
"FN_FAL", "LeeEnfield", "M4A1", "M16A2", "m136", "M9", "AK_74", "AK_47_S", "AK_47_M", "Makarov", "Binocular_Vector", "Binocular", "NVGoggles", "ItemCompass", "ItemGPS", "ItemMap", "ItemRadio", "ItemWatch"
];

_corpweapons = 
[
"M16A2GL", "G36C_camo", "G36A_camo", "G36K_camo", "M14_EP1", "BAF_L85A2_RIS_Holo", "M60A4_EP1", "STINGER", "M9SD", "revolver_EP1", "laserdesignator"
];

_sergweapons = 
[
"M4A3_CCO_EP1", "G36_C_SD_camo", "M79_EP1", "Sa58V_RCO_EP1", "Sa58V_CCO_EP1", "BAF_L85A2_RIS_SUSAT", "m8_compact_pmc", "Mk_48_DES_EP1", "M47Launcher_EP1", "Colt1911", "revolver_gold_EP1", "M24_des_EP1" 
]; 

_lieuweapons =
[
"FN_FAL_ANPVS4", "M4A3_RCO_GL_EP1", "SCAR_L_CQC", "SCAR_L_CQC_Holo", "M32_EP1", "BAF_L7A2_GPMG", "BAF_L85A2_RIS_ACOG", "BAF_L86A2_ACOG", "m8_holo_sd", "BAF_LRR_scoped", "m240_scoped_EP1", "M249_EP1", "BAF_L110A1_Aim", "MAAWS", "glock17_EP1"
];

_captweapons =
[
"SCAR_L_STD_Mk4CQT", "SCAR_L_STD_EGLM_RCO", "SCAR_L_CQC_EGLM_Holo", "SCAR_L_STD_HOLO", "SCAR_H_CQC_CCO", "BAF_L85A2_UGL_Holo", "BAF_L85A2_UGL_SUSAT", "BAF_L85A2_RIS_CWS", "AA12_PMC", "m8_tws", "BAF_LRR_scoped_W", "MG36_camo", "BAF_NLAW_Launcher", "Sa61_EP1", "UZI_EP1", "UZI_SD_EP1"
];

_majweapons = 
[
"SCAR_L_STD_EGLM_TWS", "SCAR_L_CQC_CCO_SD", "SCAR_H_CQC_CCO_SD", "SCAR_H_STD_EGLM_Spect", "Mk13_EP1", "BAF_L85A2_UGL_ACOG", "m8_tws_sd", "SCAR_H_LNG_Sniper", "SCAR_H_LNG_Sniper_SD", "M107", "M110_NVG_EP1", "BAF_AS50_scoped", "M249_TWS_EP1", "M249_m145_EP1"
];

_colweapons =
[
"SCAR_H_STD_TWS_SD", "m107_TWS_EP1", "M110_TWS_EP1", "BAF_AS50_TWS", "JAVELIN"
];


//ranking gun system


//   while {alive _ammostuff} do 
//{    
//ammo and items
clearmagazineCargoglobal _ammostuff;

sleep 1;
_ammostuff addMagazineCargoGlobal ["8Rnd_B_Beneli_74Slug",40];
//add all your mags ect here and nades

  while {alive _ammostuff} do 
{  

 switch (true) do
{
_playrank = rank player;


case (_playrank == "PRIVATE") : 
{
clearWeaponCargoglobal _ammostuff;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;	
 };


case (_playrank == "CORPORAL") :
{
clearWeaponCargoglobal _ammostuff;

{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
};

case (_playrank == "SERGEANT") :
{
clearWeaponCargoglobal _ammostuff;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sergweapons;
};


case (_playrank == "LIEUTENANT") :
{
clearWeaponCargoglobal _ammostuff;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sergweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _lieuweapons;
};


case (_playrank == "CAPTAIN") :
{
clearWeaponCargoglobal _ammostuff;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sergweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _lieuweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
};

case (_playrank == "MAJOR") :
{
clearWeaponCargoglobal _ammostuff;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sergweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _lieuweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _majweapons;	
};

case (_playrank == "COLONEL") :
{
clearWeaponCargoglobal _ammostuff;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _privweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _corpweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _sergweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _lieuweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _captweapons;
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _majweapons;	
{ _ammostuff addWeaponCargoglobal [_x,10]; } foreach _colweapons;	
};
};
waituntil {count playableUnits >= 1};
sleep 500; // restock time.
};  // linked to While do 
}; //linked to the isnot dedicated


ranknew.sqf

//////////////////////////////////////////////////////////////////
// Function file for Armed Assault
// [FOCK] Mikie J - adapted from earlier evo map - unknown author
//////////////////////////////////////////////////////////////////


/////change score accordingly 
rankup1 = 25; //corporal
rankup2 = 70; //sergeant
rankup3 = 150; //lieutenant
rankup4 = 250; //captain
rankup5 = 350; //major
rankup6 = 500;//colonel
/////////////////////////

if ! isdedicated then                                   //not run on the dedicated server - client side 
{
[] spawn 								// calls the below script used for a loop
{
waituntil {!isnull player};	

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do 

{

switch (true) do 

{
_myguy = name player; 
     _score = score player;
_promo = rank player;

 case ((_score < rankup1) and (_promo != "PRIVATE")) :

  {
      hint format["Your rank is now %2",_myguy,"PRIVATE"];

	aunit = player;
	arank = "PRIVATE";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";	

 };

 case (( _score < rankup2) and (_score >= rankup1) and (_promo != "CORPORAL")): 

  {
      hint format["Your rank is now %2",_myguy,"CORPORAL"];

	aunit = player;
	arank = "CORPORAL";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";

 };


 case ((_score < rankup3) and (_score >= rankup2) and (_promo != "SERGEANT")) :

   {
      	hint format["Your rank is now %2",_myguy,"SERGEANT"];

	aunit = player;
	arank = "SERGEANT";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";	

  };


 case (_score < rankup4 and _score >= rankup3 and _promo != "LIEUTENANT") :

  {

  hint format["Your rank is now %2",_myguy,"LIEUTENANT"];
	aunit = player;
	arank = "LIEUTENANT";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";

  };


  case (_score < rankup5 and _score >= rankup4 and _promo != "CAPTAIN") :

  {

		hint format["Your rank is now %2",_myguy,"CAPTAIN"];
	aunit = player;
	arank = "CAPTAIN";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";

  };

 case (_score < rankup6 and _score >= rankup5 and _promo != "MAJOR") :

 {
  	hint format["Your rank is now %2",_myguy,"MAJOR"];
	aunit = player;
	arank = "MAJOR";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";

 };

 case (_score >= rankup6 and _promo != "COLONEL") :

 {
      hint format["Your rank is now %2",_myguy,"COLONEL"];
	aunit = player;
	arank = "COLONEL";
	player setUnitRank arank;
	publicVariable "aunit";
	publicVariable "arank";

  };



};
sleep 1.03;
};

};	
};


Share this post


Link to post
Share on other sites

@Mikie Boy thanks you very much for sharing this with me, I can't wait to see this work.

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  

×