balliztik1 Posted July 16, 2007 Author Share Posted July 16, 2007 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 ThenExit SubEnd Ifmap(MapNum).Npc(slot) = NpcNumEnd SubFunction NumberPlayersOnMap(map)Dim variableNumberPlayersOnMap = 0variable = 1Do While variable <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))If GetPlayerMap(variable) = map ThenNumberPlayersOnMap = NumberPlayersOnMap + 1End Ifvariable = variable + 1LoopEnd FunctionFunction HowManyPlaying()Dim variableHowManyPlaying = 0variable = 1Do While variable <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))If IsPlaying(variable) = "True" ThenHowManyPlaying = HowManyPlaying + 1End Ifvariable = variable + 1LoopEnd FunctionFunction IsInteger(number)If Not IsNumeric(number) ThenExit FunctionEnd IfIf number = Int(number) ThenIsInteger = "True"ElseIsInteger = "False"End IfEnd FunctionFunction Decimate(places, number)Dim xx = 1Do 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 + 1LoopDecimate = numberEnd FunctionFunction GetMapNPCIndex(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCIndex = MapNpc(map, slot).numEnd FunctionFunction GetMapNPCHP(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCHP = MapNpc(map, slot).HPEnd FunctionFunction GetMapNPCMaxHP(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCMaxHP = Npc(MapNpc(map, slot).num).MaxHPEnd FunctionFunction GetNPCMaxHP(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCMaxHP = 0Exit FunctionEnd IfGetNPCMaxHP = Npc(index).MaxHPEnd FunctionFunction GetNPCX(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetNPCX = MapNpc(map, slot).xEnd FunctionFunction GetNPCY(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetNPCY = MapNpc(map, slot).yEnd FunctionFunction GetNPCStrength(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCStrength = 0Exit FunctionEnd IfGetNPCStrength = Npc(index).STREnd FunctionFunction GetNPCDefense(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCDefense = 0Exit FunctionEnd IfGetNPCDefense = Npc(index).DEFEnd FunctionFunction GetNPCSprite(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCSprite = 0Exit FunctionEnd IfGetNPCSprite = Npc(index).spriteEnd FunctionFunction GetNPCSpeak(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCSpeak = 0Exit FunctionEnd IfGetNPCSpeak = Npc(index).AttackSayEnd FunctionFunction GetNPCName(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCName = 0Exit FunctionEnd IfGetNPCName = Trim(Npc(index).Name)End FunctionFunction GetNPCElement(index)If index <= 0 Or index > MAX_NPCS ThenGetNPCElement = 0Exit FunctionEnd IfGetNPCElement = Npc(index).ElementEnd FunctionFunction GetMapNPCStrength(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCStrength = Npc(MapNpc(map, slot).num).STREnd FunctionFunction GetMapNPCDefense(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCDefense = Npc(MapNpc(map, slot).num).DEFEnd FunctionFunction GetMapNPCSprite(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCSprite = Npc(MapNpc(map, slot).num).spriteEnd FunctionFunction GetMapNPCSpeak(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCSpeak = Npc(MapNpc(map, slot).num).AttackSayEnd FunctionFunction GetMapNPCName(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCName = Trim(Npc(MapNpc(map, slot).num).Name)End FunctionFunction GetMapNPCElement(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetMapNPCElement = Npc(MapNpc(map, slot).num).ElementEnd FunctionFunction GetNPCDir(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetNPCDir = MapNpc(map, slot).DirEnd FunctionFunction GetEquippedWeapon(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfIf GetPlayerRingSlot(index) <> 0 ThenGetEquippedWeapon = GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index))ElseGetEquippedWeapon = 0End IfEnd FunctionFunction GetEquippedLegs(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfIf GetPlayerLegsSlot(index) <> 0 ThenGetEquippedLegs = GetPlayerInvItemNum(index, GetPlayerLegsSlot(index))ElseGetEquippedLegs = 0End IfEnd FunctionFunction GetEquippedShield(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfIf GetPlayerShieldSlot(index) <> 0 ThenGetEquippedShield = GetPlayerInvItemNum(index, GetPlayerShieldSlot(index))ElseGetEquippedShield = 0End IfEnd FunctionFunction GetEquippedArmor(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfIf GetPlayerArmorSlot(index) <> 0 ThenGetEquippedArmor = GetPlayerInvItemNum(index, GetPlayerArmorSlot(index))ElseGetEquippedArmor = 0End IfEnd FunctionFunction GetEquippedRing(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfIf GetPlayerRingSlot(index) <> 0 ThenGetEquippedRing = GetPlayerInvItemNum(index, GetPlayerRingSlot(index))ElseGetEquippedRing = 0End IfEnd FunctionFunction GetEquippedNecklace(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfGetEquippedNecklace = GetPlayerInvItemNum(index, GetPlayerNecklaceSlot(index))End FunctionSub 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 ThenExit SubEnd IfMapNpc(map, slot).HP = hitpointsEnd SubSub SetNPCDir(map, slot, direction)If direction < 0 Or direction > 3 Or map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit SubEnd IfMapNpc(map, slot).Dir = directionEnd SubSub SetNPCX(map, slot, xcoord)If xcoord <= MAX_MAPX Or xcoord < 0 Or map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit SubEnd IfMapNpc(map, slot).x = xcoordEnd SubSub SetNPCY(map, slot, ycoord)If ycoord <= MAX_MAPY Or ycoord < 0 Or map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit SubEnd IfMapNpc(map, slot).y = ycoordEnd SubFunction CheckforItem(index, itemnum, value)Dim xCheckforItem = "False"x = 1Do While x <= 24If GetPlayerInvItemNum(index, x) = itemnum ThenIf GetPlayerInvItemValue(index, x) >= value ThenCheckforItem = "True"Exit FunctionEnd IfEnd Ifx = x + 1LoopEnd FunctionFunction GetPlayerNecklaceSlot(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenGetPlayerNecklaceSlot = 0Exit FunctionEnd IfGetPlayerNecklaceSlot = Player(index).Char(Player(index).CharNum).NecklaceSlotEnd FunctionFunction GetPlayerRingSlot(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenGetPlayerRingSlot = 0Exit FunctionEnd IfGetPlayerRingSlot = Player(index).Char(Player(index).CharNum).RingSlotEnd FunctionFunction CheckTakeItem(index, itemnum, value) As BooleanDim xCheckTakeItem = Falsex = 1Do While x <= 24If GetPlayerInvItemNum(index, x) = itemnum ThenIf GetPlayerInvItemValue(index, x) >= value ThenCheckTakeItem = TrueGoTo TheCandyStoreEnd IfEnd Ifx = x + 1LoopExit FunctionTheCandyStore:Call SetPlayerInvItemValue(index, x, GetPlayerInvItemValue(index, x) - value)If GetPlayerInvItemValue(index, x) = 0 ThenCall SetPlayerInvItemNum(index, x, 0)Call SetPlayerInvItemDur(index, x, 0)End IfCall SendInventory(index)End FunctionFunction GetPlayerSex(index)If index <= 0 Or index > MAX_PLAYERS Or Not IsPlaying(index) ThenExit FunctionEnd IfGetPlayerSex = Player(index).Char(Player(index).CharNum).SexEnd FunctionFunction GetNPCTarget(map, slot)If map < 1 Or map > MAX_MAPS Or slot < 0 Or slot > 14 ThenExit FunctionEnd IfGetNPCTarget = MapNpc(map, slot).TargetEnd FunctionSub 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 ThenExit SubEnd IfMapNpc(map, slot).Target = targetindexEnd SubFunction GetItemDamage(itemnum)GetItemDamage = item(itemnum).Data2End FunctionFunction GetItemName(itemnum)GetItemName = Trim(item(itemnum).Name)End FunctionFunction GetItemStrBonus(itemnum)GetItemStrBonus = item(itemnum).AddStrEnd FunctionFunction GetItemDefenseBonus(itemnum)GetItemDefenseBonus = item(itemnum).AddDefEnd FunctionFunction GetItemHPBonus(itemnum)GetItemHPBonus = item(itemnum).AddHPEnd FunctionFunction GetItemMagicBonus(itemnum)GetItemMagicBonus = item(itemnum).AddMagiEnd FunctionFunction GetItemMPBonus(itemnum)GetItemMPBonus = item(itemnum).AddMPEnd FunctionFunction GetItemSpeedBonus(itemnum)GetItemSpeedBonus = item(itemnum).AddSpeedEnd FunctionFunction GetItemSPBonus(itemnum)GetItemSPBonus = item(itemnum).AddSPEnd FunctionFunction GetIsItemBound(itemnum)GetIsItemBound = item(itemnum).BoundEnd FunctionFunction GetItemClassReq(itemnum)GetItemClassReq = item(itemnum).ClassReqEnd FunctionFunction GetItemDefenseReq(itemnum)GetItemDefenseReq = item(itemnum).DefReqEnd FunctionFunction GetItemSTRReq(itemnum)GetItemSTRReq = item(itemnum).StrReqEnd FunctionFunction GetItemSpeedReq(itemnum)GetItemSpeedReq = item(itemnum).SpeedReqEnd FunctionFunction GetItemAccessReq(itemnum)GetItemAccessReq = item(itemnum).AccessReqEnd FunctionFunction GetItemAttackSpeed(itemnum)GetItemAttackSpeed = item(itemnum).AttackSpeedEnd FunctionFunction GetIsItemStackable(itemnum)GetIsItemStackable = item(itemnum).StackableEnd FunctionFunction GetItemPrice(itemnum)GetItemPrice = item(itemnum).PriceEnd FunctionFunction GetItemDescription(itemnum)GetItemDescription = item(itemnum).DescEnd FunctionFunction GetItemType(itemnum)GetItemType = item(itemnum).TypeEnd FunctionSub GetDayOrNight()If GameTime = TIME_NIGHT ThenGetDayOrNight = 1ElseGetDayOrNight = 0End IfEnd SubFunction GetTimeHours()GetTimeHours = HoursEnd FunctionFunction GetTimeMinutes()Dim MinutesMinutes = Split(frmServer.Label8.Caption, ":")GetTimeMinutes = Minutes(1)End FunctionFunction GetTimeSeconds()Dim SecondsSeconds = Split(frmServer.Label8.Caption, ":")GetTimeSeconds = Mid(Seconds(2), 1, 2)End FunctionFunction GetTime()GetTime = GetTimeHours & ":" & GetTimeMinutes & ":" & GetTimeSecondsEnd FunctionSub Equip(index, itemnum, slot)Dim xIf itemnum > 0 Thenx = 1Do While x <= 24If GetPlayerInvItemNum(index, x) = itemnum Thenslot = xx = 24Exit SubEnd Ifx = x + 1LoopEnd IfSelect Case GetItemType(GetPlayerInvItemNum(index, slot))Case 1Call SetPlayerWeaponSlot(index, Int(slot))Case 2Call SetPlayerArmorSlot(index, Int(slot))Case 5Call SetPlayerLegsSlot(index, Int(slot))Case 3Call SetPlayerHelmetSlot(index, Int(slot))Case 4Call SetPlayerShieldSlot(index, Int(slot))Case 6Call SetPlayerRingSlot(index, Int(slot))Case 7Call SetPlayerNecklaceSlot(index, Int(slot))Case ElseExit SubEnd SelectEnd SubSub UnEquip(index, itemnum, slot)Dim xIf itemnum > 0 Thenx = 1Do While x <= 24If GetPlayerInvItemNum(index, x) = itemnum Thenslot = xx = 24Exit SubEnd Ifx = x + 1LoopEnd IfSelect Case GetItemType(GetPlayerInvItemNum(index, slot))Case 1Call SetPlayerWeaponSlot(index, 0)Case 2Call SetPlayerArmorSlot(index, 0)Case 5Call SetPlayerLegsSlot(index, 0)Case 3Call SetPlayerHelmetSlot(index, 0)Case 4Call SetPlayerShieldSlot(index, 0)Case 6Call SetPlayerRingSlot(index, 0)Case 7Call SetPlayerNecklaceSlot(index, 0)Case ElseExit SubEnd SelectEnd Sub``` Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now