Home   Help Search Login Register  

Author Topic: Player Operated Salvage truck script needed  (Read 5545 times)

0 Members and 1 Guest are viewing this topic.

Offline ironcross

  • Members
  • *
Player Operated Salvage truck script needed
« on: 14 Dec 2007, 01:40:45 »
Hi ok well im still trying to tweak Sahrani life fro my friends who have less of a clue than me ( amazing its possible i know but true )  :D

Quote
nah i scraped that idea Spooners Scripts rock! SPON p0wnz Sahrani life scripts   :good:

well i did a search and checked though the FAQ for an ARMA related topic dident find any.  :dry:

any ways im more into Cfg editing so plz be Anally detaild in your explenation if some one would be so kind as to assist.

So i need help making or finding a "Player Operated Salvage truck script" that can work indapendantly, ( needs a command for driver only, "like spec ops" but to remove dead vehicles & place objects like fences ) im hoping just needs an Init field entry  to direct it to the script after placment on map.
if it had a small Respawn script embeded that would be prefect.
not sure if any one has this laying around  ;)

yours kindly mike.
« Last Edit: 15 Dec 2007, 14:19:40 by ironcross »
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Player Operated Salvage truck script needed
« Reply #1 on: 14 Dec 2007, 11:02:42 »
Mando tractor

Can be used for any vehicle dragging any other vehicle. :) I don't see why it couldn't drag slightly damaged vehicles as well (as long as their wheels roll). You need only slight knowledge of scripting to get it to work too, and like all of Mando's scripts, it's prolly 100% multiplayer compatible.

Really, it's a very nice script! Mando, get this baby into the ed.depot already.  :cool2:

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #2 on: 14 Dec 2007, 12:39:25 »
ah sorry maybe i wasent clear enough,

Its to be more like CTI salvage truck, but no addons  :-[ with a in vehihcle command like speed pimp in Sahrani life, just for 1 vehicle.
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Player Operated Salvage truck script needed
« Reply #3 on: 14 Dec 2007, 19:47:11 »
Code: [Select]
while {alive _this} do
{

     while {player in salvagetruck} do
     {
          _objects = salvagetruck nearObjects 10;
          _i = 0;

          while {_i != count _objects} do
          {

               if (damage (_object select _i) > 0.9) then
               {
               deletevehicle (_objects select _i);
               };
          };
     };
};

exit;

make an sqf file with that and put the execution in the trucks init field:

call {[]execVM "blah.sqf"}


surdus

ps, i havent tested this.
Campaigns are hard, I'll stick with scripting for now!

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #4 on: 14 Dec 2007, 22:32:08 »
Cool thanks so much man ! :good:

although i had an error.

i've added the picture & the SQF for u to see in the zip file

also i know im realy crap at being articulate, but i had hoped it would have an option in the action menue of the player who is driver.


& later once i get the SPON banking system working with my MP mode i hope some one would help me let the player make money with the truck :D


p.s
Code: [Select]
while {player in salvagetruck} would i need to change the name of player to say public_serviceman_1 for it to work for that selected player in MP?

Code: [Select]
_i = 0;
what the hell dose _i do?

yours kindly mike
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Player Operated Salvage truck script needed
« Reply #5 on: 15 Dec 2007, 02:02:28 »
further examination shows that the syntax is all wrong, it cannot be done without a decent method of detecting the dead.
Campaigns are hard, I'll stick with scripting for now!

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #6 on: 15 Dec 2007, 14:15:42 »
uhm .. :confused: so no one actuly has a script for this?  :blink:
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Player Operated Salvage truck script needed
« Reply #7 on: 15 Dec 2007, 14:38:21 »
you can do it by making a massive trigger detecting "anybody", and then put all the units positions into an array, however i do not know a way to pick out the correct position dymanically to work the way you like.  but if you use that method, there should be someone who knows how it can be done.
Campaigns are hard, I'll stick with scripting for now!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Player Operated Salvage truck script needed
« Reply #8 on: 15 Dec 2007, 14:45:40 »
I'm still not entirely sure what it is you're trying to achieve? Drive a truck around the island, and whenever it comes across a destroyed vehicle, it could "salvage" (=delete) it and maybe give the player some monetary reward or somesuch?

If this is for MP (=Sahrani Life), then this should be moved to MP editing first of all, because things like respawn, JIP and multiple clients and whatnot will probably mess things up royally and will require additional checks as opposed to a simple SP script. Secondly, you need to give a slightly better description of what you want the script to achieve:

Do destroyed vehicles respawn? Do all of them or only some? Is there a built in deleteVehicle script to keep the game clean? (if not, there should be!)

Do you want the vehicle to be able to salvage only -entirely- destroyed vehicles, or vehicles that are i.e. unable to move (!canMove) or that are slightly damaged?

Who can do the salvaging? Everyone? Or only certain units? Is the salvaging ability tied to a -vehicle- or a -player-? (i.e., if I buy a salvaging truck and someone steals it, can they still salvage stuff for profit?)

And finally, I have no idea how Sahrani Life manages its money system for instance (global vars? vehiclevariables? no idea...), so adding that part in I have no idea how to do.

To answer your question, no, there's no pre-existing script, but one could potentially be created albeit not necessarily very easily. :)

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #9 on: 15 Dec 2007, 17:21:35 »
well old man, im real sory for any problems i dont mean to be just trying to get somthign done with assistance of people who know more thane me & glean some understanding of it along the way.

if you think its ment for MP then u guese it should be, but it hought to begin with, i would try finding a basic script for SP then find out to adapt it with help to MP. (the core idea was to keep it simple to begin with.

As for Sahrani Life i'm NOT using that any more got a prety nasty email back when i  asked if they could tell me how to add somthing like this, or if they were going to add it.


So now im using SPOONERS script and any other scirpts i can have permission to use that will create somthing mre like what my friends are looking for, as i have a list of things they(and I) wanted changed,
that would then be hosted on there high bandwidth server.

im not deciding name though so, im not sure what its going to be called. :blink:

But the general concensus was that:
  • there needed to be WAY more LEGAL civilian jobs
  • the mission needs to be more friendly for moderators & clan members to edit & update (which sahrani life aint & the Sahrani life team wont even aknowledge that there are certain bugs. so somthing has to be done)

Quote
I'm still not entirely sure what it is you're trying to achieve?


at this point just trying to get a generic vehicle (dont even need to be truck lol, that anyone who is driving can delete dammaged or destroyed vehicles infront of it within say a 30 degree arc.

This stage of the scripts Goals is;
  • Simple usage of Init from game editor to call the script
  • The Script is only to be accessable from inside the vehicle preferably the driver.
  • add an extra action in action menue (no fancy menues neeed at the mean time) this action shoudl be accessable by driver only.
  • the action should delete any wheeled/tracked or air vehicle infront of it, whether its damaged or not.

2nd stage is MP & i intended to make this anotehr thread in MP i dident exspect you chaps to be so ...shall we say exact :scratch:

although this is cool :D

I will try to answer some of your questions but im no expert thats why im humbly asking for asistance.

Code: [Select]
Do destroyed vehicles respawn? Do all of them or only some? Is there a built in deleteVehicle script to keep the game clean? (if not, there should be!)

Destroyed vehicles do not respawn & there is no intention of it being so(for any of them.

There is no delete vehicle script, as this is intended to be one of the JOB(s) for the player who owns the vehicle, to make some doe.  :D

although i do intend to add a script that cleans up body's any suggestions? (OT i know but since you asked)  ;)

Code: [Select]
Do you want the vehicle to be able to salvage only -entirely- destroyed vehicles, or vehicles that are i.e. unable to move (!canMove) or that are slightly damaged?

The vehicle is intended to delete all vehicles regardless of status, as it would get to complex,(also i have seen locked vehicles sitting on 955i server for over 3 days & it cant be moved, this can ruin game) however if the player should get out of control its expected the police would solve the problem with jail or some lead i know what they will prefer  :P (edit) it might be better if i made this only obtainable at police stations.

Code: [Select]
Who can do the salvaging? Everyone? Or only certain units? Is the salvaging ability tied to a -vehicle- or a -player-? (i.e., if I buy a salvaging truck and someone steals it, can they still salvage stuff for profit?)
any player (for now) as i hope to add a lock vehicle script later when i find it, but one thing at a time cant build a castle upside down now can i? :)

as for making money with it well, the money system is SPON's money system but i dont realy need it tied into it for now, unless you can tell me how & where to add things?

Code: [Select]
And finally, I have no idea how Sahrani Life manages its money system for instance (global vars? vehiclevariables? no idea...), so adding that part in I have no idea how to do.

Im not using Sahrani life any more like i stated above.(after an edit) but i know what you mean its very complex if not overly.also its in german  :blink:

So thanks for showing me the weakness of my request , you cant learn  without making at least some  mistakes & having them pointed out & explained in constructive detail thanks honestly. :good:

so i feal like a Terminator who just learned how to smile..  :dry:
lol

yours kindly mike. (still praying for a script pixy to bail me out)
« Last Edit: 15 Dec 2007, 17:32:57 by ironcross »
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #10 on: 17 Dec 2007, 14:40:27 »
ok well i found some scripts i dont know if they will work properly i tried calling them but with no luck.

these are from KP CTI.

here is one it looks kinda like Surdus Priest's

from "delete vehicle SQS"

Code: [Select]
_veh = _this select 0

#loop
_water = surfaceIsWater [getpos _veh select 0,getpos _veh select 1]
~30
?(_water) :  goto "delete"
?!(alive _veh) : goto "loop"
~3
#delete
deletevehicle _veh

& this one if from "add action sqs", i think maybe this is what lets player call script from vehicle???

Code: [Select]
_veh = _this select 0
_side = _this select 1
_class = typeof _veh

_veh addEventHandler ["killed", {_this exec "server\delete_veh.sqs"}]
_Veh addAction ["Toogle score","player\toogleScore.sqs"];

?(_Class in rearmvehicles) : _Veh setAmmoCargo 0
?(_Class in repairehicles) : _Veh setRepairCargo 0
?(_Class in refuelvehicles) : _Veh setAmmoCargo 0

?!(side player == _side) : Exit


?(_Class in sterovehicles) : _Veh addAction ["Play music","player\OpenMusicDialog.sqs"];

?(_Class in repairvehicles) : _Veh addAction ["Repair vehicles","player\OpenSupportDialog.sqs"];
?(_Class in rearmvehicles) : _Veh addAction ["Rearm vehicles","player\OpenSupportDialog.sqs"]; _veh addAction ["Kit menu","player\OpenWepDialog.sqs"]
?(_Class in refuelvehicles) : _Veh addAction ["Refuel vehicles","player\OpenSupportDialog.sqs"];
?(_class in CommanderVehicles) : _veh addAction ["Commander menu","player\OpenCommanderDialog.sqs"];_veh addAction ["Redeploy menu","player\OpenRedeployDialog.sqs"];

the rest of scripts that looked like it has somthing to do with the salvage truck is in the zip, hope some one can help me sort this out.
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Player Operated Salvage truck script needed
« Reply #11 on: 17 Dec 2007, 18:17:37 »
find a script from one of the cti or minibf games.

these scripts will have a timer on them before they make dead units dissapear. 

modify one of them to that they can only dissapear when the truck is near them.  that way instead of when an object is near the truck, make it so they dissapear when the truck is near the object.
Campaigns are hard, I'll stick with scripting for now!

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #12 on: 18 Dec 2007, 14:04:39 »
 :blink:


Code: [Select]
minibf games  ???


I have reasonable understanding of cfg code but i can only identify, say 1 line out of 8 or 9 atmo. so how the heck am i supposed to do what you suggest lol. (& i dont have time to spend a year learning how sqf & sqs files are written? :P )

thanks for trying, although i suspect your about 3-5 months ahead of me in terms of learning  ;)
« Last Edit: 18 Dec 2007, 14:14:07 by ironcross »
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Player Operated Salvage truck script needed
« Reply #13 on: 18 Dec 2007, 15:44:51 »
How about this:

Each vehicle needs to have a "killed" eventhandler assigned to it, like in your example there. Each vehicle will use that eventhandler to run a script that loops for all eternity/until someone comes and saves it. Since it seems like KP CTI has a built-in "if vehicle is in water, destroy it" script, we might as well retain that. I don't know how you're spawning vehicles and such in your game, but whatever the case, be sure this is added to them somehow:

Code: [Select]
vehicleName addEventHandler ["killed", {_this addAction ["Salvage vehicle", "salvage_truck.sqf"]}];
Now as to the salvage_truck.sqf script, it could look something like this.  :

Code: [Select]
//salvage_truck.sqf by Wolfrug @ OFPEC

_veh = _this select 0;
_caller = _this select 1;
_id = _this select 2;

// Check if the caller is inside the salvage truck, and that it's close enough.
if (vehicle _caller !=Salvage_Truck) exitWith {hint "You need a salvage truck for that!"};
if ((vehicle _caller distance _veh) > 10) exitWith {hint "You need to be closer to salvage the vehicle!"};

hint "Salvaging in process";

//Sleeps 5 seconds, if the salvage truck has moved away during that time the salvaging won't work
sleep 5;
if ((vehicle _caller distance _veh) > 10) exitWith {hint "You need to be closer to salvage the vehicle!"};

//Succesful salvaging. Removes vehicle, and adds some rating to the caller (might want to change that to whatever money or what you want.
_veh removeAction _id;
deleteVehicle _veh;
_caller addRating 1000;
hint "Salvaging complete!";

Untested, but should work? :) Try it by putting down an empty vehicle, writing the above in its init field and then blowing it up: should produce the action which might or might not work. Remember to have a vehicle named Salvage_Truck or it won't work (there are alternatives to this, such as having an array of salvage trucks, or using a certain type of truck (typeOf command) as universal salvage trucks, or even applying local variables that are read via the script. All depends on how you want it to work). Good luck!

Wolfrug out.
 
"When 900 years YOU reach, look as good you will not!"

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #14 on: 18 Dec 2007, 17:41:47 »
Problem is that the KILLED handler is only run on the machine where the destroyed vehicle is local, so most, if not all, people won't see the action. Just one of the long list of MP-issue reasons why I haven't stuck my nose into this thread so far. Also, when you try to delete the vehicle, the likelihood is that it will be on the server, not on the local client, so it will ignore deleteVehicle.

As you are using SPON Core anyway if you are using SPON Money, you can:
Code: (init.sqf, after SPON Core has been initialised) [Select]
// Pick up on requests to add the action, when the vehicle is destroyed.
["addSalvageAction",
    {
        _vehicleName = getText(configFile >> "CfgVehicles" >> (typeOf destroyedVehicle) >> "displayName");
        _label = format ["Salvage %1", _vehicleName];
        destroyedVehicle addAction [_label, "salvage_truck.sqf"];
    }
] call SPON_addEventHandler;

// Pick up on requests to destroy the vehicle when it is salvaged.
["removeSalvagedVehicle",
    {
        deleteVehicle vehicleToSalvage;
    }
] call SPON_addEventHandler;

Code: (addSalvageHandler.sqf) [Select]
// Call this in every vehicle init with:
//  nil = [this] execVM "addSalvageHandler.sqf"
_vehicle = _this select 0;

_vehicle addEventHandler ["killed",
    {
        destroyedVehicle = _this select 0;
        ["addSalvageAction", []] call SPON_publishGlobalEvent;
    }
];


Code: (salvageTruck.sqf) [Select]
//salvage_truck.sqf by Wolfrug @ OFPEC
//Adapted by Spooner

_veh = _this select 0;
_caller = _this select 1;
_id = _this select 2;

// Check if the caller is inside the salvage truck, and that it's close enough.
if (vehicle _caller !=Salvage_Truck) exitWith {hint "You need a salvage truck for that!"};
// Don't need to check range at this point, since actions only have a range of about 5m.

hint "Salvaging in process";

//Sleeps 5 seconds, if the salvage truck has moved away during that time the salvaging won't work
sleep 5;

// Check that everything is still available and ready for salvaging, after the sleep
if ((isNull _veh) or (not (canMove Salvage_Truck)) or (not (alive _caller))) exitWith {};

// Check the guy is still in the truck (though life is too short to care about him getting out and in again).
if (vehicle _caller !=Salvage_Truck) exitWith {hint "You need a salvage truck for that!"};

if ((vehicle _caller distance _veh) > 10) exitWith {hint "You need to be closer to salvage the vehicle!"};

//Succesful salvaging. Removes vehicle, and adds some rating to the caller (might want to change that to whatever money or what you want.
_veh removeAction _id;

// Get the vehicle removed locally.
if (local _veh) then
{
    deleteVehicle _veh;
}
else
{
    vehicleToSalvage = _veh;
    ["removeSalvagedVehicle", []] call SPON_publishGlobalEvent;
};

_caller addRating 1000;
hint "Salvaging complete!";

Code: (vehicle init) [Select]
nil = [this] execVM "addSalvageHandler.sqf";

Again, this is untested code, so fingers crossed that it does what you need it to. The issue is that to deal with this properly is non-trivial and even with a reasonably involved answer, I've no doubt there are still MP/JIP issues unresolved ;(

EDIT: Corrected typos in scripts.
« Last Edit: 19 Dec 2007, 02:05:31 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)