Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #15 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
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #16 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
« Last Edit: 19 Dec 2007, 02:20:27 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #17 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)
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #18 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);
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #19 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"],
« Last Edit: 19 Dec 2007, 15:38:21 by ironcross »
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #20 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)...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #21 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)
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 #22 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.
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Player Operated Salvage truck script needed
« Reply #23 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
I know a little about a lot, and a lot about a little.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #24 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.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #25 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!

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

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #26 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).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #27 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.
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Player Operated Salvage truck script needed
« Reply #28 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).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline ironcross

  • Members
  • *
Re: Player Operated Salvage truck script needed
« Reply #29 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..
« Last Edit: 14 Jan 2008, 01:06:29 by ironcross »
ANY scripts or textures I use will be given DETAILED Acknowledgment's when help or scripts are used.