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

Simple quest? SIMPLE???


viesty
 Share

Recommended Posts

Okay, this is my problem-
when i try to add this basic script:
```
Sub ScriptedNPC(index, Script)
Select Case Script
    Case 0
        If CheckInventoryForItem(index, 2) = true Then
            Call TakeItem(index, 2, 0)
            Call GiveItem(index, 3, 0)
            Call PlayerMsg(index, "Congrats quest complete.", 4)
        Else
            Call PlayerMsg(index, "You don't have item 2", 4)
        End If
End Select
End Sub
```
And I put npc on script 0, and attack it, it brings me a message- NPCz work.
What the hell is wrong?

It looks like this-
![](http://img8.imageshack.us/img8/3112/shithaaben.png)
Link to comment
Share on other sites

You have two case 0
I'm assuming that because the first case 0 has call playermsg(index, "NPCz work", 15) that it's sending that message and ignoring the second case 0
Try replacing the old case 0

(If that works… that would make my first actual scripting advice... scary...)
Link to comment
Share on other sites

Which version of the main.txt are you using?  Because that doesn't look like EE's main.txt

Anyway, you forgot to have "Case Else" in the Case statement (not sure if it it's needed or not), and you forgot to add the Exit Sub command.

Here's a screenshot of my main.txt, with that part:
![](http://i43.tinypic.com/ilk7s9.png)
Link to comment
Share on other sites

replace EVERYTHING in the scripted NPC section with this
```
'**************************************************************
' Executes whenever a scripted NPC does an action.
Sub ScriptedNPC(Index, Script)
'**************************************************************
Select Case Script

    Case 0
        If CheckInventoryForItem(index, 2) = true Then
            Call TakeItem(index, 2, 0)
            Call GiveItem(index, 3, 0)
            Call PlayerMsg(index, "Congrats quest complete.", 4)
        Else
            Call PlayerMsg(index, "You don't have item 2", 4)
        End If
Exit sub
Case Else
Call PlayerMsg(Index, "No NPC script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub
```
Works like a charm.

And if it doesn't work for you, don't blame me because you don't know how to follow simple instructions. It's not my fault if you don't know what i'm talking about.
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...