Difference between revisions of "Talk:GetRider"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>QQuix
(Answering ABO)
imported>QQuix
(Answered ABO and fixed indentation)
 
(One intermediate revision by one other user not shown)
Line 12: Line 12:
</dl>
</dl>
:[[User:QQuix|QQuix]] 10:34, 3 August 2009 (EDT)
:[[User:QQuix|QQuix]] 10:34, 3 August 2009 (EDT)
:: Yeah, sorry it does work and my code that didn't work was probably using it wrong. The following code didn't seem to ever detect when being ridden:
<dl><dd><dl><dd>
if (getRider == 0)
  ; do something when we are not being ridden
  else
  ; do something when we are being ridden
endif
</dl></dl>
::However assigning 'tempRef = getRider' seems to work correctly. [[User:ABO|ABO]] 09:19, 5 August 2009 (EDT)
:::For the record (since you seem to have a working solution): I placed your code in the gamemode block of the horse script and it does work for me.
:::Note that in the OnActivate block it would work kind of in reverse: when the player/NPC activates the horse, it returns 0 (as the horse is not being ridden yet). When activated again to dismount, it returns the ref to the actor that is dismounting.  GetActionRef does return the mounting actor.  [[User:QQuix|QQuix]] 13:05, 5 August 2009 (EDT)

Latest revision as of 12:05, 5 August 2009

This appears to not be working for me using OBSE 0017b... did it ever work? What is it supposed to return if the horse is being ridden by the player? What is it supposed to return if no one is riding the horse? What is supposed to happen if it is called on something that isn't a horse? ABO 09:13, 3 August 2009 (EDT)

It works for me both in OBSE v17b and v18. It correctly returns the player or NPC reference. Returns a null reference if there is no one riding the horse. Returns a null reference if called on an NPC or on a container. Used this code for testing:
 ;*Player mounts the horse* set xRef to MyHorse.GetRider PrintToConsole "Rider = %i %n" xRef xRef ;Shows Player FormID and Name  ;*Player dismounts the horse* MyHorse.activate MyNPC 1  ; MyNPC mounts the horse set xRef to MyHorse.GetRider PrintToConsole "Rider = %i %n" xRef xRef ;Shows MyNPC FormID and Name
QQuix 10:34, 3 August 2009 (EDT)
Yeah, sorry it does work and my code that didn't work was probably using it wrong. The following code didn't seem to ever detect when being ridden:
if (getRider == 0)  ; do something when we are not being ridden else  ; do something when we are being ridden endif
However assigning 'tempRef = getRider' seems to work correctly. ABO 09:19, 5 August 2009 (EDT)


For the record (since you seem to have a working solution): I placed your code in the gamemode block of the horse script and it does work for me.
Note that in the OnActivate block it would work kind of in reverse: when the player/NPC activates the horse, it returns 0 (as the horse is not being ridden yet). When activated again to dismount, it returns the ref to the actor that is dismounting. GetActionRef does return the mounting actor. QQuix 13:05, 5 August 2009 (EDT)