PDA

View Full Version : [K1] TakeGoldFromCreature Script Error?


JediMaster76
06-18-2008, 07:45 PM
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.

ForeverNight
06-18-2008, 07:50 PM
I'm not great shakes at scripting, however, I think you have to move the first parenthesis so that it is 'connected' to TakeGoldFromCreature...

I think, I wish Stoffe or somebody who actually understood this was here!

Da_Man_2423
06-18-2008, 07:55 PM
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.

JediMaster76
06-18-2008, 07:56 PM
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.

ForeverNight
06-18-2008, 07:59 PM
@Da_Man: K1 doesn't use script parameters, that's TSL only.

Hmm..... I think I have no clue as to what is going on.........

Oh! Try removing the space between the "," and the 1000...

I think that's what's wrong.

Stoffe, where the heck are you?

JediMaster76
06-18-2008, 08:06 PM
Again, there is no space in the coding, it just appears that way. And again, I removed the space and tried it that way, and I received the same error.

ForeverNight
06-18-2008, 08:10 PM
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!

EnderWiggin
06-18-2008, 08:13 PM
Are you sure you're in K1 mode when you compile the script?

I'm pretty sure only TSL deals with parameters.

_EW_

ForeverNight
06-18-2008, 08:15 PM
^^^^

Never thought to check the K1 compiling! -Do it!

And, yes only TSL supports scripting parameters...

JediMaster76
06-18-2008, 08:16 PM
I know. I'm using K1 (i don't have K2 on my PC atm) and I am compiling it as a K1 script.

ForeverNight
06-18-2008, 08:20 PM
Hmmm.... I can't help you here, sorry.

Just hang tight, and hope that people that understand scripting will get over here. Sorry!

Da_Man_2423
06-18-2008, 08:25 PM
void main()
{
TakeGoldFromCreature(200, GetPCSpeaker(), TRUE);
}

Direct from a K1 script. I don't know how much different GetPCSpeaker is from GetFirstPC but this is the script that's used to take 200 credits from you when you land on Tatooine.

EnderWiggin
06-18-2008, 08:26 PM
Try this one. It seems to work for others.

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

_EW_

EDIT:: @Da_man: That returns true, it can't be right. This isn't a conditional.

ForeverNight
06-18-2008, 08:28 PM
I was just gonna post that! But, just make it GetFirstPC() instead of GetPCSpeaker and that should do it!

@EW: What it does is destroy the credits instead of putting them in the takers inventory. It's not a conditional.

Ferc Kast
06-18-2008, 08:31 PM
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. :)

JediMaster76
06-18-2008, 08:32 PM
Well, Da_Man's script compiles successfully, but EnderWiggin's doesn't. Hmm. And I can't use Da_Man's script b/c its a conditional, correct?

*Edit - Thanks Kast, works perfectly :) Thanks for the help, everybody!

EnderWiggin
06-18-2008, 08:33 PM
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_

Da_Man_2423
06-18-2008, 08:37 PM
That was the exact script I was about to post...:)

Yeah, had just tested mine without the true conditional and it works, so yeah.

Scripting is a swing and miss thing with me.

deathdisco
06-19-2008, 02:00 AM
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.
// - bDestroy: If this is TRUE, the caller will not get the gold. Instead, the
// gold will be destroyed and will vanish from the game.
void TakeGoldFromCreature(int nAmount, object oCreatureToTakeFrom, int bDestroy=FALSE);

Darth InSidious
06-19-2008, 06:34 AM
I'd recommend a script that looks more like this, myself:


void main()
{
object oPC = GetFirstPC();

TakeGoldFromCreature(1000, oPC);
}

AFAIK, you get odd errors if you try to nest script functions directly...

stoffe
06-19-2008, 06:44 AM
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);
}

HdVaderII
06-19-2008, 06:14 PM
I ran into this problem a while ago. I worked it out myself, but that's weird that nobody has even mentioned it before. Sometimes it's good when you have to figure how to fix things yourself, though.