Scripts18 Posted March 2, 2012 Share Posted March 2, 2012 Just cant understand how to do math and compare stuff with papyrus scripting :s Take a look at this .... and theres probably errors ScriptName LevelingUpWeapon extends ObjectReference Event OnObjectEquipped( Form Weapon, ObjectReference akReference ) <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more) xp = 0 If Game.getplayer().IsInCombat() == true x = game.getplayer().getcombattarget() Debug.notification("You Are In Combat With" + x) if x.getkiller() == game.getplayer() Debug.Notification("You Killed An Ennemy") Debug.notification("Your Weapon Gained 1 xp") xp + 1 endif EndIf EndEvent Link to comment Share on other sites More sharing options...
David Brasher Posted March 2, 2012 Share Posted March 2, 2012 The best way to script is in the CK. The auto-debug feature will stop you in your tracks when you are doing things wrong. Debug.Notification("You Killed An Ennemy") Typographical error here. Ennemy --> Enemy Link to comment Share on other sites More sharing options...
Mansh00ter Posted March 2, 2012 Share Posted March 2, 2012 I disagree - the best way to script is to set up an external editor, like Notepad ++. Then you benefit from color coding, proper indentation etc. CK editor is for quick changes to code only. And if you set up an external editor properly, you will get compilation errors just like in CK. To the OP, what are you trying to do with the script? Hard to say what you're doing wrong if we don't know what it is you're supposed to do in the first place, but looking at the code I assume you're trying to make a weapon that gains experience? In that case you're calling a wrong event. The code you type will fire only once, on item being equipped. You want an event that will fire when an actor dies, or when the weapon hits something. For first use onDeath(), for second use onHit(), see if that helps. Link to comment Share on other sites More sharing options...
Scripts18 Posted March 2, 2012 Author Share Posted March 2, 2012 (edited) Im using notepad++ heres what I was getting xp undefined heres how I fixed it int xp = 0 and also fixed the x = stuff now its ok Edited March 2, 2012 by Scripts18 Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted March 2, 2012 Share Posted March 2, 2012 (edited) Try this ScriptName LevelingUpWeapon extends ObjectReference int property xp auto x = game.getplayer() .getcombattarget() Event OnObjectEquipped( Form Weapon, ObjectReference akReference ) <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more) If (Game.getplayer().IsInCombat() == true) Debug.notification("You Are In Combat With " + x + "." ) if x.getkiller() == game.getplayer() Debug.Notification("You Killed An Ennemy") Debug.notification("Your Weapon Gained 1 xp") xp += 1 endif EndIf EndEvent Edited March 2, 2012 by FiLTHYESKiMO Link to comment Share on other sites More sharing options...
Scripts18 Posted March 2, 2012 Author Share Posted March 2, 2012 (edited) Try this x = game.getplayer() .getcombattarget() <------------------------ the = gives this error : no viable alternative input '=' Also @ mansh ... I know will probably put loops , but wanted to test it how it was right now Edited March 2, 2012 by Scripts18 Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted March 2, 2012 Share Posted March 2, 2012 (edited) ScriptName LevelingUpWeapon extends ObjectReference int property xp auto string proprety x auto Event OnObjectEquipped( Form Weapon, ObjectReference akReference ) <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more) If (Game.getplayer().IsInCombat() == true) x = Game.GetPlayer().GetCombatTarget() <----------------- Note: akReference gonna be something else later (This note isnt in the script its just so you can understand a bit more) Debug.notification("You Are In Combat With " + Game.GetPlayer().GetCombatTarget() + "." ) if x.getkiller() == game.getplayer() Debug.Notification("You Killed An Ennemy") Debug.notification("Your Weapon Gained 1 xp") xp += 1 endif EndIf EndEvent I fired the GetCombatTarget too soon. It was trying to retrieve the target before it existed. Maybe this fixes it? Edited March 2, 2012 by FiLTHYESKiMO Link to comment Share on other sites More sharing options...
Scripts18 Posted March 2, 2012 Author Share Posted March 2, 2012 I get some other errors now, I think I will go back at doing some tutorials Link to comment Share on other sites More sharing options...
FiLTHYESKiMO Posted March 2, 2012 Share Posted March 2, 2012 I get some other errors now, I think I will go back at doing some tutorials I am fairly certain this line is giving you troubles. string property x auto maybe one of the three following work: string x auto or string x = "" or int property x auto Link to comment Share on other sites More sharing options...
Scripts18 Posted March 2, 2012 Author Share Posted March 2, 2012 (edited) Actually that line didnt give me errors it is something with the x.getkiller and some other stuff , I continued working on my version and I have only 1 problem now ScriptName LevelingUpWeapon extends ObjectReference int property xp auto Event OnObjectEquipped( Form Weapon, ObjectReference akReference ) If game.getplayer().IsInCombat() == True Actor x = Game.GetPlayer().GetCombatTarget() Debug.notification("You Are In Combat With " + x + ".") Endif EndEvent Event OnDeath(Actor akKiller) If (akKiller == game.getplayer()) Debug.Notification("You Killed An Enemy") Debug.notification("Your Weapon Gained 1 xp") xp += 1 Endif EndEvent If I use the OnDeaht Event I cant find out who was the npc killed.... and I dont know how to combine those 2 events into 1 (must have the weapon equiped and kill somebody with it to get the xp) Nvm for the event thingy I found out how to Edited March 2, 2012 by Scripts18 Link to comment Share on other sites More sharing options...
Recommended Posts