xBloodTigerx Posted January 29, 2017 Share Posted January 29, 2017 (edited) hello, I'm trying to get this code to work, whenever i attack, it activates a code. so far i keep getting stuck with "no viable alternative at input 'if' " here is my code Scriptname myweapon extends ObjectReference Const explosion property myweapon auto const Event OnPlayerFireWeapon(Actor akActor) native if akActor == Game.GetPlayer() Debug.Trace("you attacked") endIf endEvent //it gives an error; scythswi.psc(7,1): no viable alternative at input 'if'. what am i missing? Edited January 29, 2017 by xBloodTigerx Link to comment Share on other sites More sharing options...
shavkacagarikia Posted January 29, 2017 Share Posted January 29, 2017 Your script shouldnt be const as usual const means that the object does not contain any data and the game can throw it away at will. Also Where you have that script attached to? Also onPlayerFireWeapon will fire only if you are out of combat, you should use "weaponFire" animation event instead.If I were you I would make new quest which runs automatically and attach script on it. It would look like this: Event onQuestInit()RegisterForAnimationEvent(game.getplayer(), weaponFire)Endevent Event OnAnimationEvent(ObjectReference akSource, string asEventName) If (akSource == Game.GetPlayer() && asEventName == "weaponFire") Debug.Notification("you fired weapon") EndIfEndEvent Link to comment Share on other sites More sharing options...
xBloodTigerx Posted January 29, 2017 Author Share Posted January 29, 2017 (edited) the script is attached to the weapon itself. and thanks, ill try it out.but is it possible to just call for weaponfire? i don't want it to activate on all the weapons the code still does not work even without it being const, still gives the error. idk what im missing .-. Edited January 29, 2017 by xBloodTigerx Link to comment Share on other sites More sharing options...
shavkacagarikia Posted January 29, 2017 Share Posted January 29, 2017 (edited) You can check needed weapon with getequippedweapon() Do that in the way I suggested. Edited January 29, 2017 by shavkacagarikia Link to comment Share on other sites More sharing options...
steve40 Posted January 31, 2017 Share Posted January 31, 2017 (edited) OnPlayerFireWeapon is a function in Actor script. You cannot use it that way in a script that extends ObjectReference. Actor extends ObjectReference but not the other way around. If you still wanted to call OnPlayerFireWeapon, you would do it like this: RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerFireWeapon"), then rename your event to: Event Actor.OnPlayerFireWeapon(Actor akSender, Form akBaseObject) if akSender == Game.GetPlayer() Debug.Trace("you fired weapon: " + akBaseObject) endIf endEvent Note that you cannot use the native flag on your functions, and that "OnPlayerFireWeapon(Actor akActor)" is invalid, the native function is "OnPlayerFireWeapon(Form akBaseObject)", you must keep the argument types consistent.. Edited January 31, 2017 by steve40 Link to comment Share on other sites More sharing options...
xBloodTigerx Posted February 1, 2017 Author Share Posted February 1, 2017 where would you put -RegisterForRemoteEvent(Game.GetPlayer(), "OnPlayerFireWeapon")- ? sorry i can read scripts but cannot put them in the right place ;-; Link to comment Share on other sites More sharing options...
Recommended Posts