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

Got a few problems with scripts not working. [Sloved]


adr990
 Share

Recommended Posts

Hey all,

I've copied and pasted a few scripts into the right places of my Main.txt.
(Some of them needed GodLords Inventory Script. Which I did add. And extra maps with .ini files etc in it.)
But I got just small amount of the scripts to work.
May you guys could help me out of problems again. :)

I post my added/edited stuff in code tabs:
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
Exit Sub

Case 1
                If GetVar("Chest\" & GetPlayerName(index) & ".ini", "Chest", "Chest1") = "Have" Then
                Call playermsg(index, "Empty", 14)
              Exit Sub
            End if
              Call PutVar("Chest\" & GetPlayerName(index) & ".ini", "Chest", "Chest1", "Have")
                Call giveplayeritem(index, 1, 1000, 0)
              Call playermsg(index, "You found 1000gold!", 14)
              Exit Sub 

        Case 2
                    If CanTake(Index, 27, 1) Then
                    Call TakeItem(Index, 27, 1)
                    Call PlayerMsg(Index, "You have arrived in Gingerbread kingdom", WHITE)
                    Call Flash(Index,"Boat.swf")
                    Call PlayerWarp(Index, 41, 15, 15)
                    Else
                    Call PlayerMsg(Index, "You need a ticket to go in a boat!!", YELLOW)
                    End If
                    Exit Sub

Case 3
If getplayerlevel(indes) <80 Then
    Call blockPlayer(index)
End if
Exit Sub

    Case 4
    Dim Str
    Dim Def
    Dim Speed
    Dim Magi
    Dim TotalPoints
    Dim CurrentPoints
    Str = GetPlayerStr(Index)
    Def = GetPlayerDef(Index)
    Speed = GetPlayerSpeed(Index)
    Magi = GetPlayerMagi(Index)
    TotalPoints = Str + Def + Speed + Magi
    CurrentPoints = GetPlayerPoints(Index)   

    Call PlayerLevelUp(Index)
    Call SetPlayerStr(Index, 0)
    Call SetPlayerDef(Index, 0)
    Call SetPlayerSpd(Index, 0)
    Call SetPlayerMag(Index, 0)
    Call SetPlayerPoints(Index, CurrentPoints + TotalPoints)
    Call SendStats(Index)
    Call PlayerMsg(Index, "Your stat points have been reset. You now have " & GetPlayerPoints(Index) & " points to spend.", WHITE)
              Exit Sub
        Case 5                       
            Dim Str
            Dim Def
            Dim Spd
            Dim Mag
            Dim TotalPoints
            Dim CurrentPoints
            Str = GetPlayerSTR(Index)
            Def = GetPlayerDEF(Index)
            Spd = GetPlayerSPEED(Index)
            Mag = GetPlayerMAGI(Index)
            TotalPoints = Str + Def + Spd + Mag
            CurrentPoints = GetPlayerPOINTS(Index)
            Call PlayerLevelUp(Index)
            Call SetPlayerSTR(Index, 0)
            Call SetPlayerDEF(Index, 0)
            Call SetPlayerSPEED(Index, 0)
            Call SetPlayerMAGI(Index, 0)
            Call SetPlayerPOINTS(Index, CurrentPoints + TotalPoints)
            Call SendStats(Index)
            Call PlayerMsg(Index, "Your stat points have been reset. You now have " & GetPlayerPOINTS(Index) & " points to spend.", 10)
              Exit Sub

      Case Else
Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub
```
===================

```
Sub SetPlayerRealName(Index, name)
Call PutVar("accounts" & GetPlayerLogin(Index) & ".ini", "CHAR" & GetPlayerCharNum(Index), "RealName", name)
End Sub

Sub OnAttack(index)
Dim Checked
Checked = CheckIt(index)
If Checked = 1 Then
Call MiningMsg(index, Mine)
End If
End Sub

Sub GiveItem(index, item, value)
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = 0 Then
Call SetPlayerInvItemNum(index, SLOT, item)
Call SetPlayerInvItemValue(index, SLOT, value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub

Sub CheckIt(index)
Dim MiningSpotX
Dim MiningSpotY
Dim i
Dim memX
Dim MiningSpotM
i = 1
Do While i <= GetVar("Skills\Mining.ini", i ,"items")
MiningSpotX = GetVar("Skills\Mining.ini", i ,"X")
MiningSpotY = GetVar("Skills\Mining.ini", i ,"Y")
MiningSpotM = GetVar("Skills\Mining.ini", i ,"MAP")
memX = i
if GetPlayerMap(index) = MiningSpotM then
if MiningSpotY = Int(GetPlayerY(index) + 1) and MiningSpotX = Int(GetPlayerX(index) + 1) then
CheckIt = 1
i = 21
elseif MiningSpotY = Int(GetPlayerY(index) - 1) and MiningSpotX = Int(GetPlayerX(index) - 1) then
CheckIt = 1
i = 21
elseif MiningSpotY = Int(GetPlayerY(index) + 1) and MiningSpotX = Int(GetPlayerX(index) - 1) then
CheckIt = 1
i = 21
elseif MiningSpotY = Int(GetPlayerY(index) - 1) and MiningSpotX = Int(GetPlayerX(index) + 1) then
CheckIt = 1
i = 21
else
CheckIt = 0
i = Int(memX + 1)
end if
end if
loop
End Sub

Sub MiningMsg(index, stone)
Dim i
Dim Mlv
Dim change
Dim item
Dim val
If stone = 1 Then
If GetPlayerWeapon = GetVar("Skills\Mining.ini", i ,"weapon") Then
Call PlayerMsg(index, "You started with mining some ores", 12)
i = Rand(1, 10000)
Mlv = GetVar("Skills\DB.ini","GetPlayerName(index), "Mining")
change = GetVar("Skills\Change.ini", "Mining", Mlv & "-" & i)
change = mid(change, 1, 3) & "00"
max = GetVar("Skills\max.ini", "Mining", "MMAX")
item = GetVar("Skills\Mining.ini", i ,"item")
val = GetVar("Skills\Mining.ini", i ,"val")
If i >= change Then
Call PlayerMsg(index, "You mining some ores", 12)
Call GiveItem(index, item, val)
Call SetMiningExperience(index, GetVar("Skills\Mining.ini", i ,"exp"))
Else
Call PlayerMsg(index, "You failed with cutting some wood", 12)
End If
End If
End If
End Sub

Sub SetMiningExperience(index, exp)
Dim Mlv
Dim pexp
Dim max
Dim Mmax
Mlv = GetVar("Skills\DB.ini","GetPlayerName(index), "Mining")
Mmax = GetVar("Skills\max.ini", "Mining", "maxlv")
pexp = GetVar("Skills\DB.ini","GetPlayerName(index), "MiningExp")
max = GetVar("Skills\max.ini", "Mining", "maxexp" & Mlv)
if Int(pexp + exp) > max then
if Mlv < maxlv then
Call PutVar("Skills\DB.ini","GetPlayerName(index), "MiningExp", Int(exp - Int(max - pexp)))
Call PutVar("Skills\DB.ini","GetPlayerName(index), "Mining", Int(Mlv + 1))
Call PlayerMsg(index, "You gained a Mining level", 12)
elseif Mlv = maxlv then
Call PutVar("Skills\DB.ini","GetPlayerName(index), "MiningExp", 0)
Call PutVar("Skills\DB.ini","GetPlayerName(index), "Mining", maxlv)
end if
elseif Int(pexp + exp) <= max then
Call PutVar("Skills\DB.ini","GetPlayerName(index), "MiningExp", Int(pexp + exp))
end if
End Sub

    Function GetFreeSlots(Index)   
      Dim Slot
      Dim Slots

      Slot = 1
      Slots = 0

      Index = Int(Index)

      Do While Slot < 25 
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
            Slots = Slots + 1
          End If

          Slot = Slot + 1
      Loop

      GetFreeSlots = Slots
    End Function

    Sub GiveItem(Index, Number, Durability)
      Dim Slot

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Durability = Int(Durability)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
            Call SetPlayerInvItemNum(Index, Slot, Number)
            Call SetPlayerInvItemDur(Index, Slot, Durability)
            Call SendInventoryUpdate(Index, Slot)
            Exit Sub
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Sub GiveCurrency(Index, Number, Amount)
      Dim Slot
      Dim CurrentAmount

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
              CurrentAmount = GetPlayerInvItemValue(Index, Slot)
              Call SetPlayerInvItemValue(Index, Slot, CurrentAmount + Amount)
              Call SendInventoryUpdate(Index, Slot)
              Exit Sub
          End If

          Slot = Slot + 1
      Loop

            Slot = 1

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
              Call SetPlayerInvItemNum(Index, Slot, Number)
              Call SetPlayerInvItemValue(Index, Slot, Amount)
              Call SendInventoryUpdate(Index, Slot)
              Exit Sub
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Function CanTake(Index, Number, Amount)
      Dim Slot

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
            If GetPlayerInvItemValue(Index, Slot) >= Amount Then
                CanTake = True
                Exit Function
            End If
          End If

          Slot = Slot + 1
      Loop

      CanTake = False
    End Function

    Sub TakeItem(Index, Number, Amount)
      Dim Slot
      Dim CurrentAmount

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Slot = 1

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
              If GetPlayerInvItemValue(Index, Slot) >= Amount Then
                CurrentAmount = GetPlayerInvItemValue(Index, Slot)

                If CurrentAmount <= Amount Then
                    Call SetPlayerInvItemNum(Index, Slot, 0)
                    Call SetPlayerInvItemValue(Index, Slot, 0)
                    Call SetPlayerInvItemDur(Index, Slot, 0)
                    Call SendInventoryUpdate(Index, Slot)
                Else
                    Call SetPlayerInvItemValue(Index, Slot, CurrentAmount - Amount)
                    Call SendInventoryUpdate(Index, Slot)
                End If

                Exit Sub
              End If
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Function GetFreeSlots(Index)   
      Dim Slot
      Dim Slots

      Slot = 1
      Slots = 0

      Index = Int(Index)

      Do While Slot < 25 
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
            Slots = Slots + 1
          End If

          Slot = Slot + 1
      Loop

      GetFreeSlots = Slots
    End Function

    Sub GiveItem(Index, Number, Durability)
      Dim Slot

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Durability = Int(Durability)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
            Call SetPlayerInvItemNum(Index, Slot, Number)
            Call SetPlayerInvItemDur(Index, Slot, Durability)
            Call SendInventoryUpdate(Index, Slot)
            Exit Sub
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Sub GiveCurrency(Index, Number, Amount)
      Dim Slot
      Dim CurrentAmount

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
              CurrentAmount = GetPlayerInvItemValue(Index, Slot)
              Call SetPlayerInvItemValue(Index, Slot, CurrentAmount + Amount)
              Call SendInventoryUpdate(Index, Slot)
              Exit Sub
          End If

          Slot = Slot + 1
      Loop

            Slot = 1

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
              Call SetPlayerInvItemNum(Index, Slot, Number)
              Call SetPlayerInvItemValue(Index, Slot, Amount)
              Call SendInventoryUpdate(Index, Slot)
              Exit Sub
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Function CanTake(Index, Number, Amount)
      Dim Slot

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
            If GetPlayerInvItemValue(Index, Slot) >= Amount Then
                CanTake = True
                Exit Function
            End If
          End If

          Slot = Slot + 1
      Loop

      CanTake = False
    End Function

    Sub TakeItem(Index, Number, Amount)
      Dim Slot
      Dim CurrentAmount

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Slot = 1

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
              If GetPlayerInvItemValue(Index, Slot) >= Amount Then
                CurrentAmount = GetPlayerInvItemValue(Index, Slot)

                If CurrentAmount <= Amount Then
                    Call SetPlayerInvItemNum(Index, Slot, 0)
                    Call SetPlayerInvItemValue(Index, Slot, 0)
                    Call SetPlayerInvItemDur(Index, Slot, 0)
                    Call SendInventoryUpdate(Index, Slot)
                Else
                    Call SetPlayerInvItemValue(Index, Slot, CurrentAmount - Amount)
                    Call SendInventoryUpdate(Index, Slot)
                End If

                Exit Sub
              End If
          End If

          Slot = Slot + 1
      Loop
    End Sub

' Block Player Script
Sub blockPlayer(index)
  playerdir = GetPlayerDir(index)
  Select Case playerdir
        Case 0
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)+1)
        Case 1
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)-1)
        Case 2
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index)+1, GetPlayerY(index))
        Case 3
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index)-1, GetPlayerY(index))
  End Select
End Sub
```^Bottom of Main.txt stuff. (Added Sub stuff)

===============

```
' Executes when a player logs into the game.
Sub JoinGame(Index)a
If GetPlayerAccess(Index) = 0 Then
Call GlobalMsg(GetPlayerName(Index) & " has joined " & GameName & "!", GREY)
Else
Call GlobalMsg("Administrator " & GetPlayerName(Index) & " has joined " & GameName & "!", YELLOW)
End If

Call PlayerMsg(Index, "Welcome to " & GameName & "!", WHITE)

If LenB(MOTD) <> 0 Then
Call PlayerMsg(Index, "MOTD: " & MOTD, BRIGHTCYAN)
End If

Call SendWhosOnline(Index)
If GetVar("Skills\DB.ini","GetPlayerName(index), "Mining") = 0 Then
Call PutVar("Skills\DB.ini","GetPlayerName(index), "MiningExp", 0)
Call PutVar("Skills\DB.ini","GetPlayerName(index), "Mining", 1)
End If
End Sub

' Executes when a player logs out of the game.
Sub LeftGame(Index)
If GetPlayerAccess(Index) = 0 Then
Call GlobalMsg(GetPlayerName(Index) & " has left " & GameName & "!", GREY)
Else
Call GlobalMsg("Administrator " & GetPlayerName(Index) & " has left " & GameName & "!", YELLOW)
End If
End Sub
```
==================

I thought that was everything…
If you need my full Main.txt I will post it. :)

I can get the Chest Script, if stand of Scripted Title (Case 1)  working fine. :) Others not.

And all other added scripts not at all. :P

Thanks a lot in advance,
Adr990

Edit:
The Mining script is the Second Mining in this topic:
http://www.touchofdeathforums.com/smf/index.php/topic,10888.0.html
From Godlord, directly after the Woodcutting.
Link to comment
Share on other sites

New Scripted Tile:
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub

      Case 1
                  If GetVar("Chest\" & GetPlayerName(index) & ".ini", "Chest", "Chest1") = "Have" Then
                  Call PlayerMsg(index, "Empty", 14)
                    Exit Sub
                    End If
                    Call PutVar("Chest\" & GetPlayerName(index) & ".ini", "Chest", "Chest1", "Have")
                      Call GivePlayerItem(index, 1, 1000, 0)
                    Call PlayerMsg(index, "You found 1000gold!", 14)
                      Exit Sub

        Case 2
                    If CanTake(Index, 27, 1) Then
                    Call TakeItem(Index, 27, 1)
                    Call PlayerMsg(Index, "You have arrived in Gingerbread kingdom", WHITE)
                    Call Flash(Index,"Boat.swf")
                    Call PlayerWarp(Index, 41, 15, 15)
                    Else
                    Call PlayerMsg(Index, "You need a ticket to go in a boat!!", YELLOW)
                    End If
                    Exit Sub

Case 3
If GetPlayerLevel(index) < 80 Then
    Call BlockPlayer(index)
End If
Exit Sub

        Case 4                   
            Dim Str
            Dim Def
            Dim Spd
            Dim Mag
            Dim TotalPoints
            Dim CurrentPoints
            Str = GetPlayerSTR(Index)
            Def = GetPlayerDEF(Index)
            Spd = GetPlayerSPEED(Index)
            Mag = GetPlayerMAGI(Index)
            TotalPoints = Str + Def + Spd + Mag
            CurrentPoints = GetPlayerPOINTS(Index)
            Call PlayerLevelUp(Index)
            Call SetPlayerSTR(Index, 0)
            Call SetPlayerDEF(Index, 0)
            Call SetPlayerSPEED(Index, 0)
            Call SetPlayerMAGI(Index, 0)
            Call SetPlayerPOINTS(Index, CurrentPoints + TotalPoints)
            Call SendStats(Index)
            Call PlayerMsg(Index, "Your stat points have been reset. You now have " & GetPlayerPOINTS(Index) & " points to spend.", 10)
                      Exit Sub

          Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub

```
New bottom of the main.txt thing stuff:
```
Sub SetPlayerRealName(Index, name)
Call PutVar("accounts" & GetPlayerLogin(Index) & ".ini", "CHAR" & GetPlayerCharNum(Index), "RealName", name)
End Sub

Sub OnAttack(index)
Dim Checked
Checked = CheckIt(index)
If Checked = 1 Then
Call MiningMsg(index, Mine)
End If
End Sub

Sub GiveItem(index, item, value)
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = 0 Then
Call SetPlayerInvItemNum(index, SLOT, item)
Call SetPlayerInvItemValue(index, SLOT, value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub

Sub CheckIt(index)
Dim MiningSpotX
Dim MiningSpotY
Dim i
Dim memX
Dim MiningSpotM
i = 1
Do While i <= GetVar("Skills\Mining.ini", i ,"items")
MiningSpotX = GetVar("Skills\Mining.ini", i ,"X")
MiningSpotY = GetVar("Skills\Mining.ini", i ,"Y")
MiningSpotM = GetVar("Skills\Mining.ini", i ,"MAP")
memX = i
If GetPlayerMap(index) = MiningSpotM Then
If MiningSpotY = Int(GetPlayerY(index) + 1) And MiningSpotX = Int(GetPlayerX(index) + 1) Then
CheckIt = 1
i = 21
ElseIf MiningSpotY = Int(GetPlayerY(index) - 1) And MiningSpotX = Int(GetPlayerX(index) - 1) Then
CheckIt = 1
i = 21
ElseIf MiningSpotY = Int(GetPlayerY(index) + 1) And MiningSpotX = Int(GetPlayerX(index) - 1) Then
CheckIt = 1
i = 21
ElseIf MiningSpotY = Int(GetPlayerY(index) - 1) And MiningSpotX = Int(GetPlayerX(index) + 1) Then
CheckIt = 1
i = 21
Else
CheckIt = 0
i = Int(memX + 1)
End If
End If
Loop
End Sub

Sub MiningMsg(index, stone)
Dim i
Dim Mlv
Dim change
Dim item
Dim val
If stone = 1 Then
If GetPlayerWeapon = GetVar("Skills\Mining.ini", i ,"weapon") Then
Call PlayerMsg(index, "You started with mining some ores", 12)
i = Rand(1, 10000)
Mlv = GetVar("Skills\DB.ini", GetPlayerName(index), "Mining")
change = GetVar("Skills\Change.ini", "Mining", Mlv & "-" & i)
change = mid(change, 1, 3) & "00"
max = GetVar("Skills\max.ini", "Mining", "MMAX")
item = GetVar("Skills\Mining.ini", i ,"item")
val = GetVar("Skills\Mining.ini", i ,"val")
If i >= change Then
Call PlayerMsg(index, "You mining some ores", 12)
Call GiveItem(index, item, val)
Call SetMiningExperience(index, GetVar("Skills\Mining.ini", i ,"exp"))
Else
Call PlayerMsg(index, "You failed with cutting some wood", 12)
End If
End If
End If
End Sub

Sub SetMiningExperience(index, exp)
Dim Mlv
Dim pexp
Dim max
Dim Mmax
Mlv = GetVar("Skills\DB.ini",GetPlayerName(index), "Mining")
Mmax = GetVar("Skills\max.ini", "Mining", "maxlv")
pexp = GetVar("Skills\DB.ini",GetPlayerName(index), "MiningExp")
max = GetVar("Skills\max.ini", "Mining", "maxexp" & Mlv)
If Int(pexp + exp) > max Then
If Mlv < maxlv Then
Call PutVar("Skills\DB.ini",GetPlayerName(index), "MiningExp", Int(exp - Int(max - pexp)))
Call PutVar("Skills\DB.ini",GetPlayerName(index), "Mining", Int(Mlv + 1))
Call PlayerMsg(index, "You gained a Mining level", 12)
ElseIf Mlv = maxlv Then
Call PutVar("Skills\DB.ini",GetPlayerName(index), "MiningExp", 0)
Call PutVar("Skills\DB.ini",GetPlayerName(index), "Mining", maxlv)
End If
ElseIf Int(pexp + exp) <= max Then
Call PutVar("Skills\DB.ini",GetPlayerName(index), "MiningExp", Int(pexp + exp))
End If
End Sub

    Function GetFreeSlots(Index)   
      Dim Slot
      Dim Slots

      Slot = 1
      Slots = 0

      Index = Int(Index)

      Do While Slot < 25 
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
            Slots = Slots + 1
          End If

          Slot = Slot + 1
      Loop

      GetFreeSlots = Slots
    End Function

    Sub GiveItem(Index, Number, Durability)
      Dim Slot

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Durability = Int(Durability)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
            Call SetPlayerInvItemNum(Index, Slot, Number)
            Call SetPlayerInvItemDur(Index, Slot, Durability)
            Call SendInventoryUpdate(Index, Slot)
            Exit Sub
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Sub GiveCurrency(Index, Number, Amount)
      Dim Slot
      Dim CurrentAmount

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
              CurrentAmount = GetPlayerInvItemValue(Index, Slot)
              Call SetPlayerInvItemValue(Index, Slot, CurrentAmount + Amount)
              Call SendInventoryUpdate(Index, Slot)
              Exit Sub
          End If

          Slot = Slot + 1
      Loop

            Slot = 1

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = 0 Then
              Call SetPlayerInvItemNum(Index, Slot, Number)
              Call SetPlayerInvItemValue(Index, Slot, Amount)
              Call SendInventoryUpdate(Index, Slot)
              Exit Sub
          End If

          Slot = Slot + 1
      Loop
    End Sub

    Function CanTake(Index, Number, Amount)
      Dim Slot

      Slot = 1

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
            If GetPlayerInvItemValue(Index, Slot) >= Amount Then
                CanTake = True
                Exit Function
            End If
          End If

          Slot = Slot + 1
      Loop

      CanTake = False
    End Function

    Sub TakeItem(Index, Number, Amount)
      Dim Slot
      Dim CurrentAmount

      Index = Int(Index)
      Number = Int(Number)
      Amount = Int(Amount)

      Slot = 1

      Do While Slot < 25
          If GetPlayerInvItemNum(Index, Slot) = Number Then
              If GetPlayerInvItemValue(Index, Slot) >= Amount Then
                CurrentAmount = GetPlayerInvItemValue(Index, Slot)

                If CurrentAmount <= Amount Then
                    Call SetPlayerInvItemNum(Index, Slot, 0)
                    Call SetPlayerInvItemValue(Index, Slot, 0)
                    Call SetPlayerInvItemDur(Index, Slot, 0)
                    Call SendInventoryUpdate(Index, Slot)
                Else
                    Call SetPlayerInvItemValue(Index, Slot, CurrentAmount - Amount)
                    Call SendInventoryUpdate(Index, Slot)
                End If

                Exit Sub
              End If
          End If

          Slot = Slot + 1
      Loop
    End Sub
' Block Player Script
Sub BlockPlayer(index)
  playerdir = GetPlayerDir(index)
  Select Case playerdir
        Case 0
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)+1)
        Case 1
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index)-1)
        Case 2
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index)+1, GetPlayerY(index))
        Case 3
          Call PlayerWarp(index, GetPlayerMap(index), GetPlayerX(index)-1, GetPlayerY(index))
  End Select
End Sub

```
New JoinGame/LeftGame:
```
' Executes when a player logs into the game.
Sub JoinGame(Index)
  If GetPlayerAccess(Index) = 0 Then
      Call GlobalMsg(GetPlayerName(Index) & " has joined " & GameName & "!", GREY)
  Else
      Call GlobalMsg("Administrator " & GetPlayerName(Index) & " has joined " & GameName & "!", YELLOW)
  End If

  Call PlayerMsg(Index, "Welcome to " & GameName & "!", WHITE)

  If LenB(MOTD) <> 0 Then
      Call PlayerMsg(Index, "MOTD: " & MOTD, BRIGHTCYAN)
  End If

  Call SendWhosOnline(Index)
If GetVar("Skills\DB.ini",GetPlayerName(index), "Mining") = 0 Then
Call PutVar("Skills\DB.ini",GetPlayerName(index), "MiningExp", 0)
Call PutVar("Skills\DB.ini",GetPlayerName(index), "Mining", 1)
End If
End Sub

' Executes when a player logs out of the game.
Sub LeftGame(Index)
  If GetPlayerAccess(Index) = 0 Then
      Call GlobalMsg(GetPlayerName(Index) & " has left " & GameName & "!", GREY)
  Else
      Call GlobalMsg("Administrator " & GetPlayerName(Index) & " has left " & GameName & "!", YELLOW)
  End If
End Sub

```
Enjoy.
Link to comment
Share on other sites

Woah, that's just great!
Thanks a lot man.

It's surprising me how this forum is so super help fully if you need help all the time.

I can't thank you enough. :)

Adr990

–-

They work, thanks! :)

I'm still having problem with the mining stuff though, but I will just read stuff all over again.
And check if I did do something wrong in the INI files etc.

Great stuff, Soul. Thanks.
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...