*Now into the same script you will need check if this player have the item variable so:
if (_hasitem) then {
};
so the script can be:
Spoiler
if (_hasitem) then {
//here you put what happend if this player had the items and if u want an animation and a command to remove the item
//for example : make the animation ,put the player thirst at 100% and remove only 1 item
player playActionNow "Medic";
dayz_thirst = 0;
player removeMagazine "FoodchickenCooked";
}else{
//here u can put a text to say missing items cutText [format["You will need 1xFoodchickenCooked"], "PLAIN DOWN"];
};
*Now at very top its time to define the private variables for this script so:
private = ["name of variable","name of variable"];
private = ["_hasitem"];
So at this time the script looks like:
Spoiler
private = ["_hasitem"];
_hasitem = "FoodchickenCooked" in magazines player;
if (_hasitem) then {
player playActionNow "Medic";
dayz_thirst = 0;
player removeMagazine "FoodchickenCooked";
}else{
cutText [format["You will need 1xFoodchickenCooked"], "PLAIN DOWN"];
};
2-REMOVING ITEMS
Here you will see how to remove more than 1 item: ( remember for remove only one item you can use player removeMagazine "FoodchickenCooked"; )
But you need define what means _Time & _LastUsedTime variables and need put where start to count. So:
_LastUsedTime = 1200;//time in seconds before use again the script
_Time = time - lastuse; //"lastuse" is where you start to count and is equal to time so you need to put it immediately after the _hasitem variable is checked as fine...
/////////////////////Proceed
if (_hasitem) then { lastuse = time;
player playActionNow "Medic";
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
4-USING RANDOMS
Now you wanna put a random events into the script. You can use two ways:
First:
_randomCases = round(random(2));
switch (_randomCases) do {
case 0 :{
//what happend here?
};
case 1 :{
//what happend here?
};
};
Or the other way:
_randomNumbers = floor(random 100);//you can use any other number 100,200,50
if (_randomNumbers <= 30) then { //if randomNumbers is less or equal to 30 then
//what happend here?
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then { //if randomNumbers is into 31 to 100 then
//what happend here?
};
/////////////////////Proceed
if (_hasitem) then {
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems; };
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1; };
};
5-ADD A TOOL REQUIRED
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if (_hastools) then {
};
/////////////////////Proceed
if (_hasitem && _hastools) then {
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
6-Allow The script only if player is an hero
Now you want procced with the script only if player is an hero.. so:
_PlayerHumanity = (player getVariable"humanity");
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_PlayerHumanity > 5000) then {
};
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
}; };
};
};
8-Nearest Required
Now a nearest required from an objet or AI.
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["TK_CIV_Woman01_EP1"], 4] > 0; //TK_CIV_Woman01_EP1 is an AI id
if (_nearestRestriction) then {
};
you can use it to execute scripts only into plot area...
for example:
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
if (_nearestRestriction) then {
};
or to restrict if is present
for example if is a plot pole in the area you cant execute the script
_player = player;//create a _player variable
_mark = "RoadFlare" createVehicle getPosATL _player;//create a roadflare called _mark with the same location of _player
_mark attachTo [_player, [0,0,0]];//attach _mark to _player with 0/0/0 axis values
In this case we create a "RoadFlare" in the _player position and proceed to attach it with the player
Question
juandayz
A very basic guide to make your own script:
Feel free to complete this guide :)
1-IN CASE U NEED ADD ONE ITEMS REQUIRED (only one)
structure:
your own variable = "ITEM ID" in magazines player;
_hasitem = "FoodchickenCooked" in magazines player;
2-IN CASE U NEED ADD A ITEMS REQUIRED (more than one)
structure:
your own variable = [["ITEM ID",AMOUNT],["ITEM ID",AMOUNT]] call the function to check the items;
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
*Now into the same script you will need check if this player have the item variable so:
if (_hasitem) then { };
so the script can be:
if (_hasitem) then {
//here you put what happend if this player had the items and if u want an animation and a command to remove the item
//for example : make the animation ,put the player thirst at 100% and remove only 1 item
player playActionNow "Medic";
dayz_thirst = 0;
player removeMagazine "FoodchickenCooked";
}else{
//here u can put a text to say missing items
cutText [format["You will need 1xFoodchickenCooked"], "PLAIN DOWN"];
};
*Now at very top its time to define the private variables for this script so:
private = ["name of variable","name of variable"];
private = ["_hasitem"];
So at this time the script looks like:
private = ["_hasitem"];
_hasitem = "FoodchickenCooked" in magazines player;
if (_hasitem) then {
player playActionNow "Medic";
dayz_thirst = 0;
player removeMagazine "FoodchickenCooked";
}else{
cutText [format["You will need 1xFoodchickenCooked"], "PLAIN DOWN"];
};
2-REMOVING ITEMS
Here you will see how to remove more than 1 item: ( remember for remove only one item you can use player removeMagazine "FoodchickenCooked"; )
item requiered:
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
to remove this items use:
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
So now the whole script looks:
private = ["_hasitem","_remove"];
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
if (_hasitem) then {
player playActionNow "Medic";
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
}else{
cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];
};
Thers other way to say "you dont have the item required" see:
if (!_hasitem) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
***Note: the ! before the variable means NOT . So here the code say: if player Dont Have (_hasitem) exitWith {};
so now the script looks:
private = ["_hasitem","_remove"];
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
if (!_hasitem) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if (_hasitem) then {
player playActionNow "Medic";
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
3-ADD A TIME RESTRICTION TO USE THE SCRIPT AGAIN
Now whats about if u wanna put a time restriction to execute the script?
well heres the structure:
if(_Time < _LastUsedTime) exitWith { cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"]; };
But you need define what means _Time & _LastUsedTime variables and need put where start to count. So:
_LastUsedTime = 1200;//time in seconds before use again the script
_Time = time - lastuse; //"lastuse" is where you start to count and is equal to time so you need to put it immediately after the _hasitem variable is checked as fine...
see:
if (_hasitem) then { lastuse = time; };
Well now the whole script looks:
private = ["_hasitem","_remove","_LastUsedTime","_Time"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
//////////////////////////
/////Negatives///////
if (!_hasitem) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_hasitem) then {
lastuse = time;
player playActionNow "Medic";
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
4-USING RANDOMS
Now you wanna put a random events into the script. You can use two ways:
First:
_randomCases = round(random(2)); switch (_randomCases) do { case 0 :{ //what happend here? }; case 1 :{ //what happend here? }; };
Or the other way:
_randomNumbers = floor(random 100);//you can use any other number 100,200,50 if (_randomNumbers <= 30) then { //if randomNumbers is less or equal to 30 then //what happend here? }; if (_randomNumbers <= 100 && _randomNumbers > 31) then { //if randomNumbers is into 31 to 100 then //what happend here? };
So for the first example the whole script looks:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomCases"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomCases = round(random(2));
//////////////////////////
/////Negatives///////
if (!_hasitem) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_hasitem) then {
lastuse = time;
player playActionNow "Medic";
switch (_randomCases) do {
case 0 :{
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
case 1 :{
dayz_thirst = 1;
};
};
};
And for the second example looks:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
//////////////////////////
/////Negatives///////
if (!_hasitem) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_hasitem) then {
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
5-ADD A TOOL REQUIRED
_inventory = items player; _hastools = "ItemToolbox" in _inventory; if !(_hastools) exitWith { cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];}; if (_hastools) then { };
So now the script looks:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
//////////////////////////
/////Negatives///////
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_hasitem && _hastools) then {
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
6-Allow The script only if player is an hero
Now you want procced with the script only if player is an hero.. so:
_PlayerHumanity = (player getVariable"humanity"); if (_PlayerHumanity < 5000) exitWith { cutText [format["Need be a hero"], "PLAIN DOWN"];}; if (_PlayerHumanity > 5000) then { };
So the whole script now is:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
};
7-ADD A COIN COST
Whats about if u wanna put a coins cost to execute it?
_costs = 200; if !([ player,_costs] call SC_fnc_removeCoins) then { titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1]; } else { titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1]; };
So now script looks:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
};
};
8-Nearest Required
Now a nearest required from an objet or AI.
_playerPos = getPosATL player; _nearestRestriction = count nearestObjects [_playerPos, ["TK_CIV_Woman01_EP1"], 4] > 0; //TK_CIV_Woman01_EP1 is an AI id if (_nearestRestriction) then { };
you can use it to execute scripts only into plot area...
for example:
_playerPos = getPosATL player; _nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0; if (_nearestRestriction) then { };
or to restrict if is present
for example if is a plot pole in the area you cant execute the script
_playerPos = getPosATL player; _nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0; if (_nearestRestriction) exitWith { cutText [format["Not in plot area"], "PLAIN DOWN"];}; };
So now the script is:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["TK_CIV_Woman01_EP1"], 4] > 0;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_nearestRestriction) then {
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
};
};
};
in negative case.. (if u cannot execute the script if the objet plot area is present then the script must be):
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_nearestRestriction) exitWith {
cutText [format["Not in plot area"], "PLAIN DOWN"];};
};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
};
};
};
};
9-Give something to the player
here you can use:
player addMagazine "item id";
so for example if u wanna give gold money then:
player addMagazine "ItemBriefcase100oz";
if u wanna give coins money then:
_add = [player, 1000] call SC_fnc_addCoins;
if u wanna give a random item then:
_add = ["ItemSodaOrangeSherbet","HandGrenade_west","ItemSodaEmpty"] call BIS_fnc_selectRandom; player addMagazine _add;
So for the 1st example script looks: (give gold)
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_nearestRestriction) exitWith {
cutText [format["Not in plot area"], "PLAIN DOWN"];};
};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
player addMagazine "ItemBriefcase100oz";
};
};
};
};
for the 2nd example looks: (give coins)
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos","_add"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_nearestRestriction) exitWith {
cutText [format["Not in plot area"], "PLAIN DOWN"];};
};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
_add = [player, 1000] call SC_fnc_addCoins; //1000 coins
};
};
};
};
for the 3rd example (give random item)
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos","_add"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
_add = ["ItemSodaOrangeSherbet","HandGrenade_west","ItemSodaEmpty"] call BIS_fnc_selectRandom;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_nearestRestriction) exitWith {
cutText [format["Not in plot area"], "PLAIN DOWN"];};
};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
player addMagazine _add;
};
};
};
};
10-Create a small function
Now you need use random events and repeat a large or medium secuence.. to not write twice.. use a small functiion.. see:
///Function function_spawncrate = { _cratemodels=["USBasicWeapons_EP1","LocalBasicAmmunitionBox"] call BIS_fnc_selectRandom; _variete = ["ItemSodaOrangeSherbet","HandGrenade_west"] call BIS_fnc_selectRandom; _stone = ["CinderBlocks","MortarBucket","PartOreSilver"] call BIS_fnc_selectRandom; _wood = ["PartPlywoodPack","PartWoodPile","PartWoodLumber"] call BIS_fnc_selectRandom; _farm = ["FoodchickenRaw","FoodCanCorn","FoodrabbitRaw","ItemKiloHemp","FoodCanCurgon"] call BIS_fnc_selectRandom; _aiweapon = ["M16A2","M4A1"] call BIS_fnc_selectRandom; _crate1 = objNull; if (true) then{ _this = createVehicle [_cratemodels, [8352.9189, 5950.7417, -3.0517578e-005], [], 0, "CAN_COLLIDE"]; _crate1 = _this; clearWeaponCargoGlobal _crate1; clearMagazineCargoGlobal _crate1; _crate1 addWeaponCargoGlobal [_aiweapon, 1]; _crate1 addmagazinecargoglobal [_variete, 2]; _crate1 addmagazinecargoglobal [_wood, 5]; _crate1 addmagazinecargoglobal [_stone, 3]; _crate1 addmagazinecargoglobal [_farm, 3]; _crate1 setVariable ["permaLoot",true]; }; sleep 400; deleteVehicle _crate1; }; ////////////////////////////////END FUINCTON
script looks:
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos","_variete","_stone","_wood","_farm","_aiweapon","_crate1"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//////////////////////////
///Function
function_spawncrate = {
_cratemodels=["USBasicWeapons_EP1","LocalBasicAmmunitionBox"] call BIS_fnc_selectRandom;
_variete = ["ItemSodaOrangeSherbet","HandGrenade_west"] call BIS_fnc_selectRandom;
_stone = ["CinderBlocks","MortarBucket","PartOreSilver"] call BIS_fnc_selectRandom;
_wood = ["PartPlywoodPack","PartWoodPile","PartWoodLumber"] call BIS_fnc_selectRandom;
_farm = ["FoodchickenRaw","FoodCanCorn","FoodrabbitRaw","ItemKiloHemp","FoodCanCurgon"] call BIS_fnc_selectRandom;
_aiweapon = ["M16A2","M4A1"] call BIS_fnc_selectRandom;
_crate1 = objNull;
if (true) then{
_this = createVehicle [_cratemodels, [8352.9189, 5950.7417, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
_crate1 = _this;
clearWeaponCargoGlobal _crate1;
clearMagazineCargoGlobal _crate1;
_crate1 addWeaponCargoGlobal [_aiweapon, 1];
_crate1 addmagazinecargoglobal [_variete, 2];
_crate1 addmagazinecargoglobal [_wood, 5];
_crate1 addmagazinecargoglobal [_stone, 3];
_crate1 addmagazinecargoglobal [_farm, 3];
_crate1 setVariable ["permaLoot",true];
};
sleep 400;
deleteVehicle _crate1;
};
////////////////////////////////END FUINCTON
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_nearestRestriction) exitWith {
cutText [format["Not in plot area"], "PLAIN DOWN"];};
};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
call function_spawncrate;
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
call function_spawncrate;
player addMagazine "ItemBriefcase100oz";
};
};
};
};
other way is call an external script into main script see:
[] execVM 'path\to\external\script.sqf';
so the variant to not make the small function as above is call this external.sqf
your main.sqf
private = ["_hasitem","_remove","_LastUsedTime","_Time","_randomNumbers","_inventory","_hastools","_PlayerHumanity","_costs","_nearestRestriction","_playerPos"];
////////////////////Section to define all variables
_hasitem = [["cinder_wall_kit",2], ["ItemWoodFloor",3]] call player_checkItems;
_LastUsedTime = 1200;
_Time = time - lastuse;
_randomNumbers = floor(random 100);
_inventory = items player;
_hastools = "ItemToolbox" in _inventory;
_PlayerHumanity = (player getVariable"humanity");
_costs = 200;
_playerPos = getPosATL player;
_nearestRestriction = count nearestObjects [_playerPos, ["Plastic_Pole_EP1_DZ"], 30] > 0;
//////////////////////////
/////Negatives///////
if (_PlayerHumanity < 5000) exitWith {
cutText [format["Need be a hero"], "PLAIN DOWN"];};
if (_nearestRestriction) exitWith {
cutText [format["Not in plot area"], "PLAIN DOWN"];};
};
if (!_hasitem ) exitWith {cutText [format["You will need 2xcinder_wall_kit and 3xItemWoodFloor"], "PLAIN DOWN"];};
if !(_hastools) exitWith {
cutText [format["Must be equiped with 1x toolbox in your toolbet."], "PLAIN DOWN"];};
if(_Time < _LastUsedTime) exitWith {
cutText [format["wait %1 seconds !",(round(_Time - _LastUsedTime))], "PLAIN DOWN"];
};
//////////////////////
/////////////////////Proceed
if (_PlayerHumanity > 5000) then {
if (_hasitem && _hastools) then {
if !([ player,_costs] call SC_fnc_removeCoins) then {
titleText [format["Needs %1 %2.",_costs,CurrencyName] , "PLAIN DOWN", 1];
} else {
titleText [format["Pay %1 %2 for this",_costs,CurrencyName] , "PLAIN DOWN", 1];
lastuse = time;
player playActionNow "Medic";
if (_randomNumbers <= 30) then {
dayz_thirst = 0;
[] execVM 'path\to\external\external.sqf';
_remove = [["cinder_wall_kit",2],["ItemWoodFloor",3]] call player_removeItems;
};
if (_randomNumbers <= 100 && _randomNumbers > 31) then {
dayz_thirst = 1;
[] execVM 'path\to\external\external.sqf';
player addMagazine "ItemBriefcase100oz";
};
};
};
};
and you can put into external.sqf same codes as function_spawncrate
external.sqf
private ["_cratemodels","_variete ","_stone","_wood ","_farm","_aiweapon","_crate1"];
_cratemodels=["USBasicWeapons_EP1","LocalBasicAmmunitionBox"] call BIS_fnc_selectRandom;
_variete = ["ItemSodaOrangeSherbet","HandGrenade_west"] call BIS_fnc_selectRandom;
_stone = ["CinderBlocks","MortarBucket","PartOreSilver"] call BIS_fnc_selectRandom;
_wood = ["PartPlywoodPack","PartWoodPile","PartWoodLumber"] call BIS_fnc_selectRandom;
_farm = ["FoodchickenRaw","FoodCanCorn","FoodrabbitRaw","ItemKiloHemp","FoodCanCurgon"] call BIS_fnc_selectRandom;
_aiweapon = ["M16A2","M4A1"] call BIS_fnc_selectRandom;
_crate1 = objNull;
if (true) then{
_this = createVehicle [_cratemodels, [8352.9189, 5950.7417, -3.0517578e-005], [], 0, "CAN_COLLIDE"];
_crate1 = _this;
clearWeaponCargoGlobal _crate1;
clearMagazineCargoGlobal _crate1;
_crate1 addWeaponCargoGlobal [_aiweapon, 1];
_crate1 addmagazinecargoglobal [_variete, 2];
_crate1 addmagazinecargoglobal [_wood, 5];
_crate1 addmagazinecargoglobal [_stone, 3];
_crate1 addmagazinecargoglobal [_farm, 3];
_crate1 setVariable ["permaLoot",true];
};
sleep 400;
deleteVehicle _crate1;
11-Some "Commands"
sleep ( you can use it to leave in "stand by" your script for some seconds )
example: ( wait 40 seconds and proceed to delete a crate called _crate1 )
sleep 40; deleteVehicle _crate1;
also you can use a variable to define the time and make wait the variable with sleep command:
_wait_time = 40; sleep _wait_time; deleteVehicle _crate1;
Other way to let the script in "stand by" is use waitUntil command.
for example wait for nearest player from an objet:
_distance = 10; waitUntil {(player distance _xobjet) < _distance}; //proceed with the rest of the script
so with waitUntil also you can wait to complete some conditions as above, where script wait for player 10 mts near the _xobjet
removeAllWeapons player; //leave a player without weapons
removeBackpack player; //without backpack
{player removeMagazine _x} forEach magazines player; //without items
player setVariable['USEC_BloodQty',12000,true]; //set blood amount on player
r_player_infected = true; //infect player
[player,-100] call player_humanityChange;//modify humanity of the player
12-Count amount of item _
Now you need count how many items had this player in his inventory, to stop giving same item for example if thers more than 2
_bloodbagAmount = {_x == "ItemBloodbag"} count magazines player; if (_bloodbagAmount > 2) exitWith { cutText [format["WARNING: %1, YOure Full of bloodbags", name player], "PLAIN DOWN"]; };
13-Leave the script if player is in combat
if (dayz_combat == 1) exitWith { cutText [format["IN COMBAT."], "PLAIN DOWN"]; };
14-Attach to
_player = player;//create a _player variable _mark = "RoadFlare" createVehicle getPosATL _player;//create a roadflare called _mark with the same location of _player _mark attachTo [_player, [0,0,0]];//attach _mark to _player with 0/0/0 axis values
In this case we create a "RoadFlare" in the _player position and proceed to attach it with the player
Link to comment
Share on other sites
15 answers to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now