Jump to content

Community (server side) MOD


nedfox

Recommended Posts

Introduction .

 

Lots of times, addons need to run server side, at server init.. Examples can be: spawning of items like crates, custom missions, modified loot scripts or indestructable objects.

To accomplish this, the best was is to have a PBO framework which resides in @EpochHive/Addons, *NEXT TO* the Epoch PBO's so it can be run without ANY modification of Epoch server files.

Making such a PBO isn't hard, but requires lots of reading and testing and sometimes a step too far for server admins.. Having such a PBO ready to use for your own is what I'm going to post here, and explain line by line.

 

Goal .

 

The goal is to present something that anyone with notepadd++, PBOManager and some basic scripting knowledge can use for their own server, to implement posted scriptlets with goodies here on the forum without having to figure out how to make the basics work.. See it as a framework in which you can drag and drop community posted scripts and make them work server side.

Also, these scripts are not transferred to clients, making it "secure" if coders don't want to share lengthy scripts, or prevent hackers looking for holes.

 

Details. .

 

The frameworks exists of 2 folders and some config files..

1 Folder, called "serverside" is where you drop your scripts in.

1 Folder, called "init" contains a file called "fn_init.sqf" in which you declare all functions/procedures

1 File called "config.cpp" which does not need to be edited, ever.

1 File called "PboPrefix.txt" which defines the necessary prefixes so Epoch servers understand where to look for functions etc. You will never have to edit this file either.

 

 

* fn_init.sqf

 

This file contains declaration of my example scripts, which spawns a set number of crates randomly on the map, with configurable settings,plus some other  scripts that could be useful.

// Include your sqf files in here.

/*
spawncrates.sqf spawns random crates around a marker
spawn-one-NPC.sqf puts an NPC on the map, which can be configured to "do stuff"
indestructable.sqf sets certain building objects invulnerable
*/

diag_log format ['Starting Community MOD'];

//call compile preprocessFileLineNumbers "\x\addons\custom\serverside\spawncrates.sqf";
//call compile preprocessFileLineNumbers "\x\addons\custom\serverside\spawn-one-NPC.sqf";
[] execVM '\x\addons\custom\serverside\indestructible.sqf';

When you add your own scripts, which you drop in the "serverside" folder, you add each one as an extra line, with the same path, but different name

For example, you added a spawncustomloot.sqf in the serverside folder, you add this line :

call compile preprocessFileLineNumbers "\x\addons\custom\serverside\spawncustomloot.sqf"; 

or (If you lockup the server with inifinite precompiled loops) :

[] execVM '\x\addons\custom\serverside\spawncustomloot.sqf';

* spawncrates.sqf (example)

 

This is the example script, which is currently set to spawn 4 crates on Sector B island on Tavi, randomly chosen within 4 randomly set green circles.. When a player starts the game, he will see 4 green circles, in which somewhere is a crate with building goodies. I'll advice to have these crates heavily guarded by Ai :) !!

You can set size of the circles, number of crates, make it spawn shore or even water only, or hide the green circles making them totally obscured by any markers, and any lucky guy will have a field day when he finds one. The crates are filled with random (set) number of items, and is easily adaptable for guns, or ammo..

The crates CAN be lifted with a CH-67 for example, but will NOT survive server restarts !

I also included the normal marker and distances to be used as "map wide" spawn points. Just put "//" in front of the lines you don't want to be processed and remove them from the others.

/*
File: spawncrates.sqf
Author: NedFox [TZW]

Description: Custom Crates, randomly placed around a marker which is visible (or not).
*/
if (isServer) then {
_numberofcrates = 4; // this is the number of crates that you want to spawn
_spawnCenter = [22600,19600,0]; // Example : This is the center around which the crates will spawn, Sector B island on Tavi.
//_spawnCenter = getmarkerpos "center"; // Use this if you want the global center of the map, it's declared in mission.sqm, island specific
_min = 0; // minimum distance from the center position (Number) in meters
//_max = 12000; // maximum distance from the center position (Number) in meters
_max = 450; // Example : maximum range of spawned crates, to keep them INSIDE the sector B compound
_mindist = 5; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
_water = 0; // water mode (Number) 0: cannot be in water , 1: can either be in water or not , 2: must be in water
_shoremode = 0; // 0: does not have to be at a shore , 1: must be at a shore
_marker = True; // Draw a green circle in which the crate will be spawned randomly
_markersize = 100; // Radius of the marker in meters
diag_log format['Starting spawncrates.sqf']; //make a line in the RPT file to notify the scripts is going to run now.
for "_i" from 1 to _numberofcrates do
  {
_pos = [_spawnCenter,_min,_max,_mindist,_water,2000,_shoremode] call BIS_fnc_findSafePos; // find a random location within range
if (_marker) then {
     _event_marker = createMarker [ format ["loot_marker_%1", _i], _pos];
  _event_marker setMarkerShape "ELLIPSE";
  _event_marker setMarkerColor "ColorGreen";
  _event_marker setMarkerAlpha 0.75;
  _event_marker setMarkerSize [(_markersize+15), (_markersize+15)]; //green circle slightly bigger , box can spawn just outside if not increased
  _pos = [_pos,0,_markersize,0,_water,2000,_shoremode] call BIS_fnc_findSafePos;  //find a random spot INSIDE the marker area
  _pos = [_pos select 0, _pos select 1, 0];
};
diag_log format['Spawncrate %1 : Location %2',_i,_pos]; // post a line in the RPT file with the exact location of the crate.
_box = "CargoNet_01_box_F" createvehicle _pos;   //create the crate  .. These ARE liftable with chopper like the CH-67 , but will not stay after restarts !
// _box = "Box_NATO_Support_F" createvehicle _pos;   //create a smaller crate. Use either, not both

clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;
    clearItemCargoGlobal _box;
_box setVariable ["permaLoot",true]; //stay until reset
_box allowDamage false; // Prevent boxes to explode when spawning
_box addItemCargoGlobal ["MortarBucket", 4 + (random 2)];  // between 4-6
_box addItemCargoGlobal ["Cinderblocks", 8 + (random 4)]; // between 8-12
_box addItemCargoGlobal ["CircuitParts", (random 1)]; // between 0-1
_box addItemCargoGlobal ["ItemCorrugated", 2 + (random 3)]; // between 2-5
_box addItemCargoGlobal ["ItemCorrugatedLg", (random 2)]; // between 0-2
_box addItemCargoGlobal ["KitTipi", (random 2)]; // between 0-2
_box addItemCargoGlobal ["CSGAS", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["EnergyPackLg", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["KitShelf", 2 + (random 2)]; // between 2-4
_box addItemCargoGlobal ["KitFoundation", (random 2)]; // between 0-2
_box addItemCargoGlobal ["Chainsaw", (random 1)]; // between 0-1
_box addItemCargoGlobal ["KitCinderWall", 3 + (random 4)]; // between 3-7
  }
};

Attached below this post is the PBO, which simply can be dropped into the @EpochHive/Addon folder and does not require ANY other settings to activate.

 

I hope this framework will be a standard for other coders in the future to add functions too, without having ppl to modify all kind if init.sqf, making modifications in the mission.PBO which makes the client downloads larger etc etc.

Link to comment
Share on other sites

hey,

thanks, but dont work so... there is a error in it, so either the name of the pbo is wrong, or the paths need to be adjusted...

 

edit: the paths are not entirely.

 

What's wrong with it? we've tested it on several servers, but will tackle anything that comes up.. Do you get any errors ?

Link to comment
Share on other sites

sorry, my mistake ... everything ok .... many thanks: D I just play with the bot (dude) around, the dude does not fire on me: D now I'm interested in the spawn ai: D I need more info: D but I google already: D

 

i send you a indestructable base script. set at the moment only on cinder.indestructible

 

edit: u have a pm with indestructible :-)

Link to comment
Share on other sites

Cheers Suppe, you got me on the right track with the indestructable script.. I'll try and make it as readable as possible for admins to understand what it does, and able to alter it without breaking it. (which is HARD :P)

 

Also, the spawn AI was due to the guy who wanted some AI's standing around doing nothing; When I have time coming days I'll comment every line (with options) so it could be used to spawn any random AI somewhere, aggressive or not etc..

Not that it matters, but if I keep it simple, it might give insight in the AI mission scripts that have been around; Giving a simple example with easy configs will make ppl realise what all these things do to a unit.

Link to comment
Share on other sites

no problem, you're welcome: D So as I've sent you the script, if you add the foundation and the two cinderparts (door and wall) everything is indestructable.

yes, that would be cool with the "ai" manual.... the script with the boxes, I can definitely use very well: D

would be cool if I could spawn "groups" of bots to a fixed position, a simple way, the ai missions are too complex to learn from them, very simple, where you can add yourself gradually.

Link to comment
Share on other sites

would be cool if I could spawn "groups" of bots to a fixed position, a simple way, the ai missions are too complex to learn from them, very simple, where you can add yourself gradually.

 

I use AI Spawn Script Pack and they work perfectly, few changes and BE filters to do but they're good Ai and spawn/respawn/despawn via a trigger for better server performance :)

Link to comment
Share on other sites

 

I use AI Spawn Script Pack and they work perfectly, few changes and BE filters to do but they're good Ai and spawn/respawn/despawn via a trigger for better server performance :)

 

lol ... thanks .... I've already downloaded exactly that about 10 minutes before, but they are also very extensive, but if you have not previously dealt with spawn thing, you will understand this really hard.

 

But ok, I read and try to learn, I learn fast: D sometimes at least:-)

 

Link to comment
Share on other sites

Allright, needed to test (and troubleshoot) the indestructible script quite extensively..Thx Suppe for putting me in the right direction !!

 

The issue I ran into is something, when you haven't seen it before, will be VERY frustrating : Some functions will lock up the server if called with compile , and need to be executed (ie. recompiled) every time it's run.. Having an infinite loop, sleep commands make the server totally unresponsive if you try to compile it, hence the different line in fn_init.sqf.

 

Below is the script to make bases indestructible; there's 3 scenarios, all commented well, so take your pick :)

// This script makes certain objects indestructible. Tipi's and shelves are NOT in the array !!
sleep 80; //wait until server has started fully
//Here is an example that makes cinderwalls invulnerable. You need just ONE of these loops active, delete all the others

//while {true} do
//{ // do forever :
// diag_log format ['Community MOD, making objects invulnerable']; //post a line in the RPT to show what we're doing.
// _indestructible = (allMissionObjects "Constructions_static_F") + (allMissionObjects "PlotPole_EPOCH") + (allMissionObjects "LockBox_EPOCH") + (allMissionObjects "Foundation_Epoch"); // Make an array of all buildables including plotpole, lockbox and foundation
// {
//  // The next line *EXCLUDES* objects from being invulnerable.. Easier for admins to remove stuff then trying to add it :P
//  if (!((_x isKindof "WoodLargeWallDoorL_EPOCH") or (_x isKindof "WoodStairs2_EPOCH") or (_x isKindof "WoodStairs_EPOCH") or (_x isKindof "WoodRamp_EPOCH") or (_x isKindof "WoodFloor_EPOCH") or (_x isKindof "WoodLargeWallDoorway_EPOCH") or (_x isKindof "LockBox_EPOCH") or (_x isKindof "WoodLargeWall_EPOCH") or (_x isKindof "WoodLargeWallCor_EPOCH") or (_x isKindof "PlotPole_EPOCH") or (_x isKindof "CinderWallGarage_EPOCH") or (_x isKindof "WoodLargeWallDoor_EPOCH"))) then
//  {
//   _x addEventHandler ["HandleDamage", {false}];
//   _x enableSimulation false;
//  };
// } count _indestructible;
// sleep 120; // run every 2 minutes
//};

//Here is an example that makes cinderwalls, cinder garage doors, frequency jammers (plotpole) and lockboxes invulnerable. You need just ONE of these loops active, delete all the others
while {true} do
{ // do forever :
diag_log format ['Community MOD, making objects invulnerable']; //post a line in the RPT to show what we're doing.
_indestructible = (allMissionObjects "Constructions_static_F") + (allMissionObjects "PlotPole_EPOCH") + (allMissionObjects "LockBox_EPOCH") + (allMissionObjects "Foundation_Epoch"); // Make an array of all buildables including plotpole, lockbox and foundation
{
  // The next line *EXCLUDES* objects from being invulnerable.. Easier for admins to remove stuff then trying to add it :P
  if (!((_x isKindof "WoodLargeWallDoorL_EPOCH") or (_x isKindof "WoodStairs2_EPOCH") or (_x isKindof "WoodStairs_EPOCH") or (_x isKindof "WoodRamp_EPOCH") or (_x isKindof "WoodFloor_EPOCH") or (_x isKindof "WoodLargeWallDoorway_EPOCH") or (_x isKindof "WoodLargeWall_EPOCH") or (_x isKindof "WoodLargeWallCor_EPOCH") or (_x isKindof "WoodLargeWallDoor_EPOCH"))) then
  {
   _x addEventHandler ["HandleDamage", {false}];
   _x enableSimulation false;
  };
} count _indestructible;
sleep 120; // run every 2 minutes
};

//Here is an example that makes ALL OBJECTS invulnerable. You need just ONE of these loops active, delete all the others. Remember, Tipi's and shelves still are vulnerable !
//while {true} do
//{ // do forever :
// diag_log format ['Community MOD, making objects invulnerable']; //post a line in the RPT to show what we're doing.
// _indestructible = (allMissionObjects "Constructions_static_F") + (allMissionObjects "PlotPole_EPOCH") + (allMissionObjects "LockBox_EPOCH") + (allMissionObjects "Foundation_Epoch"); // Make an array of all buildables including plotpole, lockbox and foundation
// {
//  _x addEventHandler ["HandleDamage", {false}];
//  _x enableSimulation false;
// } count _indestructible;
// sleep 120; // run every 2 minutes
//};

This function needs to be called with :

[] execVM '\x\addons\custom\serverside\indestructible.sqf';

Hence the different call you see in fn_init.sqf

 

Attached is Version 1.3, only the indestructible function is active, just remove the remark signs "//" in fn_init.sqf if you want more.

I'll update the OP too with the latest version.

Community-V1.3.zip

Link to comment
Share on other sites

hey,

 

maybe you can help me now. :-)  I use your crates script, works so far so good, I've built something huge on the water, and he put it with the random spawns the boxes always under water :(

 

he does not recognize the after set things on (plattform over the water)

 

how can I change the beginning of the script to static boxes ? for example 3 static boxes ?

 

without which it seeks a safe position... I want to determine the position :-)

 

about help I would be very grateful

 

send me a pm if u not want to much bla bla in your post :D

 

*edit: iam good at editing, but scripting is something new for me, I'm still learning :-)

Link to comment
Share on other sites

The BIS function to find a spot, when set to use water, will just use water, away from anything.. Having a structure will not make those crates spawn there.

 

If you want to make a few static ones, break the loop, and use 3 procedures to spawn each one, YOU have to get the coordinates tho !!!

 

So, the spawncrates.sqf script you want to use is this :

 

Edit lines 30 , 66 and 102 for the coordinates !!!

 

/*
File: spawncrates.sqf
Author: NedFox [TZW]

Description: Custom Crates, randomly placed around a marker which is visible (or not).
*/
if (isServer) then {
//_numberofcrates = 4; // this is the number of crates that you want to spawn
//_spawnCenter = [22600,19600,0]; // Example : This is the center around which the crates will spawn, Sector B island on Tavi.
//_spawnCenter = getmarkerpos "center"; // Use this if you want the global center of the map, it's declared in mission.sqm, island specific
//_min = 0; // minimum distance from the center position (Number) in meters
//_max = 12000; // maximum distance from the center position (Number) in meters
// _max = 450; // Example : maximum range of spawned crates, to keep them INSIDE the sector B compound
//_mindist = 5; // minimum distance from the nearest object (Number) in meters, ie. spawn at least this distance away from anything within x meters..
_water = 0; // water mode (Number) 0: cannot be in water , 1: can either be in water or not , 2: must be in water
_shoremode = 0; // 0: does not have to be at a shore , 1: must be at a shore
_marker = True; // Draw a green circle in which the crate will be spawned randomly
_markersize = 100; // Radius of the marker in meters
diag_log format['Starting spawncrates.sqf'];
// Crate 1
_pos  = [x,y,z];  //EDIT THIS
if (_marker) then {
     _event_marker = createMarker [ format ["loot_marker_%1", 1], _pos];
  _event_marker setMarkerShape "ELLIPSE";
  _event_marker setMarkerColor "ColorGreen";
  _event_marker setMarkerAlpha 0.75;
  _event_marker setMarkerSize [(_markersize+15), (_markersize+15)]; //green circle slightly bigger , box can spawn just outside if not increased
};
diag_log format['Spawncrate 1 : Location %1',_pos];
_box = "CargoNet_01_box_F" createvehicle _pos;   //create the crate  .. These ARE liftable with chopper like the CH-67 , but will not stay after restarts !
// _box = "Box_NATO_Support_F" createvehicle _pos;   //create a smaller crate, use either, not both

clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;
    clearItemCargoGlobal _box;
_box setVariable ["permaLoot",true]; //stay until reset
_box allowDamage false; // Prevent boxes to explode when spawning
_box addItemCargoGlobal ["MortarBucket", 4 + (random 2)];  // between 4-6
_box addItemCargoGlobal ["Cinderblocks", 8 + (random 4)]; // between 8-12
_box addItemCargoGlobal ["CircuitParts", (random 1)]; // between 0-1
_box addItemCargoGlobal ["ItemCorrugated", 2 + (random 3)]; // between 2-5
_box addItemCargoGlobal ["ItemCorrugatedLg", (random 2)]; // between 0-2
_box addItemCargoGlobal ["KitTipi", (random 2)]; // between 0-2
_box addItemCargoGlobal ["CSGAS", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["EnergyPackLg", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["KitShelf", 2 + (random 2)]; // between 2-4
_box addItemCargoGlobal ["KitFoundation", (random 2)]; // between 0-2
_box addItemCargoGlobal ["Chainsaw", (random 1)]; // between 0-1
_box addItemCargoGlobal ["KitCinderWall", 3 + (random 4)]; // between 3-7
// Crate 2
_pos  = [x,y,z];  //EDIT THIS
if (_marker) then {
     _event_marker = createMarker [ format ["loot_marker_%1", 2], _pos];
  _event_marker setMarkerShape "ELLIPSE";
  _event_marker setMarkerColor "ColorGreen";
  _event_marker setMarkerAlpha 0.75;
  _event_marker setMarkerSize [(_markersize+15), (_markersize+15)]; //green circle slightly bigger , box can spawn just outside if not increased
};
diag_log format['Spawncrate 2 : Location %1',_pos];
_box = "CargoNet_01_box_F" createvehicle _pos;   //create the crate  .. These ARE liftable with chopper like the CH-67 , but will not stay after restarts !
// _box = "Box_NATO_Support_F" createvehicle _pos;   //create a smaller crate, use either, not both

clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;
    clearItemCargoGlobal _box;
_box setVariable ["permaLoot",true]; //stay until reset
_box allowDamage false; // Prevent boxes to explode when spawning
_box addItemCargoGlobal ["MortarBucket", 4 + (random 2)];  // between 4-6
_box addItemCargoGlobal ["Cinderblocks", 8 + (random 4)]; // between 8-12
_box addItemCargoGlobal ["CircuitParts", (random 1)]; // between 0-1
_box addItemCargoGlobal ["ItemCorrugated", 2 + (random 3)]; // between 2-5
_box addItemCargoGlobal ["ItemCorrugatedLg", (random 2)]; // between 0-2
_box addItemCargoGlobal ["KitTipi", (random 2)]; // between 0-2
_box addItemCargoGlobal ["CSGAS", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["EnergyPackLg", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["KitShelf", 2 + (random 2)]; // between 2-4
_box addItemCargoGlobal ["KitFoundation", (random 2)]; // between 0-2
_box addItemCargoGlobal ["Chainsaw", (random 1)]; // between 0-1
_box addItemCargoGlobal ["KitCinderWall", 3 + (random 4)]; // between 3-7
// Crate 3
_pos  = [x,y,z];  //EDIT THIS
if (_marker) then {
     _event_marker = createMarker [ format ["loot_marker_%1", 3], _pos];
  _event_marker setMarkerShape "ELLIPSE";
  _event_marker setMarkerColor "ColorGreen";
  _event_marker setMarkerAlpha 0.75;
  _event_marker setMarkerSize [(_markersize+15), (_markersize+15)]; //green circle slightly bigger , box can spawn just outside if not increased
};
diag_log format['Spawncrate 3 : Location %1',_pos];
_box = "CargoNet_01_box_F" createvehicle _pos;   //create the crate  .. These ARE liftable with chopper like the CH-67 , but will not stay after restarts !
// _box = "Box_NATO_Support_F" createvehicle _pos;   //create a smaller crate, use either, not both

clearMagazineCargoGlobal _box;
clearWeaponCargoGlobal _box;
    clearItemCargoGlobal _box;
_box setVariable ["permaLoot",true]; //stay until reset
_box allowDamage false; // Prevent boxes to explode when spawning
_box addItemCargoGlobal ["MortarBucket", 4 + (random 2)];  // between 4-6
_box addItemCargoGlobal ["Cinderblocks", 8 + (random 4)]; // between 8-12
_box addItemCargoGlobal ["CircuitParts", (random 1)]; // between 0-1
_box addItemCargoGlobal ["ItemCorrugated", 2 + (random 3)]; // between 2-5
_box addItemCargoGlobal ["ItemCorrugatedLg", (random 2)]; // between 0-2
_box addItemCargoGlobal ["KitTipi", (random 2)]; // between 0-2
_box addItemCargoGlobal ["CSGAS", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["EnergyPackLg", 1 + (random 1)]; // between 1-2
_box addItemCargoGlobal ["KitShelf", 2 + (random 2)]; // between 2-4
_box addItemCargoGlobal ["KitFoundation", (random 2)]; // between 0-2
_box addItemCargoGlobal ["Chainsaw", (random 1)]; // between 0-1
_box addItemCargoGlobal ["KitCinderWall", 3 + (random 4)]; // between 3-7
};
Link to comment
Share on other sites

hey,

 

have there still a problem, crate spawn still in the water :(

 

but I once got an own packed post, is clearer

 

So if you can still help or would like to:

 

otherwise a lot of fun and thank you

Link to comment
Share on other sites

hey,

 

you could do a script for "spawn a group" in your addon ? The spawn a dude's already useful, but a spawn a group would be very very helpful :D a group where all have the same features...

 

that would be great :-)

 

with the crate I first gave up that will not over water :( I think to myself what different :D

 

Greez Suppe

Link to comment
Share on other sites

I'll do a group, and concentrate on funnies on them, like sitting around a campfire or something, just to show what's possible... In your own thread Suppe, I posted to have a sleep timer in it, didn't that work? I haven't checked yet since haven't had much time and fear all my servers and clients are on 1.40 now lol...

 

Will be continued....

Link to comment
Share on other sites

Hi Guys,

 

Question... I havet tryed to call a script under @epochhive/Addons from my MPMission (epoch.altis) init.sqf file, but it does not work... as well I created a admin menu at epoch.altis but I cant call a sqf located at pbo´s under @epochhive/addons, any ideia why ??? thanks!

Link to comment
Share on other sites

The MPMission PBO is actually the file that is sent to the clients; As far as I know (my knowledge is limited though) That stuff runs all client side and doesn't know server side functions.. When variables need to be shared from the client, they get broadcasted to all clients connected (via the server) but that's it... So something that is changed by your character in game, in a client side PBO, it broadcasts that to the server and from there to all clients so they get updated.

 

If you create stuff in MPMission PBO, make sure ALL that is needed is actually in that PBO!

 

I can try and help troubleshoot, if you go more detailed into what you did.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...