Jump to content

Photo

Please help me create a script

script gold help

  • Please log in to reply
17 replies to this topic

#11
foamyesque

foamyesque

    Old hand

  • Members
  • PipPipPip
  • 816 posts


Also make sure you run it inside an event or function. The compiler should also give you the line number for the fail. I think it says line 3, 5 or something like that. If the statement isn't inside an event or function and the rest of the script is correct, the script will fail instantly and give back EOF error. 

 

Everything that does something inside a script, with only the exception of declaring variables, has to be inside either an event or a function. Events are code blocks that listen for particular things that the game does and are the entry point for manipulating it with scripts. The OnMagicEffectStart in the code snippet of this post is an example of an event. It will fire whenever the magic effect starts being applied to the target.

 

Functions are code blocks that can be reused without needing to re-write all the pieces of it. For example, RemoveItem() is an event.

 

If your objective is to use a player's gold to cast something instead of, or in addition to, their magicka, there may be a better approach. I need to do some testing.



#12
curecuriosity

curecuriosity

    Newbie

  • Members
  • Pip
  • 10 posts

Where are you from?
 

Event HasMagicEffect(MagicEffect akEffect)
 
IF Game.Getplayer().HasMagicEffekt(EffektProp)
Game.Getplayer().RemoveItem(GoldProp, 1)
Utility.Wait(1.0)
EndIF
 
EndEvent

Im a scripting noob so I'm not sure, but I'd start there.


#13
gbcsi88

gbcsi88

    Stranger

  • Members
  • Pip
  • 8 posts

from korea

 

compilered success

 

but, it does not apply to inGame...

 

Gold is not consumed when using spells... :sad:



#14
curecuriosity

curecuriosity

    Newbie

  • Members
  • Pip
  • 10 posts
Try this. (I only added lines to your first script, check for typos)
 
Event OnEffectStart(actor Target, actor Caster)
 
RegisterForSingleUpdate(1.0) 
 
EndEvent
 
Event OnUpdate() 
 
 
IF Game.Getplayer().GetitemCount(gold001) <= 1
 
Game.Getplayer().Unequipspell(Myspell, 0)
 
Game.Getplayer().Unequipspell(Myspell, 1)
 
Debug.Notification("no Gold")
 
 
ElseIf Game.Getplayer()GetItemCount(Gold001) > 1
 
Game.Getplayer()RemoveItem(Gold001, 1) 
 
RegisterForSingleUpdate(1.0)
 
ENDIF
ENDIF
 
endEvent
 
Event OnEffectFinish(Actor Target, Actor Caster)
 
UnregisterForUpdate()
 
EndEvent


#15
gbcsi88

gbcsi88

    Stranger

  • Members
  • Pip
  • 8 posts

fail... i do not know what i;m doing wrong..

 

i'm stupid :sad:

Attached Files

  • Attached File  fail.jpg   109.58KB   0 downloads


#16
curecuriosity

curecuriosity

    Newbie

  • Members
  • Pip
  • 10 posts

See where it's ENDIF ENDIF? remove one of them. I'll look at the rest.


Edited by curecuriosity, 07 September 2018 - 12:02 PM.


#17
SeraphimKensai

SeraphimKensai

    Have you all seen my keys? I think they are here somewhere.

  • Members
  • PipPipPip
  • 560 posts
It is probably also worth putting a "." after "Game.GetPlayer()" on both lines 25 & 26 before the GetItemCount and RemoveItem respectively.

#18
curecuriosity

curecuriosity

    Newbie

  • Members
  • Pip
  • 10 posts

^ Yes. Should work after those corrections.

A few problems; 
The HasMagicEffect event is not needed anymore.
Line 25 doesn't need the Elseif i don't think. Using "Else" instead and removing the contents of that line would do the same, but be more efficient. (my bad)
The way it is now, if we ignore the first event, the script will run for 1 second when you cast without checking for gold, which I guess doesn't work very well with what you are trying to do. 


 







Also tagged with one or more of these keywords: script, gold, help

Page loaded in: 1.085 seconds