Jump to content

Small Scripting Issue | Please Help


KaelVirum

Recommended Posts

Ok, here's the thing. I've created my own race that is 0.25 in height and now I'm trying to create an activator that will shrink the player down to that size so that they can interact with my race more comfortably. I know I have most of the script correct as I'm only getting one error. Here's the Script:

 

ScriptName ShrinkPlayerScript extends ObjectReference
Function SetScale(float afScale)
Event onActivate(objectReference akActionRef)
Player().SetScale(0.25)
endEvent
endFunction
But when I try to compile it in CK I get an error message (10,0) missing EOF at 'endFunction'
What exactly is it that I'm missing here? Any help will be greately appreciate!
Link to comment
Share on other sites

Ok, sorry for the double post, guys, but I felt it would be better than cluttering up the front page with an issue dealing with the same thing. I've got the script working, thanks to JMSFedaykin, and attached to an activator and it works perfectly. However, I'm now trying to figure out how to add the conditionals so that once I activate it and my scale is set to 0.25 that I can activate it again and have my scale reset to 1.00. Here's the script I have, does anyone know where I'm going wrong?

 

Scriptname ShrinkPlayerScript extends ObjectReference
{This script sets the scale of the Player to 0.25.}
Function SetScale(float afScale) native
int afScale
Event onActivate(ObjectReference akActionRef)
afScale = Game.GetPlayer().GetScale()
Game.GetPlayer().SetScale()
endEvent
int Function GetScale(int currentafScale)
if currentafScale == 1.00
Game.GetPlayer().SetScale(0.25)
elseif currentafScale == 0.25
Game.GetPlayer().SetScale(1.00)
endif
endFunction
Edited by KaelVirum
Link to comment
Share on other sites

ok, i think you need to rewrite this a little bit... try something like this:

 

Event onActivate(ObjectReference akActionRef)

if (Game.GetPlayer().GetScale() == 1.00)

Game.GetPlayer().SetScale(0.25)

else

Game.GetPlayer().SetScale(1.00)

endif

endEvent

 

 

Now I'm not sure if you would need to do this, but for good-coding's sake, you might want to make sure that only the player can activate the object. If so, you could do it like this:

 

Actor Property PlayerREF Auto

Event onActivate(ObjectReference akActionRef)

if (akActionRef == PlayerREF && Game.GetPlayer().GetScale() == 1.00)

Game.GetPlayer().SetScale(0.25)

elseif (akActionRef == PlayerREF && Game.GetPlayer().GetScale() == 0.25)

Game.GetPlayer().SetScale(1.00)

endif

endEvent

Now I'm not positive, but I think after compiling the script, you would still need to set the PlayerREF in the properties of the script in the CK. But after that it should work...

Hope that helps!

Edited by JMSFedaykin
Link to comment
Share on other sites

Just in case the player had been set to some other scale before starting I would use:

Actor Property PlayerREF Auto

int PreviousScale = 0.25 ; default to 0.25 in case by some strange chance the player was already that size

Event OnActivate(ObjectReference akActionRef)
    if akActionRef == PlayerREF ; so activator only works for the player
        if PlayerRef.GetScale() != 0.25
             PreviousScale = PlayerRef.GetScale() ; record current scale so it can be restored
             PlayerRef.SetScale(0.25)
        else ; already small
             PlayerRef.SetScale(PreviousScale)  ; restore previous scale
        endif
    endif
EndEvent
And yes, you then need to fill the script properties, but Auto-Fill will know what to do with PlayerREF.
Link to comment
Share on other sites

Just in case the player had been set to some other scale before starting I would use:

Actor Property PlayerREF Auto

int PreviousScale = 0.25 ; default to 0.25 in case by some strange chance the player was already that size

Event OnActivate(ObjectReference akActionRef)
    if akActionRef == PlayerREF ; so activator only works for the player
        if PlayerRef.GetScale() != 0.25
             PreviousScale = PlayerRef.GetScale() ; record current scale so it can be restored
             PlayerRef.SetScale(0.25)
        else ; already small
             PlayerRef.SetScale(PreviousScale)  ; restore previous scale
        endif
    endif
EndEvent
And yes, you then need to fill the script properties, but Auto-Fill will know what to do with PlayerREF.

 

That didn't work for me. The script wouldn't compile because it couldn't set an int to 0.25.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...