Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Question Script


Choseal
 Share

Recommended Posts

Hello, and thank you for your time!

I am making a script in which a npc asks me something, and depending on their answer, (Yes or no) they will get a different answer.

This is what it said in the command list:
Call Prompt(index, question, case script)
- but I didnt get the explanation.

So could anyone give me a example of how I should make one? I probably don't need alot of details, just an example.

How I thought It should be:
Sub Harald(Index)
  Call Prompt(Index, "My daughter..is she safe..?", 0)
    Case 0
  Call PlayerMsg(Index, hm..I will grant you these weapons, 1)
    End If
    Case 1
  Call PlayerMsg(Index, hm..I will not grant you these weapons, 1)
    End If
    Exit Sub

And then make a Scripted NPC with the following script:
Call Harald(Index)
Link to comment
Share on other sites

```
Sub Harald
  Call Prompt(Index, "My daughter..is she safe..?", 0)
End Sub

Sub PlayerPrompt(Index, Prompt, Value)
If Prompt = 6 Then
Select Case Value
Case 0
Call PlayerMsg(Index, "Yes message", 1)
Exit Sub
End Select
Else
Select Case Value
Case 0
Call PlayerMsg(Index, "No Message", 1)
Exit Sub
End Select
End If
End Sub

```
–Akselj
Link to comment
Share on other sites

Thank you!

Just one question though, I just have to add those subs, and then make a scripted npc like this:

Sub ScriptedNPC(index, Script)
Select Case Script
    Case 0
    Call Harald
    End If
End Select
End Sub

I just noticed it says Call Harald..x3

Edit: It asks the question, then it says: This is a Yes answer, or This is a No answer. Am I doing something wrong?
Link to comment
Share on other sites

Ok, i've made this script, but after the question, it just stops, could you please take a look at it? (Ps: Yes, I did fill in all these parts in my main: (index, ITEM NUMBER, VALUE, DURA))

Sub PlayerPrompt(Index, Prompt, Value)
If Prompt = 6 Then
Select Case Value
Case 0
Call PlayerMsg(Index, "…", 1)
Call PlayerMsg(Index, "I shall bequeath that sword to you", 1)
                                If GetPlayerClass(Index) > 0
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
                                If GetPlayerClass(Index) > 1
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
                                If GetPlayerClass(Index) > 2
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
                                If GetPlayerClass(Index) > 3
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
                                If GetPlayerClass(Index) > 4
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
                                If GetPlayerClass(Index) > 5
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
Exit Sub
End Select
Else
Select Case Value
Case 0
Call PlayerMsg(Index, "...", 1)
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
Call PlayerMsg(Index, "...", 1)
                              If INT(rand(4,1))=0 then
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a good item here, a really good one
                            Else
                              If INT(rand(4,1))=1 then
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a good item here, a really good one
                            Else
                              If INT(rand(4,1))=2 then
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a good item here, a really good one
                            Else
                              If INT(rand(4,1))=3 then
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a good item here, a really good one
                            Else
                              If INT(rand(4,1))=4 then
                                Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a good item here, a really good one
                            Else
                                End if
                                End if
                                End if
                                End if

Exit Sub
End Select 
End If
End Sub
Link to comment
Share on other sites

All of your If-Then cases are wrong.
Eg,
If GetPlayerClass(Index) > 0
should be:
If GetPlayerClass(Index) = 0 Then

And you can't have all those Else's and stuff lined up like that either, here is what's going on (haven't checked the other part, just the first part):
![](http://i44.tinypic.com/wbvreh.jpg)

Of course, you forgot ALL of the *Then and the "End If" too…
So the first part, would actually be like this:

                                If GetPlayerClass(Index) = 0 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                Else
                                   If GetPlayerClass(Index) = 1 Then
                                      Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                   Else
                                      If GetPlayerClass(Index) = 2 Then
                                         Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                      Else
                                         If GetPlayerClass(Index) = 3 Then
                                            Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                         Else
                                            If GetPlayerClass(Index) = 4 Then
                                               Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                            Else
                                               If GetPlayerClass(Index) = 5 Then
                                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                               Else
                                                  Exit Sub
                                               End If
                                            End If
                                         End If
                                      End If
                                   End If
                                End If

But why even use the "Else"?  It's potentially a waste in processing.. Instead, just do this:

                                If GetPlayerClass(Index) = 0 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 1 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 2 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 3 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 4 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 5 Then
                                   Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

I haven't checked the syntax or logic of the rest, but that first part is an issue.

EDIT:
Also, why are you converting the random number between 4 and 1, into an integer, if it's already an integer?
Link to comment
Share on other sites

Wow, thank you, I added what you said and it now looks like this:

Sub PlayerPrompt(Index, Prompt, Value)
If Prompt = 6 Then
Select Case Value
Case 0
Call PlayerMsg(Index, "…", 1)
Call PlayerMsg(Index, "I shall bequeath that sword to you", 1)
                                If GetPlayerClass(Index) = 0 Then
                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 1 Then
                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 2 Then
                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 3 Then
                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 4 Then
                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If

                                If GetPlayerClass(Index) = 5 Then
                                  Call giveplayeritem(index, ITEM NUMBER, VALUE, DURA) 'Add a strong but not TOO special weapon here
                                End If 
Exit Sub
Else
Select Case Value
Case 0
Call PlayerMsg(Index, "...", 1)
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
Call PlayerMsg(Index, "...", 1)
                              If INT(rand(4,1)) = 1 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

                              If INT(rand(4,1)) = 2 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

                              If INT(rand(4,1)) = 3 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

                              If INT(rand(4,1)) = 4 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If
Exit Sub
End Select 
End If
End Sub

I'm only a beginner though, and I didnt get that last part, I didn't know how to make a "Pick random ?" script, so I copied it from the random warp script in the script index.
Link to comment
Share on other sites

Okay.  The INT() part, is meant to take a string (characters) and convert it into a number; but it's already a number.  I suppose you could leave it in though…

Also, it's very ineffency, and you'll end up with undesirable results; I'll explain.
It goes around the first time:
If INT(rand(4,1)) = 1 Then
_Let's say it returns a number between 4 and 1 = 3.  That's not equal to 1, so it goes on to the next_

If INT(rand(4,1)) = 2 Then
_It runs again, this time returns 4; let's go to the next_

If INT(rand(4,1)) = 3 Then
_It runs again, this time returning 2; let's go to the next_

If INT(rand(4,1)) = 4 Then
_It runs this last time, returning 1.  Nothing has happened_.

A better solution, would be to just calculate the random number once:

                              Dim random
                              random = INT(rand(4,1))

                              If random  = 1 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

                              If random = 2 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

                              If random = 3 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

                              If random = 4 Then
                                Call giveplayeritem(index, 1, 1, 1) 'Add a good item here, a really good one
                              End If

Also, where did you get the giveplayeritem sub from?
Link to comment
Share on other sites

Nevermind that Giveplayeritem sub, I saw it in a topic and automaticly assumed it was already coded into Eclipse..

For now I replaced it with PlayerMsg :P

But it's still not working:

```
Sub PlayerPrompt(Index, Prompt, Value)
If Prompt = 6 Then
Select Case Value
Case 0
Call PlayerMsg(Index, "...", 1)
Call PlayerMsg(Index, "I shall bequeath that sword to you", 1)
                                If GetPlayerClass(Index) = 0 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 1 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 2 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 3 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 4 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 5 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If 
Exit Sub
Else
Select Case Value
Case 0
Call PlayerMsg(Index, "...", 1)
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
Call PlayerMsg(Index, "...", 1)
                              Dim random
                              random = INT(rand(4,1))

                              If random  = 1 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 2 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 3 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 4 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If
Exit Sub
End Select 
End If
End Sub
```
Thanks once again for your time!
Link to comment
Share on other sites

A quick glance at the syntax, and you still haven't got an End Select.

If you want Giveplayeritem though, I don't have that, but I do have GiveItem; the sub to install and the instructions on how to call it, can be found here:
http://www.touchofdeathforums.com/smf/index.php?topic=28174.0

Now, I re-worked your script, but I didn't fix the syntax errors (I didn't add the End Select, etc); instead, I changed the aligning around, so you can see the structure easier:

> **Sub** **PlayerPrompt**(Index, Prompt, Value)
> **If** Prompt = 6 **Then**
> **Select** **Case** Value
> **Case** 0
> **Call** **PlayerMsg**(Index, "…", 1)
> **Call** **PlayerMsg**(Index, "I shall bequeath that sword to you", 1)
> **If** GetPlayerClass(Index) = 0 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** GetPlayerClass(Index) = 1 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** GetPlayerClass(Index) = 2 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** GetPlayerClass(Index) = 3 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** GetPlayerClass(Index) = 4 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** GetPlayerClass(Index) = 5 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**  
>          **Exit Sub**
> **Else**
> **Select** **Case** Value
> **Case** 0
> **Call** **PlayerMsg**(Index, "…", 1)
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **Call** **PlayerMsg**(Index, "…", 1)
> Dim random
> random = INT(**Rand**(4,1))
> **If** random  = 1 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** random = 2 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** random = 3 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **If** random = 4 **Then**
> **Call** **PlayerMsg**(Index, "I shall not bequeath those swords to you", 1)
> **End If**
> **Exit Sub**
> **End **Select****
> **End If**
> **End Sub**

Take a good look at the above code.

The first part, you see a Select Case, but… No "End Select" (refer to the second part, where that part does have an end select).  Unless you put that End Select, it will just keep looking for more cases

@LinuZ_:

> Hey Amiral, what program do you use for illustrating the code like that?

Microsoft Visio 2007
Link to comment
Share on other sites

Ok, that's fixed, but now, nomatter what I choose, it will execute both of the answer and will not give the items..

When I click yes, it sais, Shall not, and I Shall bequeath those swords to you, and does not give a item.

When I click no, it sais: I Shall not bequeath those swords to you, I Shall not bequeath those swords to you, and again, does not give a item.
Link to comment
Share on other sites

@Choseal:

> Ok, that's fixed, but now, nomatter what I choose, it will execute both of the answer and will not give the items..
>
> When I click yes, it sais, Shall not, and I Shall bequeath those swords to you, and does not give a item.
>
> When I click no, it sais: I Shall not bequeath those swords to you, I Shall not bequeath those swords to you, and again, does not give a item.

Post up your working version of the PlayerPrompt sub.
Link to comment
Share on other sites

Sorry, but what do you mean? I replaced the Playerprompt sub with that script.

Like this:

```
Sub PlayerPrompt(Index, Prompt, Value)
If Prompt = 6 Then
Select Case Value
Case 0
Call PlayerMsg(Index, "...", 1)
Call PlayerMsg(Index, "I shall bequeath that sword to you", 1)
                                If GetPlayerClass(Index) = 0 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 1 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 2 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 3 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 4 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 5 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                  End If 
                    Exit Sub                             
            End Select
Else
Select Case Value
Case 0
Call PlayerMsg(Index, "...", 1)
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
Call PlayerMsg(Index, "...", 1)
                              Dim random
                              random = INT(rand(4,1))

                              If random  = 1 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 2 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 3 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 4 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If
Exit Sub
End Select 
End If
End Sub
```
And I call it with:
```
Sub ScriptedNPC(index, Script)
Select Case Script
    Case 0
    Call Harald(Index)
End Select
End Sub
```
And this is the Sub:
```
Sub Harald(Index)
  Call Prompt(Index, "I shall ask you a question, Is my daughter safe and sound?", 0)
End Sub
```
Link to comment
Share on other sites

That's exactly what I wanted.

Okay, I'm going to re-post that sub, with differnt parts hilighted.
Red = When person answers "No"
Green = When person asnwers "Yes"

And you'll see why what happens, happens, when the player answers "Yes" and "no":

Sub PlayerPrompt(Index, Prompt, Value)
  If Prompt = 6 Then
      Select Case Value
        Case 0
**Call PlayerMsg(Index, "…", 1)
            Call PlayerMsg(Index, "I shall bequeath that sword to you", 1)
                              If GetPlayerClass(Index) = 0 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 1 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 2 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 3 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 4 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                End If

                                If GetPlayerClass(Index) = 5 Then
                                  Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                                  End If
                            Exit Sub**        
                    End Select
  Else
      Select Case Value
        Case 0
**            Call PlayerMsg(Index, "…", 1)
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
            Call PlayerMsg(Index, "...", 1)
                              Dim random
                              random = INT(rand(4,1))

                              If random  = 1 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 2 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 3 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If

                              If random = 4 Then
                                Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)
                              End If
        Exit Sub**
      End Select
  End If
End Sub

Notice in both parts, all it's doing is saying "Call PlayerMsg(Index, "I shall not bequeath those swords to you", 1)"
Link to comment
Share on other sites

I was reading over the script yesterday on my PSP, and yes, you are right, I accidentally replaced the Give Item Sub with the PlayerMsg, but I couldnt reply, my PSP doesn't let me >.<
Anyways, the script is finally working :D

Thank you for your patience, I've learned alot from the both of you! :D
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...