Venorize Posted August 29, 2009 Author Share Posted August 29, 2009 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 SelectEnd Sub``` Link to comment Share on other sites More sharing options...
JayT Posted August 29, 2009 Share Posted August 29, 2009 @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.htmlthen 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 SelectEnd Sub``` Link to comment Share on other sites More sharing options...
Venorize Posted August 29, 2009 Author Share Posted August 29, 2009 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 More sharing options...
JayT Posted August 29, 2009 Share Posted August 29, 2009 ok hold 1 min…. i have this is my main that works so i copy n paste it for you :) Link to comment Share on other sites More sharing options...
JayT Posted August 29, 2009 Share Posted August 29, 2009 ```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 More sharing options...
Venorize Posted August 29, 2009 Author Share Posted August 29, 2009 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 More sharing options...
Guest Posted August 29, 2009 Share Posted August 29, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now