arcane20 Posted August 2, 2011 Share Posted August 2, 2011 Get self doesn't seem to work, it only returns the player. Here's the section of code I'm having problems with. (Please not "PistolWeaponnum" Is a global that is why it is not listed) Scn Sciptydoodah ref ThisPistol Begin onequip set ThisPistol to Getself ;========Debugging============= If ThisPistol == Weap10mmPistol printc "Thispistol is the correct ref" elseif ThisPistol == player printc "Thispistol = player" else printc "Thispistol = something else" endif ;================================= Set PistolWeaponnum to ListGetFormIndex RealSwitchlist ThisPistol end This script runs on a weapon. I need to call the weapons ID. As you can see 'getself' doesn't work. Can anyone please help ? Link to comment Share on other sites More sharing options...
nosisab Posted August 2, 2011 Share Posted August 2, 2011 (edited) getself is used on a target... it works to find who/what it (the weapon) hits If that is an object script you don't need to check because forcibly will be the weapon the caller If you need to check if it is equipped, use: ... Set WeaponREF to ActorID.GetEquippedObject 16 If WeaponREF == YourWeaponID ; do whatever you need here ... endif change the parameters and identifiers to actual values. 16 there is for the equipped weapon. I'm translating from my experience with Oblivion CS, adapt if needed for GECK. PS: Where possible avoid creating global variables, you can achieve similar results using variables in quest script. Just be aware there are some pitfalls regarding changing the variables order (the quest variables are stored in saves by their position (their order in the script) and not explicit identifiers). Edited August 2, 2011 by nosisab Link to comment Share on other sites More sharing options...
arcane20 Posted August 2, 2011 Author Share Posted August 2, 2011 I'm not sure what you mean by "forcible will be the weapon the caller"But anyways GetEquippedObject will do perfectly, Though it's 5 for the weapon in fallout. Still ^_^ You saved me a bunch of headaches and everything works thanks a lot. Kudos to you. Link to comment Share on other sites More sharing options...
nosisab Posted August 2, 2011 Share Posted August 2, 2011 (edited) I'm not sure what you mean by "forcible will be the weapon the caller"But anyways GetEquippedObject will do perfectly, Though it's 5 for the weapon in fallout. Still ^_^ You saved me a bunch of headaches and everything works thanks a lot. Kudos to you.By "caller" I mean the script knows that is the object it is attached the caller of the function whenever an explicit calling reference is not given. That's the reason this kind of script is named "reference script". Edited August 2, 2011 by nosisab Link to comment Share on other sites More sharing options...
arcane20 Posted August 3, 2011 Author Share Posted August 3, 2011 Ahh I see what you mean. Unfortunately ListGetFormIndex requires a reference and cannot be used without 1.I'll try to take on what you said about globals too thanks. Link to comment Share on other sites More sharing options...
rickerhk Posted August 3, 2011 Share Posted August 3, 2011 In this case you are dealing with base objects and not references. A weapon in a container (player in this case) doesn't have a reference, even when it's equipped. GetEquiptObject always returns base objects. A form list that you create in the Geck is a list of base objects. So something like this should be perfectly valid if you want to check a weapon against a list:scn Sciptydoodah ref ThisPistol ref rContainer short PistolWeaponnum Begin onequip set rContainer to GetContainer if rContainer == player set ThisPistol to GetEquippedObject 5 Set PistolWeaponnum to ListGetFormIndex RealSwitchlist ThisPistol if PistolWeaponnum > -1 ;it's in the list ;Do stuff endif endif End Link to comment Share on other sites More sharing options...
arcane20 Posted August 5, 2011 Author Share Posted August 5, 2011 In this case you are dealing with base objects and not references. A weapon in a container (player in this case) doesn't have a reference, even when it's equipped. GetEquiptObject always returns base objects. A form list that you create in the Geck is a list of base objects. So something like this should be perfectly valid if you want to check a weapon against a list:scn Sciptydoodah ref ThisPistol ref rContainer short PistolWeaponnum Begin onequip set rContainer to GetContainer if rContainer == player set ThisPistol to GetEquippedObject 5 Set PistolWeaponnum to ListGetFormIndex RealSwitchlist ThisPistol if PistolWeaponnum > -1 ;it's in the list ;Do stuff endif endif End Thanks for your reply I had already figured it out but couldn't find this topic =$. I posted a Similar solution here.http://www.thenexusforums.com/index.php?/topic/416297-isinlist-function-causing-script-to-hang/page__p__3443016__fromsearch__1#entry3443016The only difference I'd make is instead of '>-1' Use '!= -1' Just because it's better to be exact. Kudos to you for replying though ^_^. Link to comment Share on other sites More sharing options...
Recommended Posts