dialog_request problem

Started by , Sun 16/07/2006 00:02:26

Previous topic - Next topic

AlexWilson

i've looked around and can't find the solution to this problem (most of the other topics similar to this are about older versions i think), but it's probably very simple, and i'm just being an idiot (i'm a complete beginner at this).

i wanted to add some stuff to the dialogs, mainly so that the player gets an inventory item.

i used the run-script thing in the dialog, then had this in the global script

function dialog_request (int value){
Ã,  Ã, if (value == 1){
Ã,  Ã,  Ã,  character[1].AddInventory(9);
Ã,  Ã, }
}

i made this following several examples I found, but it doesn't work, and i have no idea whyÃ,  ??? (but then i suppose i don't really understand why it WOULD work, eitherÃ,  ;))

thanks in advance for any help

Ubel

Well, the character[1] part is the problem. It's supposed to be character[(your character's script name here)]. For example (as in the default template the player character's name is EGO) character[EGO].

Or you could do it like this: cEgo. Both ways work the same. You could also use player.AddInventory to give the inventory item to the currently controlled character.

And by the way, there is a dialog script called add-inv, so you don't have to use dialog_request for that. :)

Ashen

#2
How does it 'not work'? Does the character not get the item, do they get the wrong item, does it crash (and if so, is there an error message), etc.

Some things to check:

Are you calling it right from the dialog (run-script 1)?
Character.AddInventory uses the SCRIPT O-NAME of the item, not it's number (player.AddInventory(iKey);, for example, rather than player.AddInventory(1);). Fix that, and see if it works then - this is most likely the problem, based on what you've posted.
Are you sure you're adding it to the right character? Using the Script O-Name is the clearest way, rather than relying on the numbers (cEgo or character[EGO] instead of character[0]). The character[0] method will work - provided you've used the right character number - it just isn't as obvious who it relates to, meaning mistakes are easier to make.
I know what you're thinking ... Don't think that.

AlexWilson

ahh, thanks (to both of youÃ,  :))!

i've used the add-inv script in the dialog now, but it was the use of the inventory number rather than the name that was the problem in the first place :)

sorted!

SMF spam blocked by CleanTalk