My Script Won't Work

Post » Tue May 17, 2011 11:38 am

I'm trying to make it so they when you put on clothing and/or armour associated with a faction you are added to that faction, unless of course you're already in the faction in which case I want it to do nothing. Then I need to reverse the whole thing when you take off the clothing/armour. Here's my script:

scriptName MythicDawnClothingbegin GameMode	if player.getequipped 00024DE2 && player.getequipped 0008D755 && (player.getinfaction MythicDawn == -1) == 1		player.setfactionrank MythicDawn 0	endif	if player.getequipped 00024DE2 && player.getequipped 0008D755 && player.getinfaction MythicDawn == 0		player.setfactionrank MythicDawn -1	endifend


Any help would be greatly appreciated.

- Ryan Paul Fialcowitz
User avatar
Kim Bradley
 
Posts: 3427
Joined: Sat Aug 18, 2007 6:00 am

Post » Tue May 17, 2011 1:06 am

Interesting. Didn't know it is possible to use a hex id in a script. But it's not a good idea, anyway.

What's wrong with your script is the part (player.getinfaction MythicDawn == -1) == 1

getinfaction returns 0, if the player is not a member. Unlike getfactionrank, which you probably had in mind.
And the '== 1' at the is unnecessary.
User avatar
Nathan Risch
 
Posts: 3313
Joined: Sun Aug 05, 2007 10:15 pm

Post » Tue May 17, 2011 1:44 am

Possible, but It's not a good idea to use form ids in a script, use the editor ids instead. This is probably another reason it wont work. Why? Because form ids of items change based on load order, so this is why they came up with editor ids :)
User avatar
lexy
 
Posts: 3439
Joined: Tue Jul 11, 2006 6:37 pm

Post » Tue May 17, 2011 12:31 am

My revised script which works:

scriptName MythicDawnClothingbegin GameMode	if (player.getequipped 00024DE2 && player.getequipped 0008D755 == 1) && player.getinfaction 00029F82 == 0		player.setfactionrank 00029F82 0	endif	if (player.getequipped 00024DE2 && player.getequipped 0008D755 == 0) && player.getinfaction 00029F82 == 1		player.setfactionrank 00029F82 -1	endifend


If anyone is interested all you would need to do is switch out the FormIDs and you could make this work for any equipment/faction combination. Thanks for the help.

- Ryan Paul Fialcowitz
User avatar
N3T4
 
Posts: 3428
Joined: Wed Aug 08, 2007 8:36 pm

Post » Tue May 17, 2011 9:25 am

People tell you not to use Form ID's in scripts and you replace the last few editor ID's you had in the script with Form ID's. :unsure:
User avatar
Wane Peters
 
Posts: 3359
Joined: Tue Jul 31, 2007 9:34 pm

Post » Mon May 16, 2011 10:45 pm

There's also the minor problem that if you were in the faction before equipping the items, your script doesn't record that and unconditionally expels you from the faction when you unequip. The DB faction, for example, likes to kill its ex-members.
User avatar
Sara Johanna Scenariste
 
Posts: 3381
Joined: Tue Mar 13, 2007 8:24 pm

Post » Tue May 17, 2011 1:50 pm

People tell you not to use Form ID's in scripts and you replace the last few editor ID's you had in the script with Form ID's. :unsure:


I haven't had much luck with Editor IDs in Fallout 3 where I've had the most experience scripting, while Form IDs always work. Yes, there is the load order issue - but what can I do if it didn't work with Editor IDs? However, it DID work with The Elder Scrolls IV - Oblivion. So, consider me admonished. . .

There's also the minor problem that if you were in the faction before equipping the items, your script doesn't record that and unconditionally expels you from the faction when you unequip. The DB faction, for example, likes to kill its ex-members.


How do I fix this issue? My scripting knowledge is clearly quite limited. I would appreciate some input on this matter and, of course, thanks for all the replies.

UPDATE
I got it to work. Now the script does nothing if you wear or remove the clothing whilst already a member of the faction.

scriptName MythicDawnClothingshort AlreadyInFactionshort NotInFactionbegin GameMode		if player.getinfaction MythicDawn == 1		set AlreadyInFaction to 1	endifendbegin OnEquip	if (player.getequipped MythicDawnRobe && player.getequipped MythicDawnRobeHood == 0) && AlreadyInFaction == 0		player.setfactionrank MythicDawn 0		set NotInFaction to 1	endifendbegin OnUnequip	if NotInFaction == 1		player.setfactionrank MythicDawn -1		set NotInFaction to 0	endifend


- Ryan Paul Fialcowitz
User avatar
Sweet Blighty
 
Posts: 3423
Joined: Wed Jun 21, 2006 6:39 am

Post » Tue May 17, 2011 8:19 am

I haven't had much luck with Editor IDs in Fallout 3 where I've had the most experience scripting, while Form IDs always work.

I have coded FO3 scripts since it came out and have never had a problem with using the Editor ID. Ever... And I write tons of scripts, just look at any of my released mods to see proof of that. So the problem was probably not the Editor ID.
User avatar
Robert Bindley
 
Posts: 3474
Joined: Fri Aug 03, 2007 5:31 pm


Return to IV - Oblivion