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

Scripts stop working after re-installing


Akselj
 Share

Recommended Posts

@Akselj:

> I got a very big problem: when I need to reinstall a script because it is not working properly, it stops working.
> May the reason be that I am using Windows Vista?
> Any help appreciated.
>
> Thanks,
> AkselJ

Are you sure scripting is enabled on your server?

Regards,
  Goddianicus.
Link to comment
Share on other sites

Yup, I never changed those settings… And to be 100% sure, I just tested it. All I do is find an unchanged Main.txt and put in the same scripts as in the old one.
BTW Goddie, I think it is the same problem as with the teleport spell, that problem occured the same way.
Link to comment
Share on other sites

@AdrianC:

> If its from 2.7 to 2.7 you probably messed up copying the scripts.
>
> Just copy the whole main.txt
>
> Maybe your scripts require .ini files which were created by hand initially?

Well… I don't think that's the problem either... Because I used Baron's Skill Superscript, and I messed it up trying to use OnClick... So, I found an fresh Main.txt and re-installed the whole script, using the one that's in the topic. And, as all of Baron's script that require INI's, it creates them, and I did not delete the one's I used for skills i was using in the game at that time.
Link to comment
Share on other sites

Okay…

Here you go:

```
' Eclipse Evolution 2.7 Scripting File

' Global Variables
Public GameName
Public MAX_MAPS
Public MOTD

' 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_MONITER = 1
Public Const ADMIN_MAPPER = 2
Public Const ADMIN_DEVELOPER = 3
Public Const ADMIN_CREATOR = 4

' Executes when the server initially loads.
Sub OnServerLoad()
GameName = GetVar("Data.ini", "CONFIG", "GameName")
MAX_MAPS = GetVar("Data.ini", "MAX", "MAX_MAPS")
MOTD = GetVar("MOTD.ini", "MOTD", "Msg")
End Sub

' Executes when the scripts are reloaded.
Sub OnScriptReload()
GameName = GetVar("Data.ini", "CONFIG", "GameName")
MAX_MAPS = GetVar("Data.ini", "MAX", "MAX_MAPS")
MOTD = GetVar("MOTD.ini", "MOTD", "Msg")
End Sub

' Executes the MOTD is changed by the client.
Sub ChangeMOTD()
MOTD = GetVar("MOTD.ini", "MOTD", "Msg")
End Sub

' Executes when a new character is created.
Sub OnNewChar(Index, CharNum)

End Sub

' Executes every second, based on the server time.
Sub TimedEvent(Hours, Minutes, Seconds)
If Minutes = 0 Then
If Seconds = 0 Then
Call AdminMsg("Don't forget to vote for Eclipse.", YELLOW)
End If
End If
End Sub

' Executes when a player presses the CONTROL key.
Sub OnAttack(Index, Damage)
Dim Target

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

Sub OnArrowHit(Index, Damage)
Dim Target

If Int(Damage) > 0 Then
If Int(GetPlayerTarget(Index)) > 0 Then
Target = GetPlayerTarget(Index)
Call DamagePlayer(Index, Target, Damage)
Else
Target = GetPlayerTargetNPC(Index)
Call DamageNPC(Index, Target, Damage)
End If
End If
End Sub

Sub PlayerHit(Index, NPCNum, Damage)
If Damage > 0 then
Call NPCAttack(NPCNum, Index, Damage)
End If
End Sub

' Executes when a hotkey is pressed client-side.
Sub HotScript(Index, KeyID)
Select Case KeyID
' Executes when any player presses the PageUp key.
Case 1

' Executes when any player presses the Delete key.
Case 2

' Executes when players press the End key.
Case 3

' Executes when players press the PageDown key.
Case 4
End Select
End Sub

' Executes when something on a custom menu is clicked.
Sub MenuScripts(Index, Clicked_Index, Menu_Type)
Dim MenuTitle
Dim FieldMessage

MenuTitle = getplayermenuclicktitle(Index)
FieldMessage = getplayermenuclickmsg(Index)

Select Case Menu_Type
Case 1
Call PlayerMsg(Index, "Clicked picture number " & Clicked_Index & " on the menu named " & MenuTitle, YELLOW)
Case 2
Call PlayerMsg(Index, "Clicked field number " & Clicked_Index & " on the menu named " & MenuTitle & ". The field text was " & FieldMessage, YELLOW)
Case 3
Call PlayerMsg(Index, "Clicked label number " & Clicked_Index & " on the menu named " & MenuTitle, YELLOW)
End Select
End Sub

' Executes when a player logs into the game.
Sub JoinGame(Index)
If GetVar("var.ini", GetPlayerName(index), "startup") = "" Then

weapon = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Weapon"))
armor = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Armor"))
shield = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Shield"))
helmet = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Helmet"))
wepdur = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Wepdur"))
armdur = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Armdur"))
shldur = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Shldur"))
hlmdur = Int(GetVar("classes\class" & GetPlayerClass(index) & ".ini", "StartUp", "Hlmdur"))

If weapon <> 0 Then
Call Give_Item(index, weapon, wepdur)
End If
If armor <> 0 Then
Call Give_Item(index, armor, armdur)
End If
If shield <> 0 Then
Call Give_Item(index, shield, shldur)
End If
If helmet <> 0 Then
Call Give_Item(index, helmet, hlmdur)
End If

Call PutVar("var.ini", GetPlayerName(index), "startup", "yes")
End If
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)
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

' Executes when a players experience exceeds the next level requirement.
Sub PlayerLevelUp(Index)
Dim TotalExp

Do While GetPlayerExp(Index) >= GetPlayerNextLevel(Index)
TotalExp = GetPlayerExp(Index) - GetPlayerNextLevel(Index)
Call SetPlayerLevel(Index, GetPlayerLevel(Index) + 1)

Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) + 5)
Call SetPlayerExp(Index, TotalExp)
Loop

Call BattleMsg(Index, "You have " & GetPlayerPOINTS(Index) & " unused stat points.", BRIGHTBLUE, 0)
End Sub

' Executes when a player uses one of the points given on an attribute to level up.
Sub UsingStatPoints(Index, PointType)
Select Case PointType
Case 0
If GetPlayerSTR(Index) + 1 > 2500 Then
Call BattleMsg(Index, "You have maxed your strength!", BRIGHTRED, 0)
Exit Sub
End If
Call SetPlayerSTR(Index, GetPlayerSTR(Index) + 1)
Call BattleMsg(Index, "You have gained more strength!", WHITE, 0)

Case 1
If GetPlayerDEF(Index) + 1 > 2500 Then
Call BattleMsg(Index, "You have maxed your defence!", BRIGHTRED, 0)
Exit Sub
End If
Call SetPlayerDEF(Index, GetPlayerDEF(Index) + 1)
Call BattleMsg(Index, "You have gained more defense!", WHITE, 0)

Case 2
If GetPlayerMAGI(Index) + 1 > 2500 Then
Call BattleMsg(Index, "You have maxed your magic!", BRIGHTRED, 0)
Exit Sub
End If
Call SetPlayerMAGI(Index, GetPlayerMAGI(Index) + 1)
Call BattleMsg(Index, "You have gained more magic!", WHITE, 0)

Case 3
If GetPlayerSPEED(Index) + 1 > 2500 Then
Call BattleMsg(Index, "You have maxed your speed!", BRIGHTRED, 0)
Exit Sub
End If
Call SetPlayerSPEED(Index, GetPlayerSPEED(Index) + 1)
Call BattleMsg(Index, "You have gained more speed!", WHITE, 0)
End Select

' Remove one point after the sub in question is done
Call SetPlayerPOINTS(Index, GetPlayerPOINTS(Index) - 1)
End Sub

' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
Select Case Script
Case 0
   Call Baron_Uber_skills(index)

'<><><><><>

Case 1
   Call Baron_Stam_regain(index)

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

' Executes when a player clicks on an OnClick tile.
Sub OnClick(Index, Script)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
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

' Out-dated: Executes when a player chooses yes or no on a player prompt.
Sub PlayerPrompt(Index, Prompt, Value)
If Prompt = 6 Then
Select Case Value
Case 0
Call GlobalMsg("Hi This is a Yes answer!", CYAN)
Case 1
Call GlobalMsg("This is case 1?", CYAN)
End Select
Else
Select Case Value
Case 0
Call GlobalMsg("Hi This is a No answer!", RED)
Case 1
Call GlobalMsg("This is no case 1?", RED)
End Select
End If
End Sub

' Out-dated: Executes query box responses.
Sub QueryBox(Index, Prompt)
Value = GetVar("responses.ini", "Responses", CStr(Index))
End Sub

' Executes every time a player drops an item.
Sub OnItemDrop(Index, Map, ItemNum, ItemVal, ItemDur, ItemIndex, InvSlot)

End Sub

' Executes each time a player changes map.
Sub OnMapLoad(Index, OldMap, NewMap)

End Sub

' Executes whenever an NPC is killed.
' Note: Death occurs as normal externally to this script.
Sub OnNPCDeath(Index, Map, NPCNum, NPCIndex)
Call BattleMsg(Index, "You killed a " & getnpcname(NPCNum) & ".", BRIGHTRED, 0)
End Sub

' Executes when a player is killed by another.
' Note: Death occurs as normal externally to this script.
Sub OnPVPDeath(Attacker, Victim)
Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
End Sub

' Executes when a player dies in an arena by another player.
Sub OnArenaDeath(Attacker, Victim)
Dim Map
Dim X
Dim Y
Dim Data1
Dim Data2
Dim Data3

Map = GetPlayerMap(Victim)
X = GetPlayerX(Victim)
Y = GetPlayerY(Victim)

Call GlobalMsg(GetPlayerName(Victim) & " has been defeated in the arena by " & GetPlayerName(Attacker), BRIGHTRED)

Call SetPlayerHP(Victim, GetPlayerMaXHP(Victim))
Call SetPlayerMP(Victim, GetPlayerMaXMP(Victim))

Call sendHp(Victim)
Call sendMP(Victim)

Data1 = GetTileData1(Map, X, Y)
Data2 = GetTileData2(Map, X, Y)
Data3 = GetTileData3(Map, X, Y)

Call PlayerWarp(Victim, Data1, Data2, Data3)
End Sub

' Executes whenever a player casts a scripted spell.
Sub ScriptedSpell(Index, Script)
Select Case Script
    Case 0
        Call PlayerWarp(index, 1, 0, 0)
        Call PlayerMsg(index, "You teleported home!", 15)
End Select
    Case 1
        Call PlayerWarp(index, 10, 15, 15)
        Call PlayerMsg(index, "You teleported to the castle!", 15)
End Select
    Case 2
        Call PlayerWarp(index, M, X, Y)
        Call PlayerMsg(index, "You teleported to the shops!", 15)
End Select

    Case 3
        Call PlayerWarp(index, 17, 15, 15)
        Call PlayerMsg(index, "You teleported to Chinatown!", 15)
End Select
    Case 4
        Call PlayerWarp(index, 20, 15, 15)
        Call PlayerMsg(index, "You teleported to Mr. Wong!", 15)
End Select
    Case 5
        Call PlayerWarp(index, 15, 15, 15)
        Call PlayerMsg(index, "You teleported to the desert!", 15)
End Select
End Sub

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

' Executes whenever a scripted NPC does an action.
Sub ScriptedNPC(Index, Script)
Select Case Script
Case 0
Call PlayerMsg(Index, "This scripted NPC has no apparent use.", WHITE)
Exit Sub

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

' Executed whenever a slash command is sent to the server.
Sub Commands(Index)
Dim TextSay
Dim PlayerID
Dim MapNum

' Get the command and arguments from the cache.
TextSay = Trim(GetVar("Scripts\Command.ini", "TEMP", "Text" & Index))

' Split the command into an array. All arguments are seperated by spaces.
TextSay = Split(TextSay)

Select Case TextSay(0)
Case "/testscripts"
Call TestMain(Index)
Exit Sub

Case "/help"
Call PlayerMsg(Index, "Social Commands:", WHITE)
Call PlayerMsg(Index, "'msghere = Broadcast Message", WHITE)
Call PlayerMsg(Index, "-msghere = Emote Message", WHITE)
Call PlayerMsg(Index, "!namehere msghere = Player Message", WHITE)
Call PlayerMsg(Index, "Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /party, /join, /leave, /refresh", WHITE)
Exit Sub

Case "/calladmins"
If GetPlayerAccess(Index) = 0 Then
Call AdminMsg(GetPlayerName(Index) & " needs your help!", BRIGHTGREEN)
Else
Call PlayerMsg(Index, "You are an admin! You cannot call for help!", BRIGHTGREEN)
End If
Exit Sub

Case "/admin"
If GetPlayerAccess(Index) > 0 Then
Call PlayerMsg(Index, "Social Commands:", WHITE)
Call PlayerMsg(Index, """msghere = Global Admin Message", WHITE)
Call PlayerMsg(Index, "=msghere = Private Admin Message", WHITE)
Call PlayerMsg(Index, "Available Commands: /admin, /loc, /mapeditor, /warpmeto, /warptome, /warpto, /setsprite, /mapreport, /kick, /ban, /edititem, /respawn, /editnpc, /motd, /editshop, /ban, /editspell", WHITE)
End If
Exit Sub

Case "/warpmeto"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(Index, GetPlayerMap(PlayerID), GetPlayerX(PlayerID), GetPlayerY(PlayerID))
Call PlayerMsg(Index, "You have been warped to " & GetPlayerName(PlayerID) & ".", BROWN)
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
End If
Exit Sub

Case "/warptome"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(PlayerID, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(PlayerID, "You have been warped to " & GetPlayerName(Index) & ".", BROWN)
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
End If
Exit Sub

Case "/warpto"
If GetPlayerAccess(Index) > 0 Then
MapNum = TextSay(1)

If MapNum > 0 And MapNum <= MAX_MAPS Then
Call PlayerWarp(Index, MapNum, GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(Index, "You have been warped to map #" & MapNum & ".", BRIGHTBLUE)
Else
Call PlayerMsg(Index, "Invalid map number.", BRIGHTRED)
End If
End If
Exit Sub
End Select

Call PlayerMsg(Index, "That is not a valid command.", BRIGHTRED)
End Sub

' Executes on death, dropping all of the players items.
Sub DropItems(Index)
' Remove this to enable.
Exit Sub

If GetPlayerWeaponSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerWeaponSlot(Index), 0)
End If

If GetPlayerArmorSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerArmorSlot(Index), 0)
End If

If GetPlayerHelmetSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerHelmetSlot(Index), 0)
End If

If GetPlayerShieldSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerShieldSlot(Index), 0)
End If

If GetPlayerLegsSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerLegsSlot(Index), 0)
End If

If GetPlayerRingSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerRingSlot(Index), 0)
End If

If GetPlayerNecklaceSlot(Index) > 0 Then
    Call PlayerMapDropItem(Index, GetPlayerNecklaceSlot(Index), 0)
End If
End Sub

' Executes whenever somebody dies outside of an arena.
Sub OnDeath(Index)
Dim MapNum
Dim ClassID
Dim X
Dim Y

If GetMapBootMap(Index) > 0 Then
Call PlayerWarp(Index, GetMapBootMap(Index), GetMapBootX(Index), GetMapBootY(Index))
Else
ClassID = GetPlayerClass(Index)

MapNum = GetVar("Classes\Class" & ClassID & ".ini", "CLASS", "Map")

X = GetVar("Classes\Class" & ClassID & ".ini", "CLASS", "x")
Y = GetVar("Classes\Class" & ClassID & ".ini", "CLASS", "y")

Call PlayerWarp(Index, MapNum, X, Y)
End If
End Sub

' Executes whenever a scripted item is used or double clicked.
Sub ScriptedItem(Index, Script)
Select Case Script
Case 0
x = Rand(4,1)
If x = 1 Then
    Call SetPlayerMP(index, int(GetPlayerMP(index)-int(int(GetPlayerMaxMP(index)/100)*5)))
    Call PlayerMsg(index, "You drink the beer and feel your heart sink...", 7)
    Call TakeItem(Index, 65)
End If
If x = 2 Then
    Call SetPlayerMP(index, int(GetPlayerMP(index)+int(int(GetPlayerMaxMP(index)/100)*5)))
    Call PlayerMsg(index, "You drink the beer and feel your spirits lifting!", 7)
    Call TakeItem(Index, 65)
End If
If x = 3 Then
    Call SetPlayerHP(index, int(GetPlayerHP(index)-int(int(GetPlayerMaxHP(index)/100)*5)))
    Call PlayerMsg(index, "You drink the beer and feel slightly sick...", 7)
    Call TakeItem(Index, 65)
End If
If x = 4 Then
    Call SetPlayerHP(index, int(GetPlayerHP(index)+int(int(GetPlayerMaxHP(index)/100)*5)))
    Call PlayerMsg(index, "You drink the beer and feel a bit better!", 7)
    Call TakeItem(Index, 65)
End If
If GetPlayerHP(index) <= 0 Then
    Call OnDeath(index)
    Call PlayerMsg(index, "You wake up not having a clue what happened... You are hopeless drunk!", 7)
    Call TakeItem(Index, 65)
End If
If GetPlayerMP(index) <= 0 Then
    Call PlayerMsg(index, "The beer would kill more brain cells, but there aren't any left to kill... You are hopeless drunk!", 7)
    Call TakeItem(Index, 65)
End If
Case Else
Call PlayerMsg(Index, "No item script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub

' Map Attributes

Sub SetBlank(Map, X, Y)
Call SetAttribute(Map, X, Y, 0, 0, 0, 0, "", "", "")
End Sub

Sub SetBlock(Map, X, Y)
Call SetAttribute(Map, X, Y, 1, 0, 0, 0, "", "", "")
End Sub

Sub SetWarp(Map, X, Y, WarpMap, WarpX, WarpY)
Call SetAttribute(Map, X, Y, 2, WarpMap, WarpX, WarpY, "", "", "")
End Sub

Sub SetItem(Map, X, Y, ItemID, ItemValue)
Call SetAttribute(Map, X, Y, 3, ItemID, ItemValue, 0, "", "", "")
End Sub

Sub SetNPCAvoid(Map, X, Y)
Call SetAttribute(Map, X, Y, 4, 0, 0, 0, "", "", "")
End Sub

Sub SetKeY(Map, X, Y, KeyID, KeyTake)
Call SetAttribute(Map, X, Y, 5, KeyID, KeyTake, 0, "", "", "")
End Sub

Sub SetKeYOpen(Map, X, Y, KeyX, KeyY, Message)
Call SetAttribute(Map, X, Y, 6, KeyX, KeyY, 0, Message, "", "")
End Sub

Sub SetHeal(Map, X, Y)
Call SetAttribute(Map, X, Y, 7, 0, 0, 0, "", "", "")
End Sub

Sub SetKill(Map, X, Y)
Call SetAttribute(Map, X, Y, 8, 0, 0, 0, "", "", "")
End Sub

Sub SetShop(Map, X, Y, ShopID)
Call SetAttribute(Map, X, Y, 9, ShopID, 0, 0, "", "", "")
End Sub

Sub SetClassBlock(Map, X, Y, Allow1, Allow2, Allow3)
Call SetAttribute(Map, X, Y, 10, Allow, Allow2, Allow3, "", "", "")
End Sub

Sub SetArena(Map, X, Y, MapID, NewX, NewY)
Call SetAttribute(Map, X, Y, 11, MapID, NewX, NewY, "", "", "")
End Sub

Sub SetSound(Map, X, Y, FileName)
Call SetAttribute(Map, X, Y, 12, 0, 0, 0, FileName, "", "")
End Sub

Sub SetSpriteChange(Map, X, Y, SpriteID, ItemID, Cost)
Call SetAttribute(Map, X, Y, 13, SpriteID, ItemID, Cost, "", "", "")
End Sub

Sub SetSign(Map, X, Y, Line1, Line2, Line3)
Call SetAttribute(Map, X, Y, 14, 0, 0, 0, Line1, Line2, Line3)
End Sub

Sub SetDoor(Map, X, Y)
Call SetAttribute(Map, X, Y, 15, 0, 0, 0, "", "", "")
End Sub

Sub SetNotice(Map, X, Y, Title, Text, FileName)
Call SetAttribute(Map, X, Y, 16, 0, 0, 0, Title, Text, FileName)
End Sub

Sub SetScripted(Map, X, Y, Script)
Call SetAttribute(Map, X, Y, 18, Script, 0, 0, "", "", "")
End Sub

Sub SetBank(Map, X, Y)
Call SetAttribute(Map, X, Y, 23, 0, 0, 0, "", "", "")
End Sub

' Tests scripts up to the location of Sub TestMain(Index).
' Leave this sub at the bottom to test the entire script file.
Sub TestMain(Index)
Call PlayerMsg(Index, "Scripts are working properly.", BRIGHTGREEN)
End Sub

'********************************
Function F_Freeslots(index)     
'********************************

Dim slot
Dim count

slot=1
count=0
   Do While slot < 25  
      If getplayerinvitemnum(index, slot) = 0 Then
      count = Int(count) + 1
      End If
   slot=Int(slot) + 1
   Loop
F_Freeslots=Int(count)
End Function

'********************************
Sub Give_Item(index, number, durability)
'********************************

Dim slot

slot = 1
   Do While slot < 25
      If Getplayerinvitemnum( index, Int( slot ) ) = 0 Then
         Call SetPlayerInvItemNum(index, Int( slot ), Int( number ) )
         Call SetPlayerInvItemDur(index, Int( slot ), Int( durability ) )
         Call SetPlayerInvItemValue(index, Int( slot ), Int(0) )
         Call SendInventoryUpdate(index, Int(slot) )
         slot = 25
      End If
   slot = slot + 1
   Loop
End Sub

'********************************
Sub Give_Currency(index, number, quantity)
'********************************

Dim slot
Dim initial
Dim final
Dim given

slot=1
given=0

   Do While slot < 25
      If Getplayerinvitemnum(index,Int(slot))=Int(number) Then
         initial = Getplayerinvitemvalue( index, Int( slot ) )
         final = Int( initial ) + Int( quantity )
         Call setplayerinvitemvalue( index, Int( slot ), Int( final ) )
         Call SendInventoryUpdate(index, Int(slot) )
         slot = 25
         given = 1
      End If
   slot = slot + 1
   Loop

   If given=1 Then
      slot=25
   Else
      slot=1
   End If

   Do While slot < 25
      If Getplayerinvitemnum(index,Int(slot)) = 0 Then
         Call SetPlayerInvItemNum(index, Int( slot ), Int( number ) )
         Call SetPlayerInvItemValue(index, Int( slot ), Int( quantity ) )
         Call SetPlayerInvItemDur(index, Int( slot ), 0 )
         Call SendInventoryUpdate(index, Int(slot) )
         slot = 25
      End If
   slot = slot + 1
   Loop

End Sub

'********************************
Function F_Check_Take(index, number, value)
'********************************

Dim slot

slot = 1
F_Check_Take =0
   Do While slot < 25  
      If Getplayerinvitemnum( index, Int( slot ) ) = Int( number ) Then
         If GetPlayerInvItemValue(index, Int( slot ) ) >= Int(value) Then        
         F_Check_Take=1           
         End If
      End If
   slot = slot + 1
   Loop
End Function

'********************************
Sub Take_Item(index, number, value)
'********************************

Dim slot
Dim taken
Dim initial
Dim final

slot=1
taken=0
   Do While Int(slot) < 25     
      If Int(taken)=0 Then     
         If Getplayerinvitemnum(index,Int(slot)) = Int(number) Then
            If Int(getplayerinvitemvalue(index, Int(slot))) >= Int(value) Then
            initial = Int(getplayerinvitemvalue(index, Int(slot) ) )
            final = Int(initial) - Int(value)           
               If Int(final) <= 0 Then              
               Call setplayerinvitemnum(index, Int(slot), Int(0) )
               Call setplayerinvitemvalue(index, Int(slot), Int(0) )
               Call setplayerinvitemdur(index, Int(slot), Int(0) )
               Call SendInventoryUpdate(index, Int(slot))
               taken=1              
               Else           
               Call setplayerinvitemvalue(index, Int(slot), Int(final) )
               Call SendInventoryUpdate(index, Int(slot) )
               taken=1           
               End If
            End If        
         End If
      End If     
   slot = slot + 1
   Loop
End Sub

'********************************
Sub Baron_Stam_regain(index)
'********************************

Dim skill_type
Dim skill_action
Dim stam_total
Dim player_lvl

skill_type=Trim( GetVar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","type") )

   If Int(Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type), "has_data") ) < 1 Then
   Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "Exp", Int(0) )
   Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "level", Int(0))
   Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "stamina", Int(10))
   Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "has_data", Int(1))
   Call battlemsg(index, "You should return here if you wish to rest", 14, 1)
   End If

player_lvl=Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "level")
skill_action=Trim(GetVar("scripts\skills\" & skill_type & ".ini", "INDEX","action"))
stam_total=5 + Int(player_lvl)
Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "stamina", Int(stam_total))
Call battlemsg(index, "You feel refreshed and ready to " & skill_action & " again.", 14, 1)
End Sub

'********************************
Sub Baron_Uber_skills(index)
'********************************
'Do not modify this script in any way.
'It is provided as is in all goodwill.
'There is CONSIDERABLE time spent here.
On Error Resume next
Dim skill_type
Dim skill_number
Dim take_total
Dim give_total
Dim count
Dim take_count
Dim take_num
Dim take_val
Dim take_msg
Dim empty_space
Dim take_check
Dim needed_item
Dim player_weapon
Dim skill_action
Dim currency_check
Dim recipe_count
Dim recipe_total
Dim min_lvl
Dim player_lvl
Dim player_stam
Dim recipe_stam
Dim give_val
Dim give_num
Dim give_dur
Dim give_msg
Dim high_randomiser
Dim success_chance
Dim low_chance
Dim high_chance
Dim give_exp
Dim new_exp
Dim lvl_exp
Dim next_lvl

If Int(GetVar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","has_data")) < 0 Then
Call Putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","type", "")
Call Putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","number", 0)
Call Putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","has_data", 1)
Call Playermsg(index, "Made skill template for map", 14)
Call Playermsg(index, "Credits go to Baron - http://barony.deviantart.com/", 14)
End If

RECIPE_COUNT = Int(1)
skill_type=Trim( GetVar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","type") )
recipe_total=Int(GetVar("scripts\skills\" & skill_type & ".ini","INDEX" ,"total_recipes"))

'RECIPES ALWAYS HAVE SKILL 1 SELECTED IN MAPEXTRAS AND TOTAL RECIPES IN SKILLS SET TO HIGHEST
'NON RECIPES HAVE ANY SKILL SELECTED IN MAPEXTRAS AND TOTAL RECIPES IN SKILLS SET TO 1

Do While Int(RECIPE_COUNT) <= Int(recipe_total)

   If trim(skill_type) <> "" Then

   skill_number = Int(GetVar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "SKILL","number"))

   If Int(recipe_count) > 1 Then
   skill_number = Int(recipe_count)
   End If

   needed_item=Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number),"item_num_needed"))
   player_weapon=Int( Getplayerinvitemnum(index, Int(getplayerweaponslot(index)) ) )
   skill_action=Trim(GetVar("scripts\skills\" & skill_type & ".ini", "INDEX","action"))

      If Int(needed_item) = Int(player_weapon) Then

      min_lvl = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number),"min_level"))

      If Int(Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type), "has_data") ) < 1 Then
      Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "Exp", Int(0) )
      Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "level", Int(0))
      Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "stamina", Int(10))
      Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "has_data", Int(1))
      Call playermsg(index, "You attempt to " & skill_action & " for the first time!", 14)
      End If

      player_lvl = Int(Getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "level"))

         If Int(min_lvl) <= Int(player_lvl) Then

         player_stam=Int(getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "stamina"))
         recipe_stam=Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number),"stam_taken"))

         If Int(player_stam) >= Int(recipe_stam) Then

         take_total = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number),"take_total"))
         give_total = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number),"give_total"))  
          count = Int ( 1 )
          take_count = Int ( 0 )
          empty_space=F_Freeslots(index)

               If Int(give_total) <= Int(empty_space) Then

            Do While count <= Int(take_total)
            take_num=Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_take_num"))
            take_val=Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_take_val"))  

            take_check=F_Check_Take(index,take_num,take_val)
            take_count=take_count + Int(take_check)  
            count=count+1
            Loop

               If Int(take_count) = Int(take_total) Then        

               count = Int ( 1 )     

                  Do While Int(count) <= Int(take_total)
                  take_num=Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_take_num"))
                  take_val=Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_take_val"))  
                    take_msg=Trim(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_take_Msg"))           
                  Call battlemsg(index, trim(take_msg), 15, 1)  
                  Call Take_Item(index, Int(take_num), Int(take_val) )        
                  count=count+1
                  Loop

                  count = Int ( 1 )
                  new_exp = 0

                  Do While Int(count) <= Int(give_total)
                  give_val = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_give_val"))
                  give_msg = Trim(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_give_msg"))

                  success_chance = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_base_chance"))
                  low_chance= Int(player_lvl) - Int(min_lvl) + 1
                  high_chance = Int(player_lvl) - Int(min_lvl) + Int(success_chance)
                  high_randomiser = Int((high_chance + 1) * Rnd)

                  If Int(high_randomiser) <= Int(low_chance) Then                 

                     If Int(give_val) > 0 Then
                     give_num = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_give_num"))
                     Call Give_Currency(index, Int(give_num), Int(give_val) )
                     Call battlemsg(index, Trim(give_msg),10, 1)
                     'TO HAVE THE SCRIPT AUTO CREATE ALL ITEMS IT CAN ONCE EACH, REMOVE LINE BELOW
                     RECIPE_COUNT= Int(recipe_total)
                     Else
                     give_num = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_give_num"))
                     give_dur = Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_give_dur"))
                     Call Give_Item(index, give_num, give_dur)
                     Call battlemsg(index, Trim(give_msg),10, 1)
                     'TO HAVE THE SCRIPT AUTO CREATE ALL ITEMS IT CAN ONCE EACH, REMOVE LINE BELOW
                     RECIPE_COUNT= Int(recipe_total)
                     End If

                     give_exp = 0 + Int(GetVar("scripts\skills\" & skill_type & ".ini", Int(skill_number), Int(count) & "_EXP"))
                     new_exp = 0 + Int(getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "exp")) + Int(give_exp)
                      Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "exp", Int(new_exp))
                  End If

                  If new_exp=0 Then
                  new_exp=Int(getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "exp"))
                  End If

                  count=count+1
                  Loop

                  next_level = Int(player_lvl) + Int(1)
                  lvl_exp = Int(Getvar("experience.ini", "EXPERIENCE", "Exp" & Int(next_level) ) )
                  Call battlemsg(index,new_exp & " / " & lvl_exp & " For " & next_level & " " & trim(skill_type), 6, 0)

                  If Int(new_exp) >= Int(lvl_exp) and Int(player_lvl) < 100 Then
                  new_exp= 0 + Int(new_exp) - Int(lvl_exp)                 
                  Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "exp", Int(new_exp))
                  Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "level", Int(next_level))
                  Call battlemsg(index, "Congratulations, you are now level " & Int(next_level) & " in " & trim(skill_type) & "!", 13, 1)
                  End If

                  player_stam = Int(player_stam) - Int(recipe_stam)
                  Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", Trim(Skill_type) , "stamina", Int(player_stam))

                  If Int(recipe_total) = 1 Then
                  RECIPE_COUNT= Int(recipe_total)
                  End If                          

                 Else                
                    If Int(recipe_count) + 1 > Int(recipe_total) and Int(recipe_total) > Int(1) Then
                  Call battlemsg(index, "You have no components to " & skill_action, 12, 1)
                  End If   
               End If        

            Else     
            Call battlemsg(index, "You need more inventory room to continue " & skill_type & ".", 15, 1)           
             End If

           Else
           Call battlemsg(index, "You are too tired to " & skill_action & ".", 12, 1)
           End If

           Else
           Call battlemsg(index, "You get nothing.", 15, 1)         
           End If

      End If
        'This continues off end of item script. Used when empty slot. Elseif errors usually.
      If Int(needed_item) <> Int(player_weapon) and Int(recipe_count) = 1 Then
        Call battlemsg(index, "You need to get the right tool/component to " & skill_action & " here.", 15, 1)      
      End If

    Else
    'Not working. Cant figure out why. Is non essential for the script to work.
    Call Playermsg(index, "You still need to define a skill for this map", 14)
   End If

RECIPE_COUNT = Int(recipe_count)+1

Loop

End Sub

Sub TakeItem(index, item, value)
If value = "all" Then
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = item Then
Call SetPlayerInvItemNum(index, SLOT, 0)
Call SetPlayerInvItemValue(index, SLOT, 0)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
Else
SLOT = 1
Do While SLOT < 24
If GetPlayerInvItemNum(index, SLOT) = item Then
Call SetPlayerInvItemNum(index, SLOT, 0)
Call SetPlayerInvItemValue(index, SLOT, GetPlayerInvItemValue(index, SLOT) - value)
Call SendInventoryUpdate(index, SLOT)
SLOT = 24
End If
SLOT = SLOT+1
Loop
End Sub
End If

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

```
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...