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

Scripting a Quiz


Recommended Posts

I want to make a quiz in my game, but I'm not sure how to. I don't really care how it's done or what it looks like as long as it works, but the original plan I had in mind would be for a window to pop up, prompting the player… something like this:

1 + 1 = ?
a) 7
b) 2
c) Penguins will conquer the world
(The player types their answer here)

If that can't be done, I'll take any other form, really. I just want the quiz to be in the game.
Link to comment
Share on other sites

How Exactly do you want this shown. When You Log-on when you type in /quiz or something like that or when you step on a scripted tile. Maybe a quiz/poll booth.

Also who do you want to be able to make quiz's like this?
Link to comment
Share on other sites

Heheheh… I probably should've explained all of that. >.>

I wanted the quiz to be for stepping on a tile OR for talking to an NPC.

I don't want players to be able to make quizzes. I just want them to take quizzes for classes in things such as Gunner classes or Swordsman classes. I wanted the quizzes to be easy multiple-choice questions.
Link to comment
Share on other sites

@Admiral:

> This can be done.
>
> Just store the questions and answers in ini files, and use GetVar to output the text onto Custom Menus, or run the quiz in the chatbox using Call PlayerMsg.

Alright. I'll try that out.
Um… one more thing... is there a way to get what a player types in the chatbox and store it in an ini file?
Link to comment
Share on other sites

Use query boxes. It'd be pretty easy. Just call the query box with the question and check their response versus the correct answer. You can check out my tutorial on query boxes here:

[Prompts and QueryBoxes](http://www.touchofdeathforums.com/smf/index.php/topic,15084.0.html)
Link to comment
Share on other sites

OK. Just ooooone more problem.

```
Call PlayerMsg(index, "Options", YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q1C1"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q1C2"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q1C3"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q1C4"), YELLOW)
Call PlayerQueryBox(index,GetVar("scripts\Quiz\Gunner.ini","Beginner","Q1"), 3)

Call PlayerMsg(index, "Options", YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2C1"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2C2"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2C3"), YELLOW)
Call PlayerQueryBox(index,GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2"), 0)
```
When a character steps on a tile with this code, most of the time, a Runtime Error (400) occurs. Once in a while, it doesn't happen, though. I'm pretty sure it's running the first QueryBox, then running the next one right after… without giving the player a chance to type in the first QueryBox. How do I stop this from happening?
Link to comment
Share on other sites

Well, you're calling them all in the same sub, silly. Have the second query box appear after you enter your response from the first.
```
  If Prompt = 3 Then     
        'Do something with their answer value     
        Call PlayerQueryBox(index, "Next question thing", 0) 
  End If
```That would be within your QueryBox sub.
Link to comment
Share on other sites

Um… like this?

```
Case 3
Select Case Value
Case "D" 
If Prompt = 3 Then   
Dim Score
Call PlayerMsg(index, "Correct!", 15)
Score=PutVar("accounts\"&GetPlayerLogin(index)&"\"&GetPlayerName(index)&".ini","Temp","Quiz",GetVar("accounts\"&GetPlayerLogin(index)&"\"&GetPlayerName(index)&".ini","Temp","Quiz")+1)
Call PlayerMsg(index, "Options", YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2C1"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2C2"), YELLOW)
Call PlayerMsg(index, GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2C3"), YELLOW)
Call PlayerQueryBox(index,GetVar("scripts\Quiz\Gunner.ini","Beginner","Q2"), 0)
End If

Case Else
Call PlayerMsg(index, "That is incorrect!", 12)
End Select
```
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...