Jump to content

Need help with a script.


Vega1942

Recommended Posts

I'm doing a simple script that adds an item to your inventory when you drink a potion but I don't know what I'm doing wrong, here's the script

 

actor property PlayerREF auto

MiscItem property MyItem auto

 

Event OnEffectStart(actor AkTarget, AkCaster)

 

If AkCaster == Game.GetPlayer()

ElseIf AkTarget == Game.GetPlayer()

 

Player.REF.AddItem(MyItem, 1,ture)

 

Endif

 

EndEvent

 

it compile just fine but when I go in game to test it nothing happens, so any help would be appreciated thanks.

 

 

Link to comment
Share on other sites

Assuming a potion is part of an ACTOR script,

I would ask why are you using player.ref?

 

I have only used player.additem("declareditm,# to give, true/false)

 

Also, if you actually typed: MyItem, 1, ture and it is not a typo, it should be: MyItem, 1, true

 

Where was the script placed? On the NPC or on the potion?

What property was assignedf to MyItem?

 

 

Also:

The syntax is wrong

You are missing another ACTOR statement where as by example:

Examples
Event OnEffectStart(Actor akTarget, Actor akCaster)

endEvent
Edited by Ashenfire
Link to comment
Share on other sites

no the script is extends to an effect so I tried editing the script to

 

scriptname myScript extends activemagiceffect

 

actor property player auto

MiscItem property Myitem auto

 

event oneffectstart(actor AkTarget, Actor AkCaster)

 

If Akcaster == game.getplayer()

Elseif Aktarget == Game.getPlayer()

 

Player.additem(Myitem, 1,true)

 

Endif

 

endevent

 

but its still not working, so what is it I'm doing wrong?

Link to comment
Share on other sites

Step through your event with Debug.Notification to see where things are getting up to or if they are even being fired.
eg:

Scriptname myScript Extends ActiveMagicEffect

MiscObject Property Myitem Auto ;MiscObject is the property for MiscItem

Event OnEffectStart(Actor akTarget, Actor akCaster)
    Debug.Notification("Yep Effect has been called.")
    Actor PlayerRef = Game.GetPlayer()
    If akTarget == PlayerRef || akCaster == PlayerRef
        Debug.Notification("Yep it's the player should be adding item now.")
        PlayerRef.AddItem(Myitem, 1,true)
    Endif
EndEvent
Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

Yep, that would be the next step. The difference there is that the actor is actually defined [ Actor PlayerRef = Game.GetPlayer() ]

In other words, I don't believe you can do a comparitive value with AkCaster, it has to be defined with a variable and then you compare the variable with Game.Getplayer().

Edited by Ashenfire
Link to comment
Share on other sites

You can compare PlayerRef if it's defined as an Actor, be it in an external property or an internal cast in a function or event.
The only reason I declared Actor PlayerRef = Game.GetPlayer() was because the Variable name makes no difference
(The variable name can be anything you like as long as you fill it in CK or by whatever means you like).
I was going to call the the same Game.GetPlayer() 3 times.
Better to call it once and put it in a variable and use the variable in this instance.

Using for example:
Actor Property Player Auto
Will not fill the property on it's own, eg: you still have to fill the property in CK or by what ever means.
The scripting engine doesn't recognize Player on it's own without first declaring and filling it.

Player is only unique in some situations where you can use the text Player without declaring it such as in Text Replacement where you have for example a book or message owned by a quest and you use something like <Alias=Player>, which would show the players display name even without having a Reference Alias or Property filled with the player.

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

Did you fill the MyItem property in CK and point it to the item you want added to the player inventory?

eg:

With the script attached and selected hit the Properties button.
In the script property window that opens select the MyItem property on the left and click edit on the right.
You will see a dropdown box, select the item you want from the dropdown box.
Click Ok and the property window closes.

Properties don't assign themselves just because you may give it the same name as your item.
The scripting engine doesn't know the item by the name.
It knows the item by what the property points to.

(in your case whatever you selected from the dropdown box in the property window)

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

Is the item flagged as playable.

When you edit the MiscItem in the object window is the Playable checkbox ticked?

Is this an item you've added yourself?

Is the path to the model set for the MiscItem?

Does the preview of the item show in CK?

If you drop the MiscItem in the render window in CK does the item show properly?

 

In game if you open the console and use player.placeatme XXXXXXXX

(XXXXXXXX = the base form id)

Does the item show up under your feet?

 

(Do TCL command first and lift yourself from the ground a little, then do the placeatme)

 

Does the item get added to your inventory if you do the console command

player.additem XXXXXXXX 1

(XXXXXXXX = the base form id)

Edited by sLoPpYdOtBiGhOlE
Link to comment
Share on other sites

  • Recently Browsing   0 members

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