Jump to content
  • 0

Random loadout script


hozzdutch

Question

Hi all,

 

I'm very much a beginner at all this coding malarkey, so what I'm attempting is failing.

I've been over as many posts as I can find, but I've not found anything that helps.

As the title suggests, I'm trying to a random starting loadout.

I've tried this multiple different ways but it either does nothing at all, or stops the players from logging in.

 

I've tried placing this line in the init.sqf

[] ExecVM "Scripts\loadout.sqf";

under this piece of code -

if (!isDedicated) then {
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");

The loadout.sqf contains the following -

switch floor(random 3) do {
case 0 :
     DefaultMagazines = ["8Rnd_9x18_Makarov","8Rnd_9x18_Makarov","ItemBandage","ItemBandage","ItemMorphine","FoodCanPasta","ItemSodaMdew","ItemPainkiller"];
     DefaultWeapons = ["ItemFlashlightRed","ItemMap","ItemCompass","Makarov"];
     DefaultBackpackWeapon = "";

case 1 :
     DefaultMagazines = ["8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","FoodCanFrankBeans","ItemMorphine","ItemBandage","ItemBandage","ItemSodaPepsi","ItemPainkiller","ItemMorphine"];
     DefaultWeapons = ["ItemFlashlightRed","ItemMap","MakarovSD"];
     DefaultBackpackWeapon = "";

case 2 :
     DefaultMagazines = ["10x_303","10x_303","FoodCanSardines","ItemSodaCoke","ItemMorphine","ItemBandage","ItemBandage","ItemPainkiller"];
     DefaultWeapons = ["ItemFlashlightRed","ItemMap"];
     DefaultBackpackWeapon = "LeeEnfield";
};

This doesn't do anything at all, no loadouts are given.

 

I've tried calling the script from server_playerlogin.sqf but then all that happens is players fail at the authentication stage of logging in.

I've tried placing the loadout script directly into init.sqf, which again, does nothing. I've tried placing the code directly into server_playerlogin.sqf but again, it fails to load.

 

Can anyone tell me where I'm going wrong?

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

You're missing some brackets but not sure would it still work. Try this.

_random = round(random(2));

switch (_random) do {
case 0: 
    {
    DefaultMagazines = ["8Rnd_9x18_Makarov","8Rnd_9x18_Makarov","ItemBandage","ItemBandage","ItemMorphine","FoodCanPasta","ItemSodaMdew","ItemPainkiller"];
    DefaultWeapons = ["ItemFlashlightRed","ItemMap","ItemCompass","Makarov"];
    DefaultBackpackWeapon = "";
    };

case 1:
    {
    DefaultMagazines = ["8Rnd_9x18_MakarovSD","8Rnd_9x18_MakarovSD","FoodCanFrankBeans","ItemMorphine","ItemBandage","ItemBandage","ItemSodaPepsi","ItemPainkiller","ItemMorphine"];
    DefaultWeapons = ["ItemFlashlightRed","ItemMap","MakarovSD"];
    DefaultBackpackWeapon = "";
    };

case 2:
    {
    DefaultMagazines = ["10x_303","10x_303","FoodCanSardines","ItemSodaCoke","ItemMorphine","ItemBandage","ItemBandage","ItemPainkiller"];
    DefaultWeapons = ["ItemFlashlightRed","ItemMap"];
    DefaultBackpackWeapon = "LeeEnfield";
    };
};
Link to comment
Share on other sites

  • 0

 

You're missing some brackets but not sure would it still work. Try this.

_random = round(random(2));

switch (_random) do {

 

this would work aswell:

switch (round(random 2)) do {
if (!isDedicated) then {
	//Conduct map operations
	0 fadeSound 0;
	waitUntil {!isNil "dayz_loadScreenMsg"};
	dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");

 

was about to say, if you put it there it will not work, but since you are using the default epoch variables, i guess it will work aswell, once you fixed your brackets

 

also check your rpt files for errors, they should give you a hint about whats wrong

Link to comment
Share on other sites

  • 0

OK, so I've changed the code to try both 

_random = round(random(2));
switch (_random) do {

and

switch (round(random 2)) do {

but neither makes any difference.

 

Players spawn with no loadout.

I've checked through all the logs and I can't see any errors relating to this.

Just to make sure the script was actually being called, I purposely misspelt the filename and sure enough, this gives an error on log in - the file can't be found.

Change it back, the errors go away, but no loadout is given.

 

Any more ideas?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...