Home   Help Search Login Register  

Author Topic: Checking if my addon is alive?  (Read 1094 times)

0 Members and 1 Guest are viewing this topic.

addonfreak

  • Guest
Checking if my addon is alive?
« on: 30 Oct 2004, 22:45:32 »
Hi guys,

I am making a truck and a trailer. These are separate .pbo files and the truck will tow the trailer. I use a towing script, which is included in trailer's .pbo and activated through class user actions. A yellow user menu, "Connect Trailer", appears, when player gets close to the trailer. Here you can check the related lines below. It is from config.cpp of the trailer. I defined everything in config.cpp of the trailer.

class useractions
   {
   class connectTRAILER
                 {
                displayName="Connect Trailer";
                position="axis_connect";
                radius=6
                condition="(nearestobject [this, ""TRUCK550""]) distance this < 10 and alive this and this animationphase ""ani_connection"" == 0";
                statement="[nearestobject [this, ""TRUCK550""],this,1.9,.19] exec ""\TRUCK550\tow.sqs""";
   };
   class disconnectTRAILER
                {
                displayName="Disconnect Trailer";
                position="axis_connect";
                radius=6
                condition="(nearestobject [this, ""TRUCK550""]) distance this < 10 and alive this and this animationPhase ""ani_connection"" >= 0.5";  
                statement="this animate [""ani_connection"", 0]";
   };

Now you see when the user menu appears...

Here, I want to add a condition statement for this user action menu, so when the truck is not alive, the corresponding user menu, "Connect Trailer", doesn't appear anymore!

How can I write this conditon to open this menu if the nearest truck550 is alive? I don't know this strange language!  :-\

You know, I can't use global variables cause if I use, problems arise when there are more than one couple of the same addon, in the game!


I tried this below, but it doesn't work. I know it looks funny and weird :) but you can get the point! :D can you correct it?

                class connectTRAILER
   
                condition="[alive [(nearestobject [this, ""TRUCK550""]) distance this < 10]] and alive this and this animationphase ""ani_connection"" == 0";
               
                class disconnectTRAILER
               
                condition="[alive [(nearestobject [this, ""TRUCK550""]) distance this < 10]] and alive this and this animationPhase ""ani_connection"" >= 0.5";  


Regards
       

Lean Bear

  • Guest
Re:Checking if my addon is alive?
« Reply #1 on: 30 Oct 2004, 23:29:09 »
OK, a bit confusing your config is, but here's a few ideas to help you out:

First, I think there should be a ";" after the line "radius = 6"

Next, to check if the truck is alive, you'll need something like this:

not(alive TruckName) //in the config.

I reckon that's the bit of syntax you're missing. ;)

addonfreak

  • Guest
Re:Checking if my addon is alive?
« Reply #2 on: 02 Nov 2004, 15:06:19 »
Hi again,

Yours didn't work. But I got the point on my own!  :D Now it's smooth :)

Thanks again...