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

What did I do wrong? [Solved]


Venorize
 Share

Recommended Posts

I used to do these 2d games and script a long time ago.. i'm returning to it because this engine looks really solid compared to past ones i've worked with..

So I'm learning the scripting on this and… well I have an issue.

I'm trying to make an item that when used, the item teleports the person to a specific location on map #45, then destroys the item.

The teleport part works, but right after the person is teleported, nothing else happens. The item remains in their invintory and there's no message on their screen.

What did I do wrong here? (This is my entire scripted item section);

```
Sub ScriptedItem(Index, Script)
Select Case Script
Case 0
    Call PlayerWarp(Index, 45, 15, 15)     
        Call TakeItem(Index, 75, 1)
Call PlayerMsg(Index, "The Gateway teleports you to Tenal, and is destroyed.", WHITE)
Exit Sub 

Case Else
Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub
```
Link to comment
Share on other sites

@Venorize:

> I used to do these 2d games and script a long time ago.. i'm returning to it because this engine looks really solid compared to past ones i've worked with..
>
> So I'm learning the scripting on this and… well I have an issue.
>
> I'm trying to make an item that when used, the item teleports the person to a specific location on map #45, then destroys the item.
>
> The teleport part works, but right after the person is teleported, nothing else happens. The item remains in their invintory and there's no message on their screen.
>
> What did I do wrong here? (This is my entire scripted item section);
>
> ```
> Sub ScriptedItem(Index, Script)
> Select Case Script
> Case 0
>     Call PlayerWarp(Index, 45, 15, 15)     
>         Call TakeItem(Index, 75, 1)
> Call PlayerMsg(Index, "The Gateway teleports you to Tenal, and is destroyed.", WHITE)
> Exit Sub 
>  
> Case Else
> Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)
> Exit Sub
> End Select
> End Sub
> ```

Welcome to Eclipse!! ok make sure you have http://www.touchofdeathforums.com/smf/index.php/topic,28174.0.html

then try this
```
Sub ScriptedItem(Index, Script)
Select Case Script
Case 0
    If CanTake(Index, 45, 1) = True Then
    Call PlayerWarp(Index, 45, 15, 15)     
        Call TakeItem(Index, 75, 1)
Call PlayerMsg(Index, "The Gateway teleports you to Tenal, and is destroyed.", WHITE)
    End If
Exit Sub 

Case Else
Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub
```
Link to comment
Share on other sites

After putting in the inventory script and using the script you gave me, nothing happens now; the item has no function anymore.  :cry:

Why can I not use the original script? Shouldn't two call functions work in the same sub? Doesn't make sense to me..

after changing around the order of it..
```
Case 0
    Call PlayerMsg(Index, "The Gateway teleports you to Tenal and is destroyed.", WHITE)
    Call PlayerWarp(Index, 45, 15, 15)
    Call TakeItem(Index, 75, 1)
Exit Sub
```The message and the warp are working correctly now.. but the script will still not take away the item from the player…
Link to comment
Share on other sites

```
case 0

      Call playerwarp(Index, 12, 3, 14)
      Call TakeItem(Index, 45, 1)
      Call playermsg(index, "The scroll fizzles up as you drift into a different location.", 1)

Exit Sub
```
thats what i have lol…. sorry bout leading you on :) didnt think it was that simple
Link to comment
Share on other sites

Got it working with the script you first posted…

I figured you sounded like you knew what you were talking about, so I looked up parts of the script you gave me... apparently Godlord suggests in many topics to make the If statement not actually take an item.

So instead of
```
CanTake(Index, 75, 1) = True Then
```
I used
```
CanTake(Index, 75, 0) = True Then
```
and it works now. Thanks for your help very much, I appreciate it =)

Anyways, the "Call TakeItem" doesn't seem to work without the If statement to check if it exists first… sadly. But at least it works now. So I'm using this as my final code;

```
Case 0
  If CanTake(Index, 75, 0) = True Then
    Call PlayerMsg(Index, "The Gateway teleports you to Tenal and is destroyed.", WHITE)
    Call PlayerWarp(Index, 45, 15, 15)
    Call TakeItem(Index, 75, 1)
  Else
    Call PlayerMsg(Index, "This item does not exist.", WHITE)
  End If
Exit Sub

```
Link to comment
Share on other sites

Use this.

```
Case 3
x = GETPLAYERX(INDEX)
y = GETPLAYERY(INDEX)
If GetAttribute(GetPlayerMap(Index), x, y) = 1 Then
Call PlayerMsg(index, "The potion breaks...", 14)
Call Take_Item(Index, 118, 1)
Else
Call PlayerWarp(Index, 44, 10, 9)
Call Take_Item(Index, 118, 1)
Call PlayerMsg(index, "You drink from the potion and it takes you to another location.", 14)
End If
        Exit Sub
```
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...