Jump to content

Home

[K1] TakeGoldFromCreature Script Error?


JediMaster76

Recommended Posts

Alright, I'm ashamed at myself for even asking this question :(

 

Anyway, I looked at "Frequently used script functions" copied/pasted the TakeGoldFromCreature script, and pasted it as so...

 

void main()
{
TakeGoldFromCreature( GetFirstPC(),1000);
}

 

But it gives me this compilation error...

 

ERROR: Type mismatch in parameter 1 call to "TakeGoldFromCreature".

 

Any ideas on how I can fix this? I feel like a massive n00b, cuz I can't figure out the problem, I must be staring right at it, lol.

Link to comment
Share on other sites

I searched "TakeGoldFromCreature" in KotOR Tool and this script came up...

void main()

{
       int nCredits = GetScriptParameter( 1 );
 	TakeGoldFromCreature ( nCredits, GetFirstPC () );
}

 

It looks related enough to the script you tried, so I'm guessing you can use this script above.

Link to comment
Share on other sites

It doesn't look like it, but it is the "d" and the ")" are touching. I tried it without them touching, but it returns the same error.

 

*Edit* I tried the script you entered, Da_Man, but it returned this error...

 

Undeclared Identifier: GetScriptParameter.

Link to comment
Share on other sites

Shoot!

 

I'm at the fraying end of my scripting knowledge...

 

Just looked in KotOR Tool, and I can suggest the gold amount than the GetFirstPC()....

 

I don't know if that helps, but it's all I can do.

 

 

Otherwise, sit tight and hope that people who actually understand scripting will start helping!

Link to comment
Share on other sites

You had the script reversed; I just used KotOR Tool & corrected the script:

 

void main()
{
TakeGoldFromCreature(1000, GetFirstPC());
}

 

It looks for the amount of credits to take, then it looks for who to take it from. It was only a minor error; I'm sure we all make them from time to time. :)

Link to comment
Share on other sites

I'm almost positive it will not work correctly.

 

Because it returns true.

 

That's weird.

 

Mine was wrong; use Ferc's and you'll be fine.

 

_EW_

ForeverNight is correct, it's not a conditional and TRUE/FALSE is used in other scripts that are not conditionals. It's just an extra parameter for that script command.

 

From nwscript.nss:

// 444: Take nAmount of gold from oCreatureToTakeFrom.
// - nAmount
// - oCreatureToTakeFrom: If this is not a valid creature, nothing will happen.
// - [b]bDestroy: If this is TRUE, the caller will not get the gold.  Instead, the[/b]
//   [b]gold will be destroyed and will vanish from the game[/b].
void TakeGoldFromCreature(int nAmount, object oCreatureToTakeFrom, int bDestroy=FALSE);

Link to comment
Share on other sites

Anyway, I looked at "Frequently used script functions" copied/pasted the TakeGoldFromCreature script, and pasted it as so...

 

TakeGoldFromCreature( GetFirstPC(),1000);

 

Hmm, seems to be an error in that post. The parameters should be the other way around. The amount of credits to take first, then the object to take the credits from (and an optional third parameter if you want the credits to be destroyed rather than moved to the inventory of the object running the script).

 

I've fixed the post in the tutorial thread. Odd that nobody has noticed that before. :)

 

So you'd get:

void main() {
   TakeGoldFromCreature(1000, GetFirstPC());
}

 

If you aren't already you probably want to check that the player actually has 1000 gold first as well. You can use the GetGold() function to do that. If this is done via a dialog you can use a conditional script like:

int StartingConditional() {
   return (GetGold(GetFirstPC()) >= 1000);
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...