OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: NightJay0044 on 07 Sep 2008, 22:23:58

Title: Script wont work, very simple but..
Post by: NightJay0044 on 07 Sep 2008, 22:23:58
Hi I'm trying to get this very simple script to work. Here it is, the player walks up to a jeep, he is  a couple feet away, an action appears on the action menu to "destroy" the jeep through a script. Here is what I have in the init field of the player.


INIT: ("aP" is name of the player)
Quote
Ap addaction ["destroy","distance.sqs"]

MY SCRIPT: (T1 is name of the jeep)
Quote
aP distance T1 < 2; goto "blowup"

#blowup
T1 setdammage 0

Ap removeaction destroy

Exit

Funny thing is, the action appears on the action menu, I press it and the script produces no errors but here's the problem. Nothing works at all. The jeep doesn't get destroyed and the action doesn't get removed, so where did I go wrong?

Thanks for the help.


Title: Re: Script wont work, very simple but..
Post by: Gcfungus on 08 Sep 2008, 00:10:42
With actions, it's easier to assign them names, rather than numbers.
So, you could add this:
Code: [Select]
destroy = aP addaction ["destroy","distance.sqs"]Also, the script needs changing:
Code: [Select]
?(aP distance T1 > 2):exit
T1 setdammage 1
aP removeaction destroy

You didn't assign the action a name. Also, you changed the case of aP, which I think changes it. Also, the syntax for the if statement needed changing. Finally, the setdammage ranges from 0 to 1. 0 being completely healthy, 1 being dead. You fixed it.
Should work, haven't tested but if you have any problems just give us a bell. They're easy mistakes to make, and takes some time just to realise what's wrong.  :) :good:
-=GC=-Fungus1999
Title: Re: Script wont work, very simple but..
Post by: NightJay0044 on 08 Sep 2008, 10:33:16
Thanks for the help, oh yeah I didn't realize or think about if 1 was dead or 0 was alive for the setdammage command.

One more thing, why when using the "Distance" command do you have to use these marks () around the distance command?  No where in the Command Reference at OFPEC does it tell you to put them in there. SO how does a reader know what he's doing right or wrong without needing help from another person when it's in the Command Reference?

That's one thing where the command reference really confuses me, but that's another topic.

Thank you.
Title: Re: Script wont work, very simple but..
Post by: bedges on 08 Sep 2008, 12:26:20
The COMREF example does not require brackets because it's not part of a conditional statement. This is a basic principle of scripting which it's assumed everyone already knows. Evidently not. Perhaps it's time for a few more examples to be added to the COMREF...  :scratch:
Title: Re: Script wont work, very simple but..
Post by: NightJay0044 on 09 Sep 2008, 02:38:15
Oh well when you say; "A basic principle of scripting" it doesn't fall under my skills to much. I don't have to much experience in scripting.  I suppose I need to upgrade my sklls then.  :D