OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ironcross on 14 Dec 2007, 01:40:45

Title: Player Operated Salvage truck script needed
Post by: ironcross 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.
Title: Re: Player Operated Salvage truck script needed
Post by: Wolfrug on 14 Dec 2007, 11:02:42
Mando tractor (http://www.ofpec.com/forum/index.php?topic=30032.0)

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.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross 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.
Title: Re: Player Operated Salvage truck script needed
Post by: Surdus Priest 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.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross 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
Title: Re: Player Operated Salvage truck script needed
Post by: Surdus Priest 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.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 15 Dec 2007, 14:15:42
uhm .. :confused: so no one actuly has a script for this?  :blink:
Title: Re: Player Operated Salvage truck script needed
Post by: Surdus Priest 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.
Title: Re: Player Operated Salvage truck script needed
Post by: Wolfrug 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.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross 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:

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;

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)
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross 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.
Title: Re: Player Operated Salvage truck script needed
Post by: Surdus Priest 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.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross 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  ;)
Title: Re: Player Operated Salvage truck script needed
Post by: Wolfrug 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.
 
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner 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.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 19 Dec 2007, 01:37:48
 :yes: NICE THANKS Wolfrug !  :good:


I did as you said but it just dident seem to run, but i cant thank you enough for helping/basicly doing it for me (because i dont know how) ;)


wow Spooner i dident realise how diverse your scripts are!  :blink:  :good:

& i realise now what you were all trying to tell me, sorry i guese im another one of those granit heads, your all right i needed to choose between MP OR SP not 1 & upgrade as they are totaly different im sorry, :-[

OK spooner i tried the upgrade you added & i can see how much a pain in the ares this is becoming, i realy thought it was (already done because of CTI/ or easy ish to a scripter to do).

i tried what you told me as best i could understand, i think the structure is right, but i aint familiar with it so ill post the mission so far.

i had 2 small probs,

Code: [Select]
      destroyedVehicle = _this select 0;
            ["addSalvageAction", []] call SPON_publishGlobalEvent;
        }
    ];
};

it came up with missing "{"
 so i changed it to,
Code: [Select]
      destroyedVehicle = _this select 0;
            ["addSalvageAction", []] call SPON_publishGlobalEvent;
        }
    ];
{

};

and no probs. but i dunno if that was right but it seemed to stop error.

2nd was it wouldent let me add
Code: [Select]
[this] execVM "addSalvageHandler.sqf"; so i changed it to
Code: [Select]
call {[]execVM "addSalvageHandler.sqf"}

havent tried it in MP yet though,

here is mission as is
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 19 Dec 2007, 02:01:12
Oops, a typo there, since I added a spurious }. It should have been (I've changed the original, so as not to give bad advice to future readers):
Code: [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;
    }
];

2nd was it wouldent let me add
Code: [Select]
[this] execVM "addSalvageHandler.sqf"; so i changed it to
Code: [Select]
call {[]execVM "addSalvageHandler.sqf"}

Sorry, I always forget to write that out properly, as object init requires that the result of execVM is assigned to something. We don't care what the result it (the result is the running script itself, not what is returned by the script) so we can just ignore this value by assigning it to nil:
Code: [Select]
nil = [this] execVM "addSalvageHandler.sqf";
Sorry, those errors were sloppy, especially since you aren't an experienced enough scripter to correct my dumb typos. I was being lazy and not testing the code, since I was trying not to get too sucked in to doing this whole script ;P
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 19 Dec 2007, 02:37:55
(THANKS REALY) Hey well thats my angle, suck in the pro's because i made a promise that in no way can i keep by myself  :-[ ( so its kinda like fragmented pass the parcle....)  :D
although with Thomases help & OFPEC's (realy Spooner) help lol i will be posting the credits as

scripts:
OFPEC
Spooner, etc.

Director Thomas

class A Leech & shifty guy in the background Iron+Cross  :P

OK i did every thing you have said and the fecker still aint working, so say your scripts work fine maybe i did set it up wrong...

is this how its ment to go in the init.sqf?


i havent touched anythign in the money sqf so im hopeing its like u want & i just messed somthign else up..

Code: [Select]
["DEBUG_CLIENT_SERVER"] call compile preprocessFileLineNumbers "SPON\Core\initCore.sqf";
//SPON-Wolfrug salvage truck script call OFPEC
// 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;

// -----------------------------------------------------------------------------
// SPON Money demonstration - Money, shopping and banking.
//

[
["examplePrices.sqf"],
"$", // Use dollars as currency.


sorry im keeping you up its no hastle lol i dont give up till im happy its done so you coudl get abck to it in a few days no hastle. :D (which we know it is )

..so this is just the salvage truck... wait till i ask em about the space ship..(joke)
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 19 Dec 2007, 02:52:53
That init.sqf looks fine to me. All you needed to do was ensure the calls to SPON_addEventHandler were after SPON Core was initialised, since that package defines that function.

I should have gone to bed some time ago, otherwise I'd try this out properly. What I'd suggest in the meantime is to add some hints to trace what is going on, though that can only display messages if it is run on the client (or work out how to use the SPON_TRACE_* macros to send messages from the server and client to the SPON debug log which is included in SPON Core; might as well get the most out of it :whistle:).
Code: [Select]
#include "SPON\Core\debug.inc.sqf"
SPON_TRACE("Simple message");
SPON_TRACE_3("Trace 3 variables:",_fish,_frog,_cheese);
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 19 Dec 2007, 14:58:47
Hi, ok i tried SPON debug but it seems like id need more understanding of all the symbolism in general SQF scripts before id be able to use it to its fullest potential although i can see it would make it ALOT faster debuging if i could use it :D (I realy hope that SPON tools will be compatable with ARMA 2) :clap:

So what ive done is used the Hint method you suggested.
 1st script i tested was the "Salvage truck script".
However none of them seemed to show up at all when i got in truck & drove it over to preset destroyed vehicle, then i blew up a normal car with AGS30 & drove truck up to check if its starting up script at all but no luck. :dunno:

conclusion: SalvageTruck.sqf dose not even start up by looks of things, & i used 
Quote
nil = [this] execVM "addSalvageHandler.sqf"
in the Init of vehicle, & even named vehicle Salvage_truck (tried it without name to.
Code: [Select]
//salvage_truck.sqf by Wolfrug @ OFPEC
//Adapted by Spooner

_veh = _this select 0;
hint "line 22 check";
_caller = _this select 1;
hint "line 24 check";
_id = _this select 2;
hint "line 26 check";
// 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;


OK here is the check of the "addsalvagehandler.sqf" I added 2 checks the 1st "line check 20" dont seem to work?? possible problem?
but line check 26 shows up fine. no obseravle errors.

Code: [Select]
_vehicle = _this select 0;
hint "line 20 check";
_vehicle addEventHandler ["killed",
    {
        destroyedVehicle = _this select 0;
        ["addSalvageAction", []] call SPON_publishGlobalEvent;
    }
];
hint "line 26 check";

ok i  did same for thsi see code, result was nothing showd up, i dont understand... :dunno:
Code: [Select]
["DEBUG_CLIENT_SERVER"] call compile preprocessFileLineNumbers "SPON\Core\initCore.sqf";

//SPON-Wolfrug salvage truck script call OFPEC
// 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;
hint "line check 5-17";
// -----------------------------------------------------------------------------
// SPON Money demonstration - Money, shopping and banking.
//

[
["examplePrices.sqf"],
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 19 Dec 2007, 19:28:08
OK, you need to put:
Code: (vehicle init) [Select]
nil = [this] execVM "addSalvageHandler.sqf";

On each of the vehicles that can be salvaged, NOT on the salvage vehicle itself (though if you want the salvage vehicle to be itself salvageable, then add it there, too).

I mis-typed the name of the salvage action file, so you should have:
Code: (init.sqf) [Select]
    destroyedVehicle addAction [_label, "salvageTruck.sqf"];

in the init.sqf (I originally put "salvage_truck.sqf").

Never good to give untested code to someone who is a beginner and can't fix the "more obvious" mistakes. I should know better; Sorry!

I found, however, that vehicles don't always have the salvage action available when you are in the tractor and that sometimes you needed to exit and re-enter the tractor to get that to work. I'm considering alternative methods of managing salvage because of this (unless there is an easy way around this problem)...
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 19 Dec 2007, 22:01:00
i apear to beyond retarded... :yes: :D im sorry i wasent born with enough brain cells  :no:

as for
Code: [Select]
destroyedVehicle addAction [_label, "salvageTruck.sqf"];i should have noticed this myself as thats the sort of thing i miss when im editing the cfg of my vehicles/units.  ::) sorry again & TANK you!

any ways you had a right to miss it i dident realise the time lol.

so it works i did as you say & im sorry i made it this situation,
but OFPEC thanks to you(Spooner), Surdus Priest , & last but not least! Wolfrug  :clap: :good:

below is a simple demo mission with the scipts of a semi-functional Salvage vehicle script set.

i cant thank spooner & all you chaps  enough lol  :-[  :P ill nag u guys in 2-3 days  about the  some of the bugs,   :blink:  :D seeya (small trip)
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 01 Jan 2008, 22:25:51
Hey Happy Christmass & Merry new Year to all!  :clap:

ok well i havent even looked at trying to figure out what these problems are yet, but i will try tomorrow,

So what im talking about is, a test we (Fenix from Field assasins & myself) tested on their dedicated server, we tried the mission, but ran into problems.(some could be to do with the spawn script not sure yet just listing it b4 i forget).

got the following problems (3 all together);

Code: [Select]
error '|#|<Null-object' (and under this was) error invalid number in expressions.this seemed to happen when Racs soldier in the SPON money demo mission (modified) kills US medic.

Code: [Select]
"schalar[#] bool array string oxe0ffffef error missing ;"
this happend when  the admin changed player slots  on dedicated server.

& lastly the Tractor slavage truck just totaly dident work in mp lol as you thought.

but Fenix, the owner of the server (Field Assasins) seemed to be looking for an alternative to Sahrani life lol so he even got started on some textures for flag's for the new mission & lseemed to like your easy to understand system, for admins to modify...


any ways i hope you all had a good one & ill get back later.

yours kindly mike!

p.s  thanks to Fenix i shuld be able to test the mission within 48hrs now on a dedicated server.
Title: Re: Player Operated Salvage truck script needed
Post by: Planck on 02 Jan 2008, 02:42:07
I don't think you can use the minus sign in a variable name, so 'Null-object' would not be valid.

The second error seems to imply that one of your script lines is missing a ';' at the end.



Planck
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 02 Jan 2008, 03:52:09
What Planck says is true, but it doesn't really explain why you are getting those errors :P

"<Null-object>" is what you get when you convert objNull to a string using format or str. I'm assuming that you are trying to put the varname of an object into a string which you are compiling and running, but the object variable is null when you convert it to a string and "<Null-object>" is not understood when you attempt to compile the string.

"schalar bool array string oxe0ffffef" is what you get when you convert an undefined variable (one that hasn't been set to any value) to a string using format or str. The error implies that you are trying to compile that string, as in the previous error, which isn't understood by the compiler.

In both cases, it is difficult to give more meaningful fixes without knowing more about the code that is being run and where the error is occurring.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 04 Jan 2008, 14:26:12
ok let me try & put tyour explenation in my wording & tell me if im close so i can understand better.
 (as i dont like having to bother peopel about every bloody thing all the time, as when i figured out how to bugfix myself for addon cfg's i rarely had to bother people & it felt better so bare with).

Quote
"<Null-object>" is what you get when you convert objNull to a string using format or str. I'm assuming that you are trying to put the varname of an object into a string which you are compiling and running, but the object variable is null when you convert it to a string and "<Null-object>" is not understood when you attempt to compile the string.

ok so this means to say that if i place this section of code in a vehicle's init
Code: [Select]
nil = [this] execVM "addSalvageHandler.sqf";   And in perticular the [THIS] part instead of making a list of all vehicles that are to have this code  linked to?
so would this mean that like the Spawn script im using it is linked to Each individualy named player, that has a corasponding name in the script?? & if it dosen it mean that its a variable that cant be understood when actuly being used in mp/lan???  :blink: ok i hope that was somwhere on the same planet... :dunno:

but since i haave currently no idea where this errors are coming from, unless i send u the whole thing again lol, its not going to be found unless i can get a rough idea of what kind of problem could be causing this.


yours kindly Michael thanks again for any/all replys!

Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 04 Jan 2008, 19:02:15
OK, I had no idea what you were talking about when you tried to re-explain what I said, so I'll assume you didn't understand. These errors are almost certainly created by dynamic code that is being given dodgy variables, such as:
Code: [Select]
_frog = 10;
call compile format ["_fish = %1", _frog]; // The string is formatted to "_fish = 10", which is then compiled and run, setting the value of _fish as expected.

However, when doing this sort of dynamic code translation, errors are easy to introduce:
Code: [Select]
_frog = 10;
call compile format ["_fish = %1", _treeFrog];
Since _treeFrog is undefined, the string is formatted to "_fish = schalar bool array string oxe0ffffef", which is nonsense in SQF and causes an error when it is compiled (though "_fish = schalar;" would make sense and is why it suggests you might have missed out a semi-colon at this position).

The problem with "<Null-object>" is similar, and is caused by compiling a string that contains an object that is null (probably caused by the object having being deleted beforehand). The example code isn't realistic, just being a simple example to explain a point:
Code: [Select]
// soldier is a game object that has been given a name in the editor.
deleteVehicle soldier;
call compile format ["_fish = %1", soldier];
Since soldier is null after it has been deleted, the string will be formatted as "_fish = <Null-Object>" which is again gibberish to the compiler and causes an error. If soldier hadn'y been deleted, it would be formatted as "_fish = soldier" which would have run correctly.

Ultimately though, we can't debug code that we can't see, except to give general guidelines as to what might be causing the error. If you don't understand exactly what the code you are running does, then you will usually find it very hard to debug, even given plenty of advice from us (unless it is an general problem like forgetting a semi-colon). You are using a number of scripts together, as well as code that we have given you in this thread, as well as your own code to glue it all together... The error could well be in any part of this melange, including something in SPON Money or the SPON Money demo, or due to an unexpected interaction between scripts or your changes to them. At this point, you probably need to attach the full mission for us to look at, since anything could be going wrong at this point (and anything involving dynamic code is usually harder to debug).
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 05 Jan 2008, 13:11:25
OK i see what you are saying, im not good at geting stuff in my head into words tbh..(that explains the issues with females.) :D

But what i was trying to say was what u said, so to me it seems similar to  making custom ammo & magazines in config files. (better comparison?)

Code: [Select]
The error could well be in any part of this melange, including something in SPON Money or the SPON Money demo, or due to an unexpected interaction between scripts
this is why i was trying to get a better idea of where the error could be coming from so i woudlent have to dump the whole lot on you  :-[ (trying to do some of the work lol)

but i havent modified much of the SPON scipts at all, just sifted through them.. & added some money.

ill add it youl see what i mean.. & looking for that missing ";" is like a needle in a hay stack lol.  i take it if i could figue out your debug script it would help alot ?

thanks again yours kindly mike.
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 11 Jan 2008, 18:09:34
OK, the fault here is mine, since I forgot to publicVariable some values, which is why they were undefined when they were required later. At this point, though, I think you'd be better off ditching SPON events since SPON events, although "a workaround for 1.08" are more messy to use than the publicVariable events which are added in ArmA 1.09 beta.

In init.sqf:
Code: [Select]
//SPOONER-Wolfrug salvage truck script call OFPEC
// Pick up on requests to add the action, when the vehicle is destroyed.
// This is a separate function, since that makes it easier to call normally AND use as an event handler.
addSalvageActionHandler =
{
    _destroyedVehicle = _this;
    _vehicleName = getText(configFile >> "CfgVehicles" >> (typeOf _destroyedVehicle) >> "displayName");
    _label = format ["Salvage %1", _vehicleName];
    _destroyedVehicle addAction [_label, "salvageTruck.sqf"];
};

"addSalvageAction" addPublicVariableEventHandler { (_this select 1) call addSalvageActionHandler };

] call SPON_addEventHandler;

// Pick up on requests to destroy the vehicle when it is salvaged.
"vehicleToSalvage" addPublicVariableEventHandler { deleteVehicle (_this select 1) };

In salvageTruck.sqf, replace:
Code: [Select]
    vehicleToSalvage = _veh;
    ["removeSalvagedVehicle", []] call SPON_publishGlobalEvent;

with:
Code: [Select]
    vehicleToSalvage = _veh;
    publicVariable "vehicleToSalvage";

AddSalvageHandler.sqf should contain:
Code: [Select]
_vehicle = _this select 0;
_vehicle addEventHandler ["killed",
    {
        _destroyedVehicle = _this select 0;

        // Add action locally, by calling the function directly.
        _destroyedVehicle call addSalvageActionHandler;

        // Add action on all remote machines by using publicVariable event.
        addSalvageAction = _destroyedVehicle;
        publicVariable "addSalvageAction";
    };
];

(this code is off the top of my head, so don't make massive efforts with it if it doesn't work! I'll test it myself this weekend, but I have put it here in case you want to try it yourself).
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 13 Jan 2008, 22:01:18
sory for delay my end cant thank you enough as always   :P the boys of  field assasins server  were looking forword to testing it later just told em & im ading it now.. (wish i coudl say my understanding has  went much further than editing since last time  :-[  but your  hints help ALOT ) thanks again!

p.s we will test it later tonight.

yours kindly Michael.

--------------------------------------------------------------------------------------------------------------------
Update!

ok well i got this error in SP testing & MP with obviously no "salvage action" in sp or a lan test so i canceld the mp test lol..

Code: [Select]
'...vageTruck.sqf"];
};

"addslavageaction" |#|addpublicvariableEventhandler { (_this...'
error missing ;
File C:\yada yday yada yada init.sqf, line 14

ill try fixing this myself just posting it so i remember what i did..& incase i cant fix .

UPDATE 2

ok i looked at it & coudlent find where to put the (;)
not the same as cfg's yet again lol.

any who the start of  CIVs V4 inits looks like this now
Code: [Select]
["DEBUG_CLIENT_SERVER"] call compile preprocessFileLineNumbers "SPON\Core\initCore.sqf";

//SPOONER-Wolfrug salvage truck script call OFPEC--------------------------------
// Pick up on requests to add the action, when the vehicle is destroyed.
// This is a separate function, since that makes it easier to call normally AND use as an event handler.
addSalvageActionHandler =
{
    _destroyedVehicle = _this;
    _vehicleName = getText(configFile >> "CfgVehicles" >> (typeOf _destroyedVehicle) >> "displayName");
    _label = format ["Salvage %1", _vehicleName];
    _destroyedVehicle addAction [_label, "salvageTruck.sqf"];
};
"addSalvageAction" addPublicVariableEventHandler { (_this select 1) call addSalvageActionHandler };

] call SPON_addEventHandler;

// Pick up on requests to destroy the vehicle when it is salvaged.
"vehicleToSalvage" addPublicVariableEventHandler { deleteVehicle (_this select 1) };


// -----------------------------------------------------------------------------
// SPON Money demonstration - Money, shopping and banking.
//

[
["examplePrices.sqf"],
"$", // Use dollars as currency.
{ 50 }, // Always $50 in pocket.
{ if (playerSide == WEST) then { 100000 } else { 50000 }; }, // Americans have more money in the bank.
0.5 // You keep 1/3 of cash when you respawn.
] execVM "SPON\Money\initMoney.sqf";

any who of to bed for me.

yours kindly Michael.

p.s i did mess about with sector  control for a LITTLE fun :D tell me what u think..
Title: Re: Player Operated Salvage truck script needed
Post by: Wolfrug on 14 Jan 2008, 08:16:59
Just as a quick question: you DID use the 1.09 BETA for this, right? Since addPublicVariableEventHandler is a 1.09-specific command, and if you tried to run it with 1.08 it'd probably give you some kind of error like the one above.

Otherwise, I don't know :D It's all "Spoonerish" to me!

Wolfrug out.
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 14 Jan 2008, 14:42:36
ahh well i dident think about that  after i thought shurely he woudlent do this because the server dosent run this, & i wouldent be able to test it  :blink: .


ok ill wait till the full 1.9 is out as ive always had bad problems with beta's with flashpoint engine lol

but if it works thats great!

thanks again guys! & ill get back to you when i can get the guys on Field assasins server to upgrade & test it.
Title: Re: Player Operated Salvage truck script needed
Post by: Spooner on 14 Jan 2008, 21:47:25
Oops, I did clearly say that the change to using addPublicVariableEventHandler was for 1.09 beta, which most servers and people I'm aware of are using. Didn't think to ask whether you were using this patch at all...It just seemed like flogging a dead horse trying to fix an ugly workaround to handle events when the "real" event handlers were now available, which would make the solution more simple as well as work more of the time (SPON Events are fine, but when you have to use a separate publicVariable to send data types that they don't support, they can sometimes not work properly).

EDIT:
To continue in the 1.08 idiom, the publicVariable that I mentioned that I had forgotten was in "addSalvageHandler.sqf":

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;
        publicVariable "destroyedVehicle";
        ["addSalvageAction", []] call SPON_publishGlobalEvent;
    }
];
Title: Re: Player Operated Salvage truck script needed
Post by: ironcross on 18 Jan 2008, 12:15:02
I know u did m8 i was just in a rush to try it out lol  :D

but i cant thank you chaps (specialy Spooner) for the help!! & i will try it as soon as we get somthing worked out with (FA) chaps.  ;)

p.s i found some people trying the 1st version i was testing with your money system they were just playing with the airfield demo lol DM or somthing..i dunno what they were trying to do with the bank lady though.. :blink: (youd think they never saw a female in arma b4 lol )