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

ClsCommands Addition


balliztik1
 Share

Recommended Posts

Here's a copy of all the subs and functions I have added to clsCommands, so I could use them in my main.txt. Feel free to use whichever of these you want. I'm not going to write how to use each one, because the names should tell what the command does. Feel free to ask about individual ones if you do not understand.

```
Sub SetMapNPC(MapNum, slot, NpcNum)
If MapNum < 1 Or MapNum > MAX_MAPS Or slot < 0 Or slot > 14 Or NpcNum < 0 Or NpcNum > MAX_NPCS Then
Exit Sub
End If

map(MapNum).Npc(slot) = NpcNum
End Sub

Function NumberPlayersOnMap(map)
Dim variable
NumberPlayersOnMap = 0
variable = 1
Do While variable <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))
If GetPlayerMap(variable) = map Then
NumberPlayersOnMap = NumberPlayersOnMap + 1
End If
variable = variable + 1
Loop
End Function

Function HowManyPlaying()
Dim variable
HowManyPlaying = 0
variable = 1
Do While variable <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))
If IsPlaying(variable) = "True" Then
HowManyPlaying = HowManyPlaying + 1
End If
variable = variable + 1
Loop
End Function
Function IsInteger(number)
If Not IsNumeric(number) Then
Exit Function
End If

If number = Int(number) Then
IsInteger = "True"
Else
IsInteger = "False"
End If
End Function

Function Decimate(places, number)
Dim x
x = 1
Do While x <= Len(number)
    If Mid(number, x, 1) = "." Then
        Decimate = Mid(number, 1, x + places)
        If x + places + 1 <= Len(number) Then
        If Int(Mid(number, x + places + 1, 1)) > 4 Then
          Decimate = Decimate + (1 / (10 ^ places))
    Exit Function
    End If
    End If
    Exit Function
    End If
    x = x + 1
Loop
Decimate = number
End Function

Function GetMapNPCIndex(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCIndex = MapNpc(map, slot).num
End Function

Function GetMapNPCHP(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCHP = MapNpc(map, slot).HP
End Function

Function GetMapNPCMaxHP(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCMaxHP = Npc(MapNpc(map, slot).num).MaxHP
End Function

Function GetNPCMaxHP(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCMaxHP = 0
Exit Function
End If

GetNPCMaxHP = Npc(index).MaxHP
End Function

Function GetNPCX(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetNPCX = MapNpc(map, slot).x
End Function

Function GetNPCY(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetNPCY = MapNpc(map, slot).y
End Function

Function GetNPCStrength(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCStrength = 0
Exit Function
End If

GetNPCStrength = Npc(index).STR
End Function

Function GetNPCDefense(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCDefense = 0
Exit Function
End If

GetNPCDefense = Npc(index).DEF
End Function

Function GetNPCSprite(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCSprite = 0
Exit Function
End If

GetNPCSprite = Npc(index).sprite
End Function

Function GetNPCSpeak(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCSpeak = 0
Exit Function
End If
GetNPCSpeak = Npc(index).AttackSay
End Function

Function GetNPCName(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCName = 0
Exit Function
End If
GetNPCName = Trim(Npc(index).Name)
End Function

Function GetNPCElement(index)
If index <= 0 Or index > MAX_NPCS Then
GetNPCElement = 0
Exit Function
End If

GetNPCElement = Npc(index).Element
End Function

Function GetMapNPCStrength(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCStrength = Npc(MapNpc(map, slot).num).STR
End Function

Function GetMapNPCDefense(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCDefense = Npc(MapNpc(map, slot).num).DEF
End Function

Function GetMapNPCSprite(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCSprite = Npc(MapNpc(map, slot).num).sprite
End Function

Function GetMapNPCSpeak(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCSpeak = Npc(MapNpc(map, slot).num).AttackSay
End Function

Function GetMapNPCName(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCName = Trim(Npc(MapNpc(map, slot).num).Name)
End Function

Function GetMapNPCElement(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetMapNPCElement = Npc(MapNpc(map, slot).num).Element
End Function

Function GetNPCDir(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetNPCDir = MapNpc(map, slot).Dir
End Function

Function GetEquippedWeapon(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If
If GetPlayerRingSlot(index) <> 0 Then
GetEquippedWeapon = GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index))
Else
GetEquippedWeapon = 0
End If
End Function

Function GetEquippedLegs(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If
If GetPlayerLegsSlot(index) <> 0 Then
GetEquippedLegs = GetPlayerInvItemNum(index, GetPlayerLegsSlot(index))
Else
GetEquippedLegs = 0
End If
End Function

Function GetEquippedShield(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If
If GetPlayerShieldSlot(index) <> 0 Then
GetEquippedShield = GetPlayerInvItemNum(index, GetPlayerShieldSlot(index))
Else
GetEquippedShield = 0
End If
End Function

Function GetEquippedArmor(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If
If GetPlayerArmorSlot(index) <> 0 Then
GetEquippedArmor = GetPlayerInvItemNum(index, GetPlayerArmorSlot(index))
Else
GetEquippedArmor = 0
End If
End Function

Function GetEquippedRing(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If
If GetPlayerRingSlot(index) <> 0 Then
GetEquippedRing = GetPlayerInvItemNum(index, GetPlayerRingSlot(index))
Else
GetEquippedRing = 0
End If
End Function

Function GetEquippedNecklace(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If

GetEquippedNecklace = GetPlayerInvItemNum(index, GetPlayerNecklaceSlot(index))
End Function

Sub SetNPCHP(map, slot, hitpoints)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Or hitpoints < 0 Or hitpoints > Npc(MapNpc(map, slot).num).MaxHP Then
Exit Sub
End If

MapNpc(map, slot).HP = hitpoints
End Sub

Sub SetNPCDir(map, slot, direction)
If direction < 0 Or direction > 3 Or map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Sub
End If

MapNpc(map, slot).Dir = direction
End Sub

Sub SetNPCX(map, slot, xcoord)
If xcoord <= MAX_MAPX Or xcoord < 0 Or map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Sub
End If

MapNpc(map, slot).x = xcoord
End Sub

Sub SetNPCY(map, slot, ycoord)
If ycoord <= MAX_MAPY Or ycoord < 0 Or map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Sub
End If

MapNpc(map, slot).y = ycoord
End Sub

Function CheckforItem(index, itemnum, value)
Dim x
CheckforItem = "False"
x = 1
Do While x <= 24
If GetPlayerInvItemNum(index, x) = itemnum Then
If GetPlayerInvItemValue(index, x) >= value Then
CheckforItem = "True"
Exit Function
End If
End If
x = x + 1
Loop
End Function

Function GetPlayerNecklaceSlot(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
GetPlayerNecklaceSlot = 0
Exit Function
End If

GetPlayerNecklaceSlot = Player(index).Char(Player(index).CharNum).NecklaceSlot
End Function

Function GetPlayerRingSlot(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
GetPlayerRingSlot = 0
Exit Function
End If

GetPlayerRingSlot = Player(index).Char(Player(index).CharNum).RingSlot
End Function

Function CheckTakeItem(index, itemnum, value) As Boolean
Dim x
CheckTakeItem = False
x = 1
Do While x <= 24
If GetPlayerInvItemNum(index, x) = itemnum Then
If GetPlayerInvItemValue(index, x) >= value Then
CheckTakeItem = True
GoTo TheCandyStore
End If
End If
x = x + 1
Loop
Exit Function

TheCandyStore:
Call SetPlayerInvItemValue(index, x, GetPlayerInvItemValue(index, x) - value)
If GetPlayerInvItemValue(index, x) = 0 Then
Call SetPlayerInvItemNum(index, x, 0)
Call SetPlayerInvItemDur(index, x, 0)
End If
Call SendInventory(index)
End Function

Function GetPlayerSex(index)
If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) Then
Exit Function
End If

GetPlayerSex = Player(index).Char(Player(index).CharNum).Sex
End Function

Function GetNPCTarget(map, slot)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Then
Exit Function
End If

GetNPCTarget = MapNpc(map, slot).Target
End Function

Sub SetNPCTarget(map, slot, targetindex)
If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 Or targetindex < 0 Or targetindex > MAX_PLAYERS Or IsPlaying(targetindex) = False Or GetPlayerMap(targetindex) <> map Then
Exit Sub
End If

MapNpc(map, slot).Target = targetindex
End Sub

Function GetItemDamage(itemnum)
GetItemDamage = item(itemnum).Data2
End Function

Function GetItemName(itemnum)
GetItemName = Trim(item(itemnum).Name)
End Function

Function GetItemStrBonus(itemnum)
GetItemStrBonus = item(itemnum).AddStr
End Function

Function GetItemDefenseBonus(itemnum)
GetItemDefenseBonus = item(itemnum).AddDef
End Function

Function GetItemHPBonus(itemnum)
GetItemHPBonus = item(itemnum).AddHP
End Function

Function GetItemMagicBonus(itemnum)
GetItemMagicBonus = item(itemnum).AddMagi
End Function

Function GetItemMPBonus(itemnum)
GetItemMPBonus = item(itemnum).AddMP
End Function

Function GetItemSpeedBonus(itemnum)
GetItemSpeedBonus = item(itemnum).AddSpeed
End Function

Function GetItemSPBonus(itemnum)
GetItemSPBonus = item(itemnum).AddSP
End Function

Function GetIsItemBound(itemnum)
GetIsItemBound = item(itemnum).Bound
End Function

Function GetItemClassReq(itemnum)
GetItemClassReq = item(itemnum).ClassReq
End Function

Function GetItemDefenseReq(itemnum)
GetItemDefenseReq = item(itemnum).DefReq
End Function

Function GetItemSTRReq(itemnum)
GetItemSTRReq = item(itemnum).StrReq
End Function

Function GetItemSpeedReq(itemnum)
GetItemSpeedReq = item(itemnum).SpeedReq
End Function

Function GetItemAccessReq(itemnum)
GetItemAccessReq = item(itemnum).AccessReq
End Function

Function GetItemAttackSpeed(itemnum)
GetItemAttackSpeed = item(itemnum).AttackSpeed
End Function

Function GetIsItemStackable(itemnum)
GetIsItemStackable = item(itemnum).Stackable
End Function

Function GetItemPrice(itemnum)
GetItemPrice = item(itemnum).Price
End Function

Function GetItemDescription(itemnum)
GetItemDescription = item(itemnum).Desc
End Function

Function GetItemType(itemnum)
GetItemType = item(itemnum).Type
End Function

Sub GetDayOrNight()
If GameTime = TIME_NIGHT Then
GetDayOrNight = 1
Else
GetDayOrNight = 0
End If
End Sub

Function GetTimeHours()
GetTimeHours = Hours
End Function

Function GetTimeMinutes()
Dim Minutes
Minutes = Split(frmServer.Label8.Caption, ":")
GetTimeMinutes = Minutes(1)
End Function

Function GetTimeSeconds()
Dim Seconds
Seconds = Split(frmServer.Label8.Caption, ":")
GetTimeSeconds = Mid(Seconds(2), 1, 2)
End Function

Function GetTime()
GetTime = GetTimeHours & ":" & GetTimeMinutes & ":" & GetTimeSeconds
End Function

Sub Equip(index, itemnum, slot)
Dim x
If itemnum > 0 Then
x = 1
Do While x <= 24
If GetPlayerInvItemNum(index, x) = itemnum Then
slot = x
x = 24
Exit Sub
End If
x = x + 1
Loop
End If
Select Case GetItemType(GetPlayerInvItemNum(index, slot))
Case 1
Call SetPlayerWeaponSlot(index, Int(slot))
Case 2
Call SetPlayerArmorSlot(index, Int(slot))
Case 5
Call SetPlayerLegsSlot(index, Int(slot))
Case 3
Call SetPlayerHelmetSlot(index, Int(slot))
Case 4
Call SetPlayerShieldSlot(index, Int(slot))
Case 6
Call SetPlayerRingSlot(index, Int(slot))
Case 7
Call SetPlayerNecklaceSlot(index, Int(slot))
Case Else
Exit Sub
End Select
End Sub

Sub UnEquip(index, itemnum, slot)
Dim x
If itemnum > 0 Then
x = 1
Do While x <= 24
If GetPlayerInvItemNum(index, x) = itemnum Then
slot = x
x = 24
Exit Sub
End If
x = x + 1
Loop
End If
Select Case GetItemType(GetPlayerInvItemNum(index, slot))
Case 1
Call SetPlayerWeaponSlot(index, 0)
Case 2
Call SetPlayerArmorSlot(index, 0)
Case 5
Call SetPlayerLegsSlot(index, 0)
Case 3
Call SetPlayerHelmetSlot(index, 0)
Case 4
Call SetPlayerShieldSlot(index, 0)
Case 6
Call SetPlayerRingSlot(index, 0)
Case 7
Call SetPlayerNecklaceSlot(index, 0)
Case Else
Exit Sub
End Select
End 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...