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

God's Inventory Script Error…


viciousdead
 Share

Recommended Posts

Ok, I got the script to load correctly, but now I'm having problems with God's New Inventory script..

```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: Main.txt '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Constants & Globals
' Color Constants
Public Const BLACK = 0
Public Const BLUE = 1
Public Const GREEN = 2
Public Const CYAN = 3
Public Const RED = 4
Public Const MAGENTA = 5
Public Const BROWN = 6
Public Const GREY = 7
Public Const DARKGREY = 8
Public Const BRIGHTBLUE = 9
Public Const BRIGHTGREEN = 10
Public Const BRIGHTCYAN = 11
Public Const BRIGHTRED = 12
Public Const PINK = 13
Public Const YELLOW = 14
Public Const WHITE = 15

' Admin Constants
Public Const ADMIN_PLAYER = 0
Public Const ADMIN_MONITOR = 1
Public Const ADMIN_MAPPER = 2
Public Const ADMIN_DEVELOPER = 3
Public Const ADMIN_CREATOR = 4
Public Const ADMIN_OWNER = 5

' Alignment constants
Public Const LEFT = 0
Public Const RIGHT = 1
Public Const CENTER = 2

' Stat constants
Public Const STAT_STRENGHT = 0
Public Const STAT_DEFENCE = 1
Public Const STAT_MAGIC = 2
Public Const STAT_SPEED = 3

' Key constants
Public Const KEY_PAGEUP = 1
Public Const KEY_PAGEDOWN = 4
Public Const KEY_DELETE = 2
Public Const KEY_END = 3

' Element type constants
Public Const ELEMENT_PICTURE = 1
Public Const ELEMENT_FIELD = 2
Public Const ELEMENT_LABEL = 3

' Tile type constants
Public Const TILE_TYPE_WALKABLE = 0
Public Const TILE_TYPE_BLOCKED = 1
Public Const TILE_TYPE_WARP = 2
Public Const TILE_TYPE_ITEM = 3
Public Const TILE_TYPE_NPCAVOID = 4
Public Const TILE_TYPE_KEY = 5
Public Const TILE_TYPE_KEYOPEN = 6
Public Const TILE_TYPE_HEAL = 7
Public Const TILE_TYPE_KILL = 8
Public Const TILE_TYPE_SHOP = 9
Public Const TILE_TYPE_CBLOCK = 10
Public Const TILE_TYPE_ARENA = 11
Public Const TILE_TYPE_SOUND = 12
Public Const TILE_TYPE_SPRITE_CHANGE = 13
Public Const TILE_TYPE_SIGN = 14
Public Const TILE_TYPE_DOOR = 15
Public Const TILE_TYPE_NOTICE = 16
Public Const TILE_TYPE_CHEST = 17
Public Const TILE_TYPE_CLASS_CHANGE = 18
Public Const TILE_TYPE_SCRIPTED = 19
'Public Const TILE_TYPE_NPC_SPAWN = 20
Public Const TILE_TYPE_HOUSE = 21
'Public Const TILE_TYPE_CANON = 22
Public Const TILE_TYPE_BANK = 23
'Public Const TILE_TYPE_SKILL = 24
Public Const TILE_TYPE_GUILDBLOCK = 25
Public Const TILE_TYPE_HOOKSHOT = 26
Public Const TILE_TYPE_WALKTHRU = 27
Public Const TILE_TYPE_ROOF = 28
Public Const TILE_TYPE_ROOFBLOCK = 29
Public Const TILE_TYPE_ONCLICK = 30
Public Const TILE_TYPE_LOWER_STAT = 31

' MAX constants.
Public Const MAX_INVSLOTS = 24

' Data.ini (config) settings.
Public GameName
Public WebSite
Public Port
Public HPRegen
Public HPTimer
Public MPRegen
Public MPTimer
Public SPRegen
Public SPTimer
Public NPCRegen
Public Scrolling
Public ScrollX
Public ScrollY
Public Scripting
Public ScriptErrors
Public PaperDoll
Public SaveTime
Public SpriteSize
Public Custom
Public PKMinLvl
Public Level
Public Email
Public VerifyAcc
Public Classes
Public Stat1
Public Stat2
Public Stat3
Public Stat4
Public SPAttack
Public SPRunning

' Data.ini (max) settings.
Public MAX_PLAYERS
Public MAX_ITEMS
Public MAX_NPCS
Public MAX_SHOPS
Public MAX_SPELLS
Public MAX_MAPS
Public MAX_MAP_ITEMS
Public MAX_GUILDS
Public MAX_GUILD_MEMBERS
Public MAX_EMOTICONS
Public MAX_ELEMENTS
Public MAX_LEVEL
Public MAX_PARTY_MEMBERS
Public MAX_SCRIPTSPELLS
Public MAX_MAP_X
Public MAX_MAP_Y
Public MAX_STAT

' MOTD
Public MOTD

' Events
' Initialisation & Reloading
#include #include #include ' Interactivity
#include #include #include #include #include #include ' Joining & Leaving
#include #include #include ' Death
#include #include #include #include #include ' Attacks
#include #include #include ' Scripted
#include #include #include #include ' Leveling
#include #include ' Misc
#include #include #include ' Modules
#include #include #include #include #include #include ' Functions
' General
#include #include '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: Inventory.ess '
' Author: Stephan J.R. van Schaik '
' Date: September 6th, 2009. '
' Version: 1.2.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: AddPlayerInvItem '
' Brief: adds an item to the inventory. '
' Parameters: '
' Index: the index number of the player. '
' Item: the item to add. '
' Durability: the durability of the item to add. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function AddPlayerInvItem(Index, Item, Durability)
Dim Amount

Amount = 0

For Slot = 1 To MAX_INVSLOTS
If GetPlayerInvItemNum(Index, Slot) = 0 Then
Call SetPlayerInvItemNum(Index, Slot, Item)
Call SetPlayerInvItemValue(Index, Slot, 0)
Call SetPlayerInvItemDur(Index, Slot, Durability)
Call SendInventoryUpdate(Index, Slot)

AddPlayerInvItem = True

Exit Function
End If
Next

AddPlayerInvItem = False
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: AddPlayerInvStackableItem '
' Brief: adds a stackable item to the inventory. '
' Parameters: '
' Index: the index number of the player. '
' Item: the item to add. '
' Amount: the amount to add. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function AddPlayerInvStackableItem(Index, Item, Amount)
Dim Amount

Amount = 0

For Slot = 1 To MAX_INVSLOTS
If GetPlayerInvItemNum(Index, Slot) = Item Then
Call SetPlayerInvItemNum(Index, Slot, Item)
Call SetPlayerInvItemValue(Index, Slot, 0)
Call SetPlayerInvItemDur(Index, Slot, 0)
Call SendInventoryUpdate(Index, Slot)

AddPlayerInvStackableItem = True

Exit Function
End If
Next

For Slot = 1 To MAX_INVSLOTS
If GetPlayerInvItemNum(Index, Slot) = 0 Then
Call SetPlayerInvItemNum(Index, Slot, Item)
Call SetPlayerInvItemValue(Index, Slot, Amount)
Call SetPlayerInvItemDur(Index, Slot, 0)
Call SendInventoryUpdate(Index, Slot)

AddPlayerInvStackableItem = True

Exit Function
End If
Next

AddPlayerInvStackableItem = False
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: CountPlayerInvItem '
' Brief: counts an item in the inventory. '
' Parameters: '
' Index: the index number of the player. '
' Item: the item to count. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CountPlayerInvItem(Index, Item)
Dim Amount

Amount = 0

For Slot = 1 To MAX_INVSLOTS
If GetPlayerInvItemNum(Index, Slot) = Item Then
If GetPlayerInvItemValue(Index, Slot) = 0 Then
Amount = Amount + 1
Else
Amount = Amount + GetPlayerInvItemValue(Index, Slot)
End If
End If
Next

CountPlayerInvItem = Amount
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: RemovePlayerInvItem '
' Brief: removes an item from the inventory. '
' Parameters: '
' Index: the index number of the player. '
' Item: the item to remove. '
' Amount: the amount to remove. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub RemovePlayerInvItem(Index, Item, Amount)
For Slot = 1 To MAX_INVSLOTS
If GetPlayerInvItemNum(Index, Slot) = Item Then
If GetPlayerInvItemValue(Index, Slot) = 0 Then
Amount = Amount - 1

Call SetPlayerInvItemNum(Index, Slot, 0)
Call SetPlayerInvItemValue(Index, Slot, 0)
Call SetPlayerInvItemDur(Index, Slot, 0)
Call SendInventoryUpdate(Index, Slot)
ElseIf Amount >= GetPlayerInvItemValue(Index, Slot) Then
Amount = Amount - GetPlayerInvItemValue(Index, Slot)

Call SetPlayerInvItemNum(Index, Slot, 0)
Call SetPlayerInvItemValue(Index, Slot, 0)
Call SetPlayerInvItemDur(Index, Slot, 0)
Call SendInventoryUpdate(Index, Slot)
Else
Call SetPlayerInvItemValue(Index, Slot, GetPlayerInvItemValue(Index, Slot) - Amount)
Call SendInventoryUpdate(Index, Slot)

Amount = 0
End If

If Amount <= 0 Then
Exit Sub
End If
End If
Next
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: GetPlayerInvSlots '
' Brief: gets the free inventory slots. '
' Parameters: '
' Index: the index number of the player. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GetPlayerInvSlots(Index)
Dim Amount

Amount = 0

For Slot = 1 To MAX_INVSLOTS
If GetPlayerInvItemNum(Index, Slot) = 0 Then
Amount = Amount + 1
End If
Next

GetPlayerInvSlots = Amount
End Function

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: ClearPlayerInv '
' Brief: clears the inventory of a player. '
' Parameters: '
' Index: the index number of the player. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ClearPlayerInv(Index)
Dim Amount

Amount = 0

For Slot = 1 To MAX_INVSLOTS
Call SetPlayerInvItemNum(Index, Slot, 0)
Call SetPlayerInvItemValue(Index, Slot, 0)
Call SetPlayerInvItemDur(Index, Slot, 0)
Next

Call SendInventory(Index)
End Sub

' For testing the script.
#include

```
Anyone know why the scripts arn't working?
Link to comment
Share on other sites

@נυиgℓєтσє:

> More details please?

Here is my Scripted Item.ESS:
```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: ScriptedItem.ess '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: ScriptedItem '
' Brief: executes when somebody uses an item. '
' Parameters: '
' Index: the index of the player. '
' Script: the script to execute. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ScriptedItem(Index, Script, Slot)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
Exit Sub

Case 1
If CanTake(Index, 22, 1) Then
Call TakeItem(Index, 22, 1)
Call PlayerWarp(Index, 11, 9, 5)
Call PlayerMsg(Index, "You have been warped to Rex.", BRIGHTRED)
Exit Sub

Case 2
Dim PlayerEXP
If CanTake(Index, 23, 1) Then
Call TakeItem(Index, 23, 1)
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call PlayerMsg(Index, "You have been gained a level, by drinking the Kuro

Potion", YELLOW)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Exit Sub

Case 3
If CanTake(Index, 25, 1) Then
Call TakeItem(Index, 25, 1)
z = Rand(1, 300)
If z <= 100 And z >= 50 Then
Call GiveItem(Index, 7, 10000)
Call PlayerMsg(Index, "You won Basic Sword.", WHITE)
End If
If z <= 49 And z >= 11 Then
Call GiveItem(Index, 15, 10000)
Call PlayerMsg(Index, "You won Steel Sword.", WHITE)
End If
If z < 10 Then
Call GiveItem(Index, 54, 10000)
Call GlobalMsg(GetPlayerName(Index) & " has won Soltion, congratulations!", YELLOW)
End If
If z >= 101 Then
Call PlayerMsg(Index, "Sorry, you won nothing..", BRIGHTRED)
End If
Exit Sub

Case 4
If CanTake(Index, 32, 1) Then
Call TakeItem(Index, 32, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 100)
Call PlayerMsg(Index, "You have gained 100 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 5
If CanTake(Index, 33, 1) Then
Call TakeItem(Index, 33, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000)
Call PlayerMsg(Index, "You have gained 1000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 6
If CanTake(Index, 34, 1) Then
Call TakeItem(Index, 34, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 10000)
Call PlayerMsg(Index, "You have gained 10000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 7
If CanTake(Index, 35, 1) Then
Call TakeItem(Index, 35, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 100000)
Call PlayerMsg(Index, "You have gained 100000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 8
If CanTake(Index, 37, 1) Then
Call TakeItem(Index, 37, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000000)
Call PlayerMsg(Index, "You have gained 1000000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
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

```
I changed my main again to see if I could fix it..
```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: Main.txt '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Constants & Globals
' Color Constants
Public Const BLACK = 0
Public Const BLUE = 1
Public Const GREEN = 2
Public Const CYAN = 3
Public Const RED = 4
Public Const MAGENTA = 5
Public Const BROWN = 6
Public Const GREY = 7
Public Const DARKGREY = 8
Public Const BRIGHTBLUE = 9
Public Const BRIGHTGREEN = 10
Public Const BRIGHTCYAN = 11
Public Const BRIGHTRED = 12
Public Const PINK = 13
Public Const YELLOW = 14
Public Const WHITE = 15

' Admin Constants
Public Const ADMIN_PLAYER = 0
Public Const ADMIN_MONITOR = 1
Public Const ADMIN_MAPPER = 2
Public Const ADMIN_DEVELOPER = 3
Public Const ADMIN_CREATOR = 4
Public Const ADMIN_OWNER = 5

' Alignment constants
Public Const LEFT = 0
Public Const RIGHT = 1
Public Const CENTER = 2

' Stat constants
Public Const STAT_STRENGHT = 0
Public Const STAT_DEFENCE = 1
Public Const STAT_MAGIC = 2
Public Const STAT_SPEED = 3

' Key constants
Public Const KEY_PAGEUP = 1
Public Const KEY_PAGEDOWN = 4
Public Const KEY_DELETE = 2
Public Const KEY_END = 3

' Element type constants
Public Const ELEMENT_PICTURE = 1
Public Const ELEMENT_FIELD = 2
Public Const ELEMENT_LABEL = 3

' Tile type constants
Public Const TILE_TYPE_WALKABLE = 0
Public Const TILE_TYPE_BLOCKED = 1
Public Const TILE_TYPE_WARP = 2
Public Const TILE_TYPE_ITEM = 3
Public Const TILE_TYPE_NPCAVOID = 4
Public Const TILE_TYPE_KEY = 5
Public Const TILE_TYPE_KEYOPEN = 6
Public Const TILE_TYPE_HEAL = 7
Public Const TILE_TYPE_KILL = 8
Public Const TILE_TYPE_SHOP = 9
Public Const TILE_TYPE_CBLOCK = 10
Public Const TILE_TYPE_ARENA = 11
Public Const TILE_TYPE_SOUND = 12
Public Const TILE_TYPE_SPRITE_CHANGE = 13
Public Const TILE_TYPE_SIGN = 14
Public Const TILE_TYPE_DOOR = 15
Public Const TILE_TYPE_NOTICE = 16
Public Const TILE_TYPE_CHEST = 17
Public Const TILE_TYPE_CLASS_CHANGE = 18
Public Const TILE_TYPE_SCRIPTED = 19
'Public Const TILE_TYPE_NPC_SPAWN = 20
Public Const TILE_TYPE_HOUSE = 21
'Public Const TILE_TYPE_CANON = 22
Public Const TILE_TYPE_BANK = 23
'Public Const TILE_TYPE_SKILL = 24
Public Const TILE_TYPE_GUILDBLOCK = 25
Public Const TILE_TYPE_HOOKSHOT = 26
Public Const TILE_TYPE_WALKTHRU = 27
Public Const TILE_TYPE_ROOF = 28
Public Const TILE_TYPE_ROOFBLOCK = 29
Public Const TILE_TYPE_ONCLICK = 30
Public Const TILE_TYPE_LOWER_STAT = 31

' MAX constants.
Public Const MAX_INVSLOTS = 24

' Data.ini (config) settings.
Public GameName
Public WebSite
Public Port
Public HPRegen
Public HPTimer
Public MPRegen
Public MPTimer
Public SPRegen
Public SPTimer
Public NPCRegen
Public Scrolling
Public ScrollX
Public ScrollY
Public Scripting
Public ScriptErrors
Public PaperDoll
Public SaveTime
Public SpriteSize
Public Custom
Public PKMinLvl
Public Level
Public Email
Public VerifyAcc
Public Classes
Public Stat1
Public Stat2
Public Stat3
Public Stat4
Public SPAttack
Public SPRunning

' Data.ini (max) settings.
Public MAX_PLAYERS
Public MAX_ITEMS
Public MAX_NPCS
Public MAX_SHOPS
Public MAX_SPELLS
Public MAX_MAPS
Public MAX_MAP_ITEMS
Public MAX_GUILDS
Public MAX_GUILD_MEMBERS
Public MAX_EMOTICONS
Public MAX_ELEMENTS
Public MAX_LEVEL
Public MAX_PARTY_MEMBERS
Public MAX_SCRIPTSPELLS
Public MAX_MAP_X
Public MAX_MAP_Y
Public MAX_STAT

' MOTD
Public MOTD

' Events
' Initialisation & Reloading
#include #include #include ' Interactivity
#include #include #include #include #include #include ' Joining & Leaving
#include #include #include ' Death
#include #include #include #include #include ' Attacks
#include #include #include ' Scripted
#include #include #include #include ' Leveling
#include #include ' Misc
#include #include #include ' Modules
#include #include #include #include #include #include ' Functions
' General
#include #include '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: BCInventory.ess                              '
' Author: Stephan J.R. van Schaik ([email protected])  '
' Date: September 6th, 2009.                          '
' Version: 1.2.0                                    '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function GetFreeSlots(Index)
  GetFreeSlots = GetPlayerInvSlots(Index)
End Function

Sub GiveItem(Index, Number, Durability)
  Call AddPlayerInvItem(Index, Number, Durability)
End Sub

Sub GiveCurrency(Index, Number, Amount)
  Call AddPlayerInvStackableItem(Index, Number, Amount)
End Sub

Function CanTake(Index, Number, Amount)
  If CountPlayerInvItem(Index, Number) >= Amount Then
      CanTake = True
  Else
      CanTake = False
  End If
End Function

Sub TakeItem(Index, Number, Amount)
  Call RemovePlayerInvItem(Index, Number, Amount)
End Sub

' For testing the script.
#include

```
The error I'm getting now is TYPE: Expected Statement CODE: Case 2… On the ScriptedItem..
Link to comment
Share on other sites

Change it to this:
```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: ScriptedItem.ess '
' Author: Stephan J.R. van Schaik '
' Date: August 30th, 2009. '
' Version: 1.0.0 '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: ScriptedItem '
' Brief: executes when somebody uses an item. '
' Parameters: '
' Index: the index of the player. '
' Script: the script to execute. '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ScriptedItem(Index, Script, Slot)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
Exit Sub

Case 1
If CanTake(Index, 22, 1) Then
Call TakeItem(Index, 22, 1)
Call PlayerWarp(Index, 11, 9, 5)
Call PlayerMsg(Index, "You have been warped to Rex.", BRIGHTRED)
Exit Sub

Case 2
'Dim PlayerEXP
If CanTake(Index, 23, 1) Then
Call TakeItem(Index, 23, 1)
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call PlayerMsg(Index, "You have been gained a level, by drinking the Kuro Potion", YELLOW)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Exit Sub

Case 3
If CanTake(Index, 25, 1) Then
Call TakeItem(Index, 25, 1)
z = Rand(1, 300)
If z <= 100 And z >= 50 Then
Call GiveItem(Index, 7, 10000)
Call PlayerMsg(Index, "You won Basic Sword.", WHITE)
End If
If z <= 49 And z >= 11 Then
Call GiveItem(Index, 15, 10000)
Call PlayerMsg(Index, "You won Steel Sword.", WHITE)
End If
If z < 10 Then
Call GiveItem(Index, 54, 10000)
Call GlobalMsg(GetPlayerName(Index) & " has won Soltion, congratulations!", YELLOW)
End If
If z >= 101 Then
Call PlayerMsg(Index, "Sorry, you won nothing..", BRIGHTRED)
End If
Exit Sub

Case 4
If CanTake(Index, 32, 1) Then
Call TakeItem(Index, 32, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 100)
Call PlayerMsg(Index, "You have gained 100 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 5
If CanTake(Index, 33, 1) Then
Call TakeItem(Index, 33, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000)
Call PlayerMsg(Index, "You have gained 1000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 6
If CanTake(Index, 34, 1) Then
Call TakeItem(Index, 34, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 10000)
Call PlayerMsg(Index, "You have gained 10000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 7
If CanTake(Index, 35, 1) Then
Call TakeItem(Index, 35, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 100000)
Call PlayerMsg(Index, "You have gained 100000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
End If
Exit Sub

Case 8
If CanTake(Index, 37, 1) Then
Call TakeItem(Index, 37, 1)
Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000000)
Call PlayerMsg(Index, "You have gained 1000000 experiance.", YELLOW)
If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
Call SendPlayerData(Index)
Call SendStats(Index)
Call SendHP(Index)
Call SendMP(Index)
Call SendSP(Index)
Call SendPTS(Index)
Else
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

@Alatar:

> Change it to this:
> ```
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Module: ScriptedItem.ess '
> ' Author: Stephan J.R. van Schaik '
> ' Date: August 30th, 2009. '
> ' Version: 1.0.0 '
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Function: ScriptedItem '
> ' Brief: executes when somebody uses an item. '
> ' Parameters: '
> ' Index: the index of the player. '
> ' Script: the script to execute. '
> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> Sub ScriptedItem(Index, Script, Slot)
> Select Case Script
> Case 0
> Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
> Exit Sub
>
> Case 1
> If CanTake(Index, 22, 1) Then
> Call TakeItem(Index, 22, 1)
> Call PlayerWarp(Index, 11, 9, 5)
> Call PlayerMsg(Index, "You have been warped to Rex.", BRIGHTRED)
> Exit Sub
>
> Case 2
> 'Dim PlayerEXP
> If CanTake(Index, 23, 1) Then
> Call TakeItem(Index, 23, 1)
> Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
> Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
> Call PlayerMsg(Index, "You have been gained a level, by drinking the Kuro Potion", YELLOW)
> Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
> Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
> Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
> Call SendPlayerData(Index)
> Call SendStats(Index)
> Call SendHP(Index)
> Call SendMP(Index)
> Call SendSP(Index)
> Call SendPTS(Index)
> Exit Sub
>
> Case 3
> If CanTake(Index, 25, 1) Then
> Call TakeItem(Index, 25, 1)
> z = Rand(1, 300)
> If z <= 100 And z >= 50 Then
> Call GiveItem(Index, 7, 10000)
> Call PlayerMsg(Index, "You won Basic Sword.", WHITE)
> End If
> If z <= 49 And z >= 11 Then
> Call GiveItem(Index, 15, 10000)
> Call PlayerMsg(Index, "You won Steel Sword.", WHITE)
> End If
> If z < 10 Then
> Call GiveItem(Index, 54, 10000)
> Call GlobalMsg(GetPlayerName(Index) & " has won Soltion, congratulations!", YELLOW)
> End If
> If z >= 101 Then
> Call PlayerMsg(Index, "Sorry, you won nothing..", BRIGHTRED)
> End If
> Exit Sub
>
> Case 4
> If CanTake(Index, 32, 1) Then
> Call TakeItem(Index, 32, 1)
> Call SetPlayerExp(Index, GetPlayerExp(Index) + 100)
> Call PlayerMsg(Index, "You have gained 100 experiance.", YELLOW)
> If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
> Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
> Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
> Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
> Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
> Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
> Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
> Call SendPlayerData(Index)
> Call SendStats(Index)
> Call SendHP(Index)
> Call SendMP(Index)
> Call SendSP(Index)
> Call SendPTS(Index)
> Else
> End If
> Exit Sub
>
> Case 5
> If CanTake(Index, 33, 1) Then
> Call TakeItem(Index, 33, 1)
> Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000)
> Call PlayerMsg(Index, "You have gained 1000 experiance.", YELLOW)
> If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
> Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
> Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
> Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
> Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
> Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
> Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
> Call SendPlayerData(Index)
> Call SendStats(Index)
> Call SendHP(Index)
> Call SendMP(Index)
> Call SendSP(Index)
> Call SendPTS(Index)
> Else
> End If
> Exit Sub
>
> Case 6
> If CanTake(Index, 34, 1) Then
> Call TakeItem(Index, 34, 1)
> Call SetPlayerExp(Index, GetPlayerExp(Index) + 10000)
> Call PlayerMsg(Index, "You have gained 10000 experiance.", YELLOW)
> If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
> Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
> Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
> Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
> Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
> Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
> Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
> Call SendPlayerData(Index)
> Call SendStats(Index)
> Call SendHP(Index)
> Call SendMP(Index)
> Call SendSP(Index)
> Call SendPTS(Index)
> Else
> End If
> Exit Sub
>
> Case 7
> If CanTake(Index, 35, 1) Then
> Call TakeItem(Index, 35, 1)
> Call SetPlayerExp(Index, GetPlayerExp(Index) + 100000)
> Call PlayerMsg(Index, "You have gained 100000 experiance.", YELLOW)
> If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
> Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
> Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
> Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
> Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
> Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
> Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
> Call SendPlayerData(Index)
> Call SendStats(Index)
> Call SendHP(Index)
> Call SendMP(Index)
> Call SendSP(Index)
> Call SendPTS(Index)
> Else
> End If
> Exit Sub
>
> Case 8
> If CanTake(Index, 37, 1) Then
> Call TakeItem(Index, 37, 1)
> Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000000)
> Call PlayerMsg(Index, "You have gained 1000000 experiance.", YELLOW)
> If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
> Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
> Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
> Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
> Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
> Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
> Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
> Call SendPlayerData(Index)
> Call SendStats(Index)
> Call SendHP(Index)
> Call SendMP(Index)
> Call SendSP(Index)
> Call SendPTS(Index)
> Else
> 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

> ```

Ugh, got the same error..  :icon_crap:
Link to comment
Share on other sites

Hmm, weird. I think that it could be the Case Else, that you have in another line the "problem.", WHITE)", just put it all in one line.

Like:
```
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

```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: ScriptedItem.ess              '
' Author: Stephan J.R. van Schaik   '
' Date: August 30th, 2009.              '
' Version: 1.0.0                  '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: ScriptedItem              '
' Brief: executes when somebody uses an item.        '
' Parameters:                    '
'  Index: the index of the player.            '
'  Script: the script to execute.            '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ScriptedItem(Index, Script, Slot)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
        Exit Sub

      Case 1
        If CanTake(Index, 22, 1) Then
        Call TakeItem(Index, 22, 1)
        Call PlayerWarp(Index, 11, 9, 5)
        Call PlayerMsg(Index, "You have been warped to Rex.", BRIGHTRED)
        Exit Sub

      Case 2
      'Dim PlayerEXP
        If CanTake(Index, 23, 1) Then
            Call TakeItem(Index, 23, 1)
            Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
            Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
            Call PlayerMsg(Index, "You have been gained a level, by drinking the Kuro Potion", YELLOW)
            Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
            Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
            Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
            Call SendPlayerData(Index)
            Call SendStats(Index)
            Call SendHP(Index)
            Call SendMP(Index)
            Call SendSP(Index)
            Call SendPTS(Index)
      Exit Sub

      Case 3
      If CanTake(Index, 25, 1) Then
      Call TakeItem(Index, 25, 1)
      z = Rand(1, 300)
      If z <= 100 And z >= 50 Then
        Call GiveItem(Index, 7, 10000)
        Call PlayerMsg(Index, "You won Basic Sword.", WHITE)
        End If
      If z <= 49 And z >= 11 Then
        Call GiveItem(Index, 15, 10000)
        Call PlayerMsg(Index, "You won Steel Sword.", WHITE)
        End If
      If z < 10 Then
        Call GiveItem(Index, 54, 10000)
        Call GlobalMsg(GetPlayerName(Index) & " has won Soltion, congratulations!", YELLOW)
        End If
      If z >= 101 Then
        Call PlayerMsg(Index, "Sorry, you won nothing..", BRIGHTRED)
        End If
      Exit Sub

      Case 4
        If CanTake(Index, 32, 1) Then
        Call TakeItem(Index, 32, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 100)
        Call PlayerMsg(Index, "You have gained 100 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        Else
        End If
      Exit Sub

      Case 5
        If CanTake(Index, 33, 1) Then
        Call TakeItem(Index, 33, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000)
        Call PlayerMsg(Index, "You have gained 1000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        Else
        End If
      Exit Sub

      Case 6
        If CanTake(Index, 34, 1) Then
        Call TakeItem(Index, 34, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 10000)
        Call PlayerMsg(Index, "You have gained 10000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        Else
        End If
      Exit Sub

      Case 7
        If CanTake(Index, 35, 1) Then
        Call TakeItem(Index, 35, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 100000)
        Call PlayerMsg(Index, "You have gained 100000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        Else
        End If
      Exit Sub

      Case 8
        If CanTake(Index, 37, 1) Then
        Call TakeItem(Index, 37, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000000)
        Call PlayerMsg(Index, "You have gained 1000000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        Else
        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

```Still not working..  :lipsrsealed:
Same error as before, this started happening when I changed god's inventory script..
Link to comment
Share on other sites

Ehh, you have unended if-statements in all of those cases. It has nothing to do with Godlord's scripts. The "expected statement" error you were getting was from the lack of a closing "if" in case 1, and should you have fixed it, there were also errors in all the cases afterward, too. Here's a fix with all ifs added.

```
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Module: ScriptedItem.ess              '
' Author: Stephan J.R. van Schaik   '
' Date: August 30th, 2009.              '
' Version: 1.0.0                  '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Function: ScriptedItem              '
' Brief: executes when somebody uses an item.        '
' Parameters:                    '
'  Index: the index of the player.            '
'  Script: the script to execute.            '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub ScriptedItem(Index, Script, Slot)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
        Exit Sub

      Case 1
        If CanTake(Index, 22, 1) Then
        Call TakeItem(Index, 22, 1)
        Call PlayerWarp(Index, 11, 9, 5)
        Call PlayerMsg(Index, "You have been warped to Rex.", BRIGHTRED)
        End If
        Exit Sub

      Case 2
      'Dim PlayerEXP
        If CanTake(Index, 23, 1) Then
            Call TakeItem(Index, 23, 1)
            Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
            Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
            Call PlayerMsg(Index, "You have been gained a level, by drinking the Kuro Potion", YELLOW)
            Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
            Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
            Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
            Call SendPlayerData(Index)
            Call SendStats(Index)
            Call SendHP(Index)
            Call SendMP(Index)
            Call SendSP(Index)
            Call SendPTS(Index)
        End If
      Exit Sub

      Case 3
      If CanTake(Index, 25, 1) Then
      Call TakeItem(Index, 25, 1)
      z = Rand(1, 300)
      If z <= 100 And z >= 50 Then
        Call GiveItem(Index, 7, 10000)
        Call PlayerMsg(Index, "You won Basic Sword.", WHITE)
        End If
      If z <= 49 And z >= 11 Then
        Call GiveItem(Index, 15, 10000)
        Call PlayerMsg(Index, "You won Steel Sword.", WHITE)
        End If
      If z < 10 Then
        Call GiveItem(Index, 54, 10000)
        Call GlobalMsg(GetPlayerName(Index) & " has won Soltion, congratulations!", YELLOW)
        End If
      If z >= 101 Then
        Call PlayerMsg(Index, "Sorry, you won nothing..", BRIGHTRED)
      End If
      End If
      Exit Sub

      Case 4
        If CanTake(Index, 32, 1) Then
        Call TakeItem(Index, 32, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 100)
        Call PlayerMsg(Index, "You have gained 100 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        End If
        End If
      Exit Sub

      Case 5
        If CanTake(Index, 33, 1) Then
        Call TakeItem(Index, 33, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000)
        Call PlayerMsg(Index, "You have gained 1000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        End If
        End If
      Exit Sub

      Case 6
        If CanTake(Index, 34, 1) Then
        Call TakeItem(Index, 34, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 10000)
        Call PlayerMsg(Index, "You have gained 10000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        End If
        End If
      Exit Sub

      Case 7
        If CanTake(Index, 35, 1) Then
        Call TakeItem(Index, 35, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 100000)
        Call PlayerMsg(Index, "You have gained 100000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        End If
        End If
      Exit Sub

      Case 8
        If CanTake(Index, 37, 1) Then
        Call TakeItem(Index, 37, 1)
        Call SetPlayerExp(Index, GetPlayerExp(Index) + 1000000)
        Call PlayerMsg(Index, "You have gained 1000000 experiance.", YELLOW)
        If GetPlayerExp(Index) = GetPlayerNextLevel(Index) Then
        Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)
        Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 3)
        Call SetPlayerExp(Index, GetPlayerExp(Index) - PlayerExp)
        Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
        Call SetPlayerMP(Index, GetPlayerMaxMP(Index))
        Call SetPlayerSP(Index, GetPlayerMaxSP(Index))
        Call SendPlayerData(Index)
        Call SendStats(Index)
        Call SendHP(Index)
        Call SendMP(Index)
        Call SendSP(Index)
        Call SendPTS(Index)
        End If
        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

```
For future reference, tab your code properly. This would've been a simple visual recognition to solve the problem with clean code standards. Trust me, it's worth the extra time.
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...