complicated script (SOLVED)

Started by AndersM, Tue 01/02/2005 19:38:31

Previous topic - Next topic

AndersM

Heres the story: The hero talks to a barman, and in one of the dialoge options he orders a drink. the barman then says $10, please ' and the dialogue ends, so the player can pay, or leave whitout paying. But now my scriting knowledge ends.

There must be  the folowing options:

the character have $10 credis, and pays. (and gets the drink)
the character have $10 credis, and does not pay (barman gets mad)
the character does not have $10 (barman gets mad)

BUT if the player havn't ordered a drink, the the click with the $10 on the barman should not result in anything!

help?



Pumaman

When the player orders a drink, set a variable to 1. Then when you use the money on the barman, check the variable's value and respond appropriately.

Without being more specific about what you've tried and what your scripting ability is, I can't really help further.

AndersM

I've never used variables before, but i'll try...

I used som vierd home-made version  if charcter-has-inventori-item / and / else -thing that did not work at all, even if the editor accepted the code...

Scorpiorus

Yeah, here is the logic you may probably want to use:

QuoteThe hero talks to a barman, and in one of the dialoge options he orders a drink. the barman then says $10, please ' and the dialogue ends, so the player can pay, or leave whitout paying.
In the appropriate dialog script:
set-globalint 200 1 // sets GlobalInt#200 = 1


Quotethe character have $10 credis, and pays. (and gets the drink)
Quotethe character does not have $10 (barman gets mad)
on click barman with money:

if (GetGlobalInt(200) == 1) // if GlobalInt#200 = 1
{
Ã,  Ã,  int pc = GetPlayerCharacter();
Ã,  Ã,  if (character[pc].inv[MONEY_ITEM] >= 10)
Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  character[pc].inv[MONEY_ITEM] -= 10;
Ã,  Ã,  Ã,  Ã,  DisplaySpeech(BARMAN, "Here is your drink!");
Ã,  Ã,  Ã,  Ã,  AddInventory(DRINK_ITEM_NUMBER);
Ã,  Ã,  Ã,  Ã,  SetGlobalInt(200, 0); // sets GlobalInt#200 = 0
Ã,  Ã,  }
Ã,  Ã,  else
Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  DisplaySpeech(BARMAN, "Hey, you are short of cash!");
Ã,  Ã,  }
}
else
{
Ã,  Ã,  Display("What do you want to give him cash for?");
}

Quotethe character have $10 credis, and does not pay (barman gets mad)
character leaves the room:

if (GetGlobalInt(200) == 1)
{
Ã,  Ã,  DisplaySpeech(BARMAN, "Hey, why did you order a drink then??!");
Ã,  Ã,  SetGlobalInt(200, 0); // sets GlobalInt#200 = 0
}

AndersM

Thanx  Scorpiorus . i used a modifyed version of your script, and it works fine... i think...  thanx again

SMF spam blocked by CleanTalk