Home   Help Search Login Register  

Author Topic: detect if player did it  (Read 3276 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
detect if player did it
« on: 04 Jun 2005, 14:39:13 »
im trying to simulate a court martial by using an event handler killed on all the superior officers and since in a killed event handler _this selcet 1 is the person who did it.
So how can i check if _this select 1 is the player ?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:detect if player did it
« Reply #1 on: 04 Jun 2005, 15:34:33 »
pffft...

? _this select 1 == player: goto "court_martial"
« Last Edit: 04 Jun 2005, 15:35:01 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #2 on: 04 Jun 2005, 15:35:32 »
i tried that but it didnt work anyway ill try it again
thanks

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:detect if player did it
« Reply #3 on: 04 Jun 2005, 15:45:39 »
???
That's odd...
Works just fine here...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #4 on: 04 Jun 2005, 15:50:14 »
well im having a go now but its going to take a while to get all the scripts right again cause i deleted them lol
anyway cheers

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #5 on: 04 Jun 2005, 16:06:27 »
YAY it did work i must of done something wronf last time anyway now my resource wont show up ill post it up here to save opeing a new thread
this is the description.ext

Code: [Select]
class SolidPicture
{
   type=0;
   idc=-1;
   style=48;
   colorBackground[]={0,0,0,0};
   colorText[]={1,1,1,};
   font="tahomaB24";
   size=0;
};
class RscTitles
{
class Court
   {
      idd=-1;
      movingEnable=0;
      duration=999;
      name="Court";
      controls[]={"Court"};
      class CourtMartial: SolidPicture
      {
         text="court.jpg";
         x=0.000000;
         y=0.000000;
         w=1.000000;
         h=0.15000;
      };
   };
};

note - i changed the line wich should have court.paa to court.jpg becuase the file i used is a jpg and i dont have a tool to convert the jpg into a paa
is there anything wronf in the file ?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #6 on: 04 Jun 2005, 16:10:00 »
Ummmmm........you don't have a control called Court.

controls[]={"Court"};


Planck
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #7 on: 04 Jun 2005, 16:14:56 »
okay i tried that and it worked aprt rom it said the image isnt 2n how can i get it into 2n but the thing is if i do it wont fit in the space wich covers the you are dead text on the end dialog any suggestions

Also when i tried
? _this select 1 == player: goto "court_martial"
again i got this message
? _this select 1 ==|#| player  error zero divisor
does anyone know what that might be ?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #8 on: 04 Jun 2005, 16:30:34 »
Your picture dimensions must be in powers of 2.

What are your dimensions......if they are not a power of 2 then change them.

Convert it to .tga first, then use Texview to make it .paa.


Planck
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #9 on: 04 Jun 2005, 16:37:11 »
there 1086x76
but if i did change them to 2n it will go over the border and go into the screen wich wouldnt look to good also it might not go over the default 'you are dead' text but ill have a go
thanks

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #10 on: 04 Jun 2005, 16:41:02 »
Try 1024 X 64.

Then use this bit to male it fit the area you want:

 x=0.000000;
 y=0.000000;
 w=1.000000;
 h=0.15000;


Planck
« Last Edit: 04 Jun 2005, 16:44:55 by Planck »
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #11 on: 04 Jun 2005, 16:42:37 »
how do i edit a picture's dimentions into 1024x64 then ?


Also when i tried it again i got this error
? _this select 1 == player: goto "court_martial"
again i got this message
? _this select 1 ==|#| player  error zero divisor
does anyone know what that might be ?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #12 on: 04 Jun 2005, 16:45:48 »
Don't you have a picture program of some kind......like PSP?


Planck
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #13 on: 04 Jun 2005, 16:52:17 »
ive now managed to get it to work fine except the picture looks alittle stretched what other dimensions wich are smaller wich will help unstreatch the pic

also that bug to check if the player killed the officer then ive done it

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #14 on: 04 Jun 2005, 16:53:53 »
Like I said above, use these:

 x=0.000000;
 y=0.000000;
 w=1.000000;
 h=0.15000;

To size and place it where you want on the screen.


Planck
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #15 on: 04 Jun 2005, 16:57:47 »
ive already got the right place on the screen im just trying to resize the pic so its not as blury
also thanks for your help

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #16 on: 04 Jun 2005, 17:00:43 »
Well, try a resize to 512 X 32.

But I think the same might happen, but try it anyway



Planck
I know a little about a lot, and a lot about a little.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:detect if player did it
« Reply #17 on: 04 Jun 2005, 17:11:53 »
For the zero divisor thing, it seems that there is no value returned 'in' the _this select 1...

You by any completely odd reason happen to use pre- 1.90 OFP?
Because if that's the case I don't think the eventHandlers work...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #18 on: 04 Jun 2005, 17:18:28 »
ive got V1.96

also now ive resized everything but have ran into a problem its saying it can load my texture

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #19 on: 04 Jun 2005, 17:28:41 »
okay ive fixed the dimensions just stuck with the event handler thing is there any other alternate ways checking if the player killed him?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #20 on: 04 Jun 2005, 17:58:48 »
you could try assigning a variable first.

_badboy = _this select 1

hint format ["Badboy is - %1", _badboy]


or someting like that to check what select 1 contains, if anything.


Planck
« Last Edit: 04 Jun 2005, 17:59:11 by Planck »
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #21 on: 04 Jun 2005, 18:18:52 »
i just though of something im running a script through the event handler so is it not returing anything becuase its in a script like that ?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #22 on: 04 Jun 2005, 18:31:24 »
If you are running the script from an eventhandler then the script will receive its values from the eventhandler:

For a 'killed' eventhandler it would be select 0 according to the comref.

And maybe there lies your problem......you are using select 1..........possibly   ::)


Planck
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #23 on: 04 Jun 2005, 20:12:07 »
in the editors depot theres a tutorial on event handlers and it says that a kiiled eh
has the following
this select 0 = whos dead
this select 1 = who killed him
or thats what i am to beleive people have been saying theres no select 1 so im not totaly sure if this is right
so if you know of another way please say ?
thanks for all help so far aswell

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #24 on: 04 Jun 2005, 20:17:32 »
It's not entirely impossible that the comref is wrong, any way you could always try select 0 to see what you get, if anything.

What line are you using to set the eventhandler?


Planck
« Last Edit: 04 Jun 2005, 20:17:58 by Planck »
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #25 on: 04 Jun 2005, 20:25:32 »
im using this in the units init field

this AddEventHandler ["killed", {[] exec "court.sqs"}]

and these are what (or suposebly) what is returned by it

"killed" (addable to men or vehicles) :
_this select 0 : who's dead ;
_this select 1 : whodunnit (say, the killer) ;

but i think this is wrong and your right becuase ive had trouble with this before
so this leads me to have one option the long way around wich always seems to be the easy way for ofp lol.

#loop
officer addEventHandler ["hit",{goto "CheckDead"}]}
~2
goto "loop"
#checkdead
? (_dammage >= 1) : [] exec "court" && goto exit
? (_dammage < 1): goto "loop"
#exit

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #26 on: 04 Jun 2005, 20:28:44 »
Try this:

this AddEventHandler ["killed", {_this exec "court.sqs"}]


Planck
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #27 on: 04 Jun 2005, 20:30:14 »
but when i do that i cant check if the player killed him or if a russian did

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:detect if player did it
« Reply #28 on: 04 Jun 2005, 20:35:38 »
Eventhandlers return their values in _this according to the comref.

So, when your script says:

_this select 0:  It takes the first returned value which might be the person killed.

_this select 1:  It takes the second returned value which might  be the person who did the killing.

Thats the way I understand it anyway.


Planck   ;D ;D
« Last Edit: 04 Jun 2005, 20:36:11 by Planck »
I know a little about a lot, and a lot about a little.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #29 on: 04 Jun 2005, 20:44:41 »
well i have this in my script
? _this select 1 == player : goto "court_martial"
but it says nothing is returned so therfore im pretty sure the tut im reading is wrong as well as someone else who used _this select 1 as the killer also had trouble

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:detect if player did it
« Reply #30 on: 04 Jun 2005, 20:44:48 »
@Planck:
Exactly.
In eventHandler _this refers to the array of values that is passed by the eventHandler type into the script that the eventHandler executes...


So what Planck says is correct.
It never even occurred to me that you could be using the eventHandler the wrong way...

Quote
this AddEventHandler ["killed", {_this exec "court.sqs"}]
So this is how you need to do it...
« Last Edit: 04 Jun 2005, 20:46:33 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #31 on: 04 Jun 2005, 20:46:21 »
so why is this not working ?

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:detect if player did it
« Reply #32 on: 04 Jun 2005, 20:47:07 »
Check the edited post above...
You are executing the script the wrong way...
« Last Edit: 04 Jun 2005, 20:47:21 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline 456820

  • Contributing Member
  • **
Re:detect if player did it
« Reply #33 on: 04 Jun 2005, 20:53:36 »
YES thank you so much all of you i got it workng
topic solved