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

Item check: How to?


Pasketi
 Share

Recommended Posts

So i am doing a sailing-part to my game, and i need to script something like this:

Player goes to a pier and script automatically changes his sprite to a boat and warps him to sea-map. When moving to shore, the player-sprite changes back and player is warped to pier. This works!

Problem: I need to prevent those who haven't bought a ship to board it. So i have an item number 3 as a Light sloop, and i want my script to check if that's there. If it's not, the player won't get aboard and stays on that island.

Help please?
Link to comment
Share on other sites

Ok that code is working perfectly! Now other news:

I use the boat script (modified) and this is the problem:

1\. I go down the pier, game checks if i have a currency "Light Sloop" with me (if not, i'm thrown away and they say i have to get a boat), transform to a boat and warp to sea and gain a stat bonus (little different from land-battle).
2\. I go back to island and de-transform back to my old sprite and de-gain a stat bonus i got earlier.

New island, 2 new cases on scripted tile (new island dock and launch), nothing works! What is the problem?

Used:
Boat Script
Check item -script
Original stat gain script (from that stat + script idk what it's called)
PlayerWarp
Sub ScriptedTile

When i start my server tomorrow, i can put here the code.
Link to comment
Share on other sites

Ok i got now the scrip *YAWN* here is the working copy:

```
Sub ScriptedTile(Index, Script)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
Exit Sub
Case 2
  If CanTake(Index, 3, 1) = False Then
      Call PlayerMsg(index, "You have not permissions to board the ship! You need a ship!", 4)
  Call PlayerWarp(index, 1, 3, 17)
  Else
    If int(GetPlayerSprite(index)) <> 80 Then
      Call PutVar("accounts\" & GetPlayerLogin(index) &".ini", "CHAR" & GetPlayerCharNum(index), "noboat", GetPlayerSprite(index))
      Call SetPlayerSprite(index, 80)
      Call PlayerMsg(index, "You begin to set sail from isle Gordas.", 2)     
      Call PlayerWarp(index, 10, 25, 15)
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) + 50)
      Call SetPlayerDEF(Index, GetPlayerDEF(Index) + 50)
      Call SendPlayerData(index)   
                End If
  End If
Case 3 
  Dim Sprite
  Sprite = int(GetVar("accounts\" & GetPlayerLogin(index) &".ini", "CHAR" & GetPlayerCharNum(index), "noboat"))
  If int(GetPlayerSprite(index)) = 80 Then
      Call SetPlayerSprite(index, Sprite)
      Call PlayerMsg(index, "You have docked to Isle Gordas.", 2)
      Call PlayerWarp(index, 1, 1, 17)
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) - 50)
      Call SetPlayerDEF(Index, GetPlayerDEF(Index) - 50)
      Call SendPlayerData(index)
  Else
      Call PlayerMsg(index, "Step onto the water to begin sailing", 2)
  End If
Case Else
Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub     

End Select
End Sub
```
And this doesnt work:

```
Sub ScriptedTile(Index, Script)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
Exit Sub
Case 2
  If CanTake(Index, 3, 1) = False Then
      Call PlayerMsg(index, "You have not permissions to board the ship! You need a ship!", 4)
  Call PlayerWarp(index, 1, 3, 17)
  Else
    If int(GetPlayerSprite(index)) <> 80 Then
      Call PutVar("accounts\" & GetPlayerLogin(index) &".ini", "CHAR" & GetPlayerCharNum(index), "noboat", GetPlayerSprite(index))
      Call SetPlayerSprite(index, 80)
      Call PlayerMsg(index, "You begin to set sail from isle Gordas.", 2)     
      Call PlayerWarp(index, 10, 25, 15)
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) + 50)
      Call SetPlayerDEF(Index, GetPlayerDEF(Index) + 50)
      Call SendPlayerData(index)   
                End If
  End If
Case 3 
  Dim Sprite
  Sprite = int(GetVar("accounts\" & GetPlayerLogin(index) &".ini", "CHAR" & GetPlayerCharNum(index), "noboat"))
  If int(GetPlayerSprite(index)) = 80 Then
      Call SetPlayerSprite(index, Sprite)
      Call PlayerMsg(index, "You have docked to Isle Gordas.", 2)
      Call PlayerWarp(index, 1, 1, 17)
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) - 50)
      Call SetPlayerDEF(Index, GetPlayerDEF(Index) - 50)
      Call SendPlayerData(index)
  Else
      Call PlayerMsg(index, "Step onto the water to begin sailing", 2)
  End If

Case 4
  If CanTake(Index, 3, 1) = False Then
      Call PlayerMsg(index, "You have not permissions to board the ship! You need a ship!", 4)
  Call PlayerWarp(index, 1, 3, 17)
  Else
    If int(GetPlayerSprite(index)) <> 80 Then
      Call PutVar("accounts\" & GetPlayerLogin(index) &".ini", "CHAR" & GetPlayerCharNum(index), "noboat", GetPlayerSprite(index))
      Call SetPlayerSprite(index, 80)
      Call PlayerMsg(index, "You begin to set sail from Savage Isle.", 2)     
      Call PlayerWarp(index, 10, 18, 13)
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) + 50)
      Call SetPlayerDEF(Index, GetPlayerDEF(Index) + 50)
      Call SendPlayerData(index)   
                End If
  End If
Case 5 
  Dim Sprite
  Sprite = int(GetVar("accounts\" & GetPlayerLogin(index) &".ini", "CHAR" & GetPlayerCharNum(index), "noboat"))
  If int(GetPlayerSprite(index)) = 80 Then
      Call SetPlayerSprite(index, Sprite)
      Call PlayerMsg(index, "You have docked to Savage Isle.", 2)
      Call PlayerWarp(index, 15, 15, 27)
      Call SetPlayerSTR(Index, GetPlayerSTR(Index) - 50)
      Call SetPlayerDEF(Index, GetPlayerDEF(Index) - 50)
      Call SendPlayerData(index)
  Else
      Call PlayerMsg(index, "Step onto the water to begin sailing", 2)
  End If
Case Else
Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub     

End Select
End Sub
```
I didn't find a problem here…. did you??
Link to comment
Share on other sites

Umm… i just copy-pasted those two cases and changed them a bit but... nothing above. If i use bottom, nothing happens in scipted tile. If upper code, all works fine...

and no, i don't have 2 scriptedtile subs. These are one and same, but modified
Link to comment
Share on other sites

hmmm…. never thought of that... i'll try tomorrow... you know if it works in 11 hours... Need my sleep :icon_sleep:

Thanks in advantage

EDIT: By the way, can i put this to script database after it's working? It's quite nice script...
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...