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

On death i go nowhere


jazzman170
 Share

Recommended Posts

I was messing around with my scripts to add other scripts, and had to change a few things. i got my town portal script working (i didnt make the script), the script where you run on the scripted tile and it sets it so you can type  /town  to return to it at any time, or when you die you return to that location. But now when and if you die before you have that location saved, you go nowhere lol. its not a huge problem cause i can just make it so a player when they start, runs right into the scripted tile, but even so i dont like haveing this little bug in my script. can somebody please take a look at my main.txt and check this out to see where i messed it up? thanks in advance! i know its a lot, but any help is well appreciated!

' 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

If Trim(MOTD) <> "" Then
        Call PlayerMsg(index, "MOTD: " & MOTD, 11)
Call HighScore(Index)
End If
    If GetPlayerAccess(index) = 4 Then
        Call GlobalMsg(GetPlayerName(index) & " (Administrator) has joined " & GameName & "!", 12)
    End If
    If GetPlayerAccess(index) = 3 Then
        Call GlobalMsg(GetPlayerName(index) & " (Developer) has joined " & GameName & "!", 12)
    End If
    If GetPlayerAccess(index) = 2 Then
        Call GlobalMsg(GetPlayerName(index) & " (Mapper) has joined " & GameName & "!", 12)
    End If
    If GetPlayerAccess(index) = 1 Then
        Call GlobalMsg(GetPlayerName(index) & " (Moderator) has joined " & GameName & "!", 12)
    End If
    If GetPlayerAccess(index) = 0 Then
        Call GlobalMsg(GetPlayerName(index) & " has joined " & GameName & "!", 12)
    End If
End Sub
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 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) + 1)
Call SetPlayerExp(Index, TotalExp)
Loop

Call BattleMsg(Index, "You have " & GetPlayerPOINTS(Index) & " 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 > 1000 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 > 1000 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 > 1000 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 > 1000 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 PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "DEATH", "playerdie_map", GetPlayerMap(index))
        Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "DEATH", "playerdie_x", GetPlayerX(index))
        Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "DEATH", "playerdie_y", GetPlayerY(index))
        Exit Sub

case 1
Call Uber_Scripted_Tiles(index)
  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

' 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.
*******Level Up Spell*********
Sub ScriptedSpell(index, Script)
    Select Case Script
        Case 0

            Dim mpneeded 'Declare the MP variable
            mpneeded = 5 'The amount of MP needed

            If GetPlayerMP(index) >= mpneeded Then 'Check if the player has the required amount of MP
                Call SetPlayerLevel(index,  GetPlayerLevel(Index) +1) 'Increase the player's level by one
                Call SetPlayerMP( Index, GetPlayerMP( Index) - mpneeded) 'Substract the MP thats needed
                Call SendStats( Index) 'Updates the player's stats
call playerMsg(Index, "You granted a level!", WHITE)

            End If
    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)
'********************************

On Error Resume Next
Dim i
Dim TextSay
Dim n
Dim m
Dim C
Dim test
Dim mapnum
Dim x
Dim y
dim tile
dim map

m = GetVar("Data.ini", "MAX", "MAX_MAPS")
TextSay = GetVar("Scripts\Command.ini", "TEMP", "Text" & index)     
i = 1
C = 0

'<><><><><>

    If LCase(Mid(TextSay, 1, 5)) = "/wish" Then
        If Len(TextSay) > 6 Then
            TextSay = Mid(TextSay, 6, Len(TextSay) - 5)         
            Do While C = 0
                If GetVar("wishes.ini", "WISH", "Wish" & i) <> "" Then
                  i = i + 1
                Else
                  Call PutVar("wishes.ini", "WISH", "Wish" & i, Trim(TextSay))
                  Call PlayerMsg(index, "Thank You For Wishing!", 10)
                  C = 1
                End If 
            Loop
        End If
        Exit Sub
    End If

'<><><><><>

    If LCase(Mid(TextSay, 1, 9)) = "/warpmeto" Then
        If Len(TextSay) > 10 Then
            TextSay = Mid(TextSay, 10, Len(TextSay) - 9)

            ' Prevent hacking
            If GetPlayerAccess(index) < 2 Then
                Call PlayerMsg(index, "You need be of a higher access to use this command!", 12)
                Exit Sub
            End If

            ' The player
            n = FindPlayer(TextSay)

            If n <> index Then
                If n > 0 Then
                    Call PlayerWarp(index, GetPlayerMap(n), GetPlayerX(n), GetPlayerY(n))
                    Call PlayerMsg(n, GetPlayerName(index) & " has warped to you.", 14)
                    Call PlayerMsg(index, "You have been warped to " & GetPlayerName(n) & ".", 10)
                    Call AddLog(GetPlayerName(index) & " has warped to " & GetPlayerName(n) & ", map #" & GetPlayerMap(n) & ".", ADMIN_LOG)
                Else
                    Call PlayerMsg(index, "Player is not online.", 12)
                End If
            Else
                Call PlayerMsg(index, "You cannot warp to yourself!", 12)
            End If
        End If
        Exit Sub
    End If

'<><><><><>

If LCase(Mid(TextSay, 1, 10)) = "/setportal" Then
    n = Mid(TextSay, 11, Len(TextSay) - 10)
    If GetPlayerAccess(index) >= 1 Then
        Call PlayerMsg(index, "You have created a portal opening at this spot! You may now return to this spot at any time by typing /portal " & n, 10)
        Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "map" & n, GetPlayerMap(index))
        Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "x" & n, GetPlayerX(index))
        Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "y" & n, GetPlayerY(index))
    Else
        Call PlayerMsg(index, "You do not have that ability.", 12)
    End If
    Exit Sub
End If

'<><><><><>

If LCase(Mid(TextSay, 1, 7)) = "/portal" Then
    n = Mid(TextSay, 8, Len(TextSay) - 7)
    mapnum = GetVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "map" & n)
    y = GetVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "y" & n)
    x = GetVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "x" & n)
    If GetPlayerAccess(index) >= 1 Then
        Call PlayerWarp(index, mapnum, x, y)
    Else
        Call PlayerMsg(index, "You do not have that ability.", 12)
    End If
Exit Sub
End If

'<><><><><>

    If LCase(Mid(TextSay, 1, 9)) = "/warptome" Then
        If Len(TextSay) > 10 Then
            If GetPlayerAccess(index) < 2 Then
                Call PlayerMsg(index, "You need be of a higher access to use this command!", 12)
                Exit Sub
            End If

            n = Mid(TextSay, 10, Len(TextSay) - 9)
            n = FindPlayer(n)

            If n <> index Then
                If n > 0 Then
                    Call PlayerWarp(n, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index))
                    Call PlayerMsg(n, "You have been summoned by " & GetPlayerName(index) & ".", 14)
                    Call PlayerMsg(index, GetPlayerName(n) & " has been summoned.", 10)
                    Call AddLog(GetPlayerName(index) & " has warped " & GetPlayerName(n) & " to self, map #" & GetPlayerMap(index) & ".", ADMIN_LOG)
                Else
                    Call PlayerMsg(index, "Player is not online.", 12)
                End If
            Else
                Call PlayerMsg(index, "You cannot warp yourself to yourself!", 12)
            End If
        End If
        Exit Sub
    End If

'<><><><><>

    If LCase(Mid(TextSay, 1, 7)) = "/warpto" Then
        If Len(TextSay) > 8 Then
            TextSay = Mid(TextSay, 8, Len(TextSay) - 7)
            n = TextSay

            If n > 0 and n <= m Then
                If GetPlayerAccess(index) < 2 Then
                    Call PlayerMsg(index, "You need be of a higher access to use this command!", 12)
                    Exit Sub
                End If

                Call PlayerWarp(index, n, GetPlayerX(index), GetPlayerY(index))
                Call PlayerMsg(index, "You have been warped to map #" & n, 10)
                Call AddLog(GetPlayerName(index) & " warped to map #" & n & ".", ADMIN_LOG)
            Else
                Call PlayerMsg(index, "Invalid map number.", 12)
            End If
        End If
        Exit Sub
    End If

'<><><><><>

If LCase(Mid(TextSay, 1, 5)) = "/case" Then

If int(getplayeraccess(index)) > 2 Then

If Len(TextSay) > 6 Then
TextSay = Mid(TextSay, 6, Len(TextSay) - 5)

If trim(textsay) <> "" Then

tile=int(getplayermapXY(index))
map=int(Getplayermap(index))

Call Putvar("scripts\mapextras\" & Int(map) & ".ini", "SCRIPT",Int(tile), trim(Textsay))
Call PlayerMsg(index, "You have bound tile number " & int(tile) & " to the script " & Textsay & "!", 13)

Else

Call Playermsg(index, "You must give a script name or number.", 13)

End If

End If

Else
Call Playermsg(index, "You have insufficient access to use this command.", 13)
End If

Exit Sub
End If

'<><><><><>

'–-----------------------------
Select Case LCase(Trim(TextSay))
'-------------------------------

'<><><><><>

Case "/help"
Call PlayerMsg(index, "Social Commands:", 14)
Call PlayerMsg(index, "'msghere = Broadcast Message", 15)
Call PlayerMsg(index, "-msghere = Emote Message", 15)
Call PlayerMsg(index, "!namehere msghere = Player Message", 15)
Call PlayerMsg(index, "Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /party, /join, /leave, /refresh, /town, /8ball, /rainbow", 15)
Exit Sub

'<><><><><>

Case "/calladmins"
If GetPlayerAccess(index) = 0 Then
        Call AdminMsg(GetPlayerName(index) & " needs an admin!", 14)
        Call PlayerMsg(index, "You have requested help from an admin.", 14)
    Else
        Call PlayerMsg(index, "You are an admin, grow up and solve the problem.", 12)
    End If
Exit Sub

'<><><><><>

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

'<><><><><>

Case "/away"
If GetPlayerAccess(index) >= 1 Then
    If GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status") = 0 Then
        Call GlobalMsg(GetPlayerName(index) & " is now away.", 14)
            Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status", 1)
            Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "TempPlayerName", GetPlayerName(index))
            Call SetPlayerName(index, GetPlayerName(index) & " - Away")
            Call SendPlayerData(index)
            Exit Sub
        ElseIf GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status") = 1 Then
            Call SetPlayerName(index, GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "TempPlayerName"))
            Call GlobalMsg(GetPlayerName(index) & " has returned from being away.", 14)
            Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status", 0)
            Call SendPlayerData(index)
            Exit Sub
        End If
End If

'<><><><><>

Case "/test"
Call testmain(index)
Exit Sub

'<><><><><>

Case "/town"
Call use_town_portal(index)     
Exit Sub

'<><><><><>

Case "/top5"
call HighScore(index)
exit sub

'<><><><><>
End Select

Call PlayerMsg(index, "Thats not a valid command!", 12)
End Sub

'********************************
Sub Set_town_portal(index)
'********************************
Dim townmap
Dim townx
Dim towny

    townmap = 0 + GetPlayerMap(index)
    townx = 0 + GetPlayerX(index)
    towny = 0 + GetPlayerY(index)

    Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap", 0 + townmap)
    Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townx", 0 + townx)
    Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "towny", 0 + towny)

    Call PlayerMsg(index, "Your soul is now bound to this portal arch. Type /town to return here. " , 10)

End Sub

'********************************
Sub use_town_portal(index)     
'********************************

Dim townmap
Dim townx
Dim towny

If GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") <> "" Then

        townmap = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") )
        townx = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townx") )
        towny = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "towny") )

        Call PlayerWarp(index, Int(townmap), Int(townx), Int(towny) )
        Call Playermsg(index,"You summon a town portal returning you to town.", 10)

Else   
Call Playermsg(index,"You have not yet set a town to return to.", 12)           
End If

End Sub

**************************
'*AutoUpdatingHighScoreScript*
'*******Version1.2**********
'*************************
Sub HighScore(index)
Dim acc(50)
Dim Char(50)
Dim Charlvl(50)
i=1
j=1
C=0
Cnum = 0
Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "Level" , GetPlayerLevel(Index))
Do While C = 0
acc(i) = GetVar("accounts.ini", "Players", "Name" & i)
If acc(i) <> "" Then
'Call PlayerMsg(index, acc(i), 1)
j = 1
Do While j < 4
If GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name") <> "" Then
Cnum=Cnum+1
Char(Cnum) = GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name")
Charlvl(Cnum) = INT(GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Level"))
End If
j = j + 1
Loop
i = i + 1
Else
C=1
Max=(i - 1)
End If
Loop
Ca=1
Cb=2
Do While Ca < Cnum
Do While Cb <= Cnum
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1)
If Charlvl(Ca) < Charlvl(Cb) Then
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1)
templvla = Charlvl(Ca)
templvlb = Charlvl(Cb)
tempnamea = Char(Ca)
tempnameb = Char(Cb)
Charlvl(Ca) = templvlb
Charlvl(Cb) = templvla
Char(Ca) = tempnameb
Char(Cb) = tempnamea
'Call PlayerMsg(index, "Switching", 1)
End If
Cb=(Cb + 1)
Loop
Ca=(Ca + 1)
Cb=(Ca + 1)
'Call PlayerMsg (index, Ca & Cb, 1)
Loop
Call battleMsg(index, "Top 5 Players by Level", 15, 0)
Ca=1
Do While Ca <= 5
Call battleMsg(index, Char(Ca) & " = Level " & Charlvl(Ca), 12, 0)
Ca=Ca+1
Loop
End Sub

Sub UpdateScore(index)
Dim acc(50)
Dim Char(50)
Dim Charlvl(50)
i=1
j=1
C=0
Cnum = 0
Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "Level" , GetPlayerLevel(Index))
Do While C = 0
acc(i) = GetVar("accounts.ini", "Players", "Name" & i)
If acc(i) <> "" Then
'Call PlayerMsg(index, acc(i), 1)
j = 1
Do While j < 4
If GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name") <> "" Then
Cnum=Cnum+1
Char(Cnum) = GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name")
Charlvl(Cnum) = INT(GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Level"))
End If
j = j + 1
Loop
i = i + 1
Else
C=1
Max=(i - 1)
End If
Loop
Ca=1
Cb=2
Do While Ca < Cnum
Do While Cb <= Cnum
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1)
If Charlvl(Ca) < Charlvl(Cb) Then
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1)
templvla = Charlvl(Ca)
templvlb = Charlvl(Cb)
tempnamea = Char(Ca)
tempnameb = Char(Cb)
Charlvl(Ca) = templvlb
Charlvl(Cb) = templvla
Char(Ca) = tempnameb
Char(Cb) = tempnamea
'Call PlayerMsg(index, "Switching", 1)
End If
Cb=(Cb + 1)
Loop
Ca=(Ca + 1)
Cb=(Ca + 1)
'Call PlayerMsg (index, Ca & Cb, 1)
Loop
Call globalMsg(index, "Top 5 Players by Level", 15)
Ca=1
Do While Ca <= 5
Call globalMsg(index, Char(Ca) & " = Level " & Charlvl(Ca), 12)
Ca=Ca+1
Loop
End Sub

Sub SwimStart(index, sprite, message, color)
    If GetPlayerSprite(index) = sprite Then
        Call BlockPlayer(index)
        Call PlayerMsg(index, "Sorry, you cant swim.", 1)
    Else
        Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "TempSprite" , 0)
        Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "TempSprite" , GetPlayerSprite(index))
        Call SetPlayerSprite(index, sprite)
        Call PlayerMsg(index, message, color)
        Call SendPlayerData(index)
    End If
End Sub

'********************************
Function getplayermapXY(index)
'********************************
Dim x
Dim y

x=1+GetPlayerX(index)
y=GetPlayerY(index)

getplayermapxy=x+(20*y)

End Function

'********************************
' 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

'********************************
Sub OnDeath(index)               
'********************************

Dim townmap
Dim townx
Dim towny

If GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") > 0 Then

        townmap = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") )
        townx = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townx") )
        towny = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "towny") )
        Call PlayerWarp(index, Int(townmap), Int(townx), Int(towny) )

Else

townx=29
towny=22
townmap=1
Call PlayerWarp(index, Int(townmap), Int(townx), Int(towny) )

End If

Call Dropitems(index)
End Sub

'********************************

' Executes whenever a scripted item is used or double clicked.
Sub ScriptedItem(Index, Script)
Select Case Script

case 0
Call SetPlayerLevel( Index, GetPlayerLevel( Index) +1)
Sub TakeItem(Index, 5, 1)
Call SendInventory( Index)

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

'**********************

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 getplayermapXY(index)
'********************************
Dim x
Dim y

x=1+GetPlayerX(index)
y=GetPlayerY(index)

getplayermapxy=x+(20*y)

End Function

'********************************
Sub Uber_Scripted_Tiles(index)
'********************************
On error resume next
Dim script
dim map
dim tile

tile=int(getplayermapXY(index))
map=int(Getplayermap(index))

script=Getvar("scripts\mapextras\" & Int(map) & ".ini", "SCRIPT",Int(tile))

Select case script

  Case "Uber"
  Call playermsg(index, "This truly is an uber script. Done well Baron :D", 13)
  Exit Sub

  Case "savepoint"
  Call Set_town_portal(index)
  Exit Sub

  Case Else
  Call playermsg(index, "No script was found matching that title", 13)
  Exit Sub

End Select

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
Link to comment
Share on other sites

First, find this:

> If Trim(MOTD) <> "" Then
>           Call PlayerMsg(index, "MOTD: " & MOTD, 11)
>       Call HighScore(Index)
>   End If
>     If GetPlayerAccess(index) = 4 Then
>         Call GlobalMsg(GetPlayerName(index) & " (Administrator) has joined " & GameName & "!", 12)
>     End If
>     If GetPlayerAccess(index) = 3 Then
>         Call GlobalMsg(GetPlayerName(index) & " (Developer) has joined " & GameName & "!", 12)
>     End If
>     If GetPlayerAccess(index) = 2 Then
>         Call GlobalMsg(GetPlayerName(index) & " (Mapper) has joined " & GameName & "!", 12)
>     End If
>     If GetPlayerAccess(index) = 1 Then
>         Call GlobalMsg(GetPlayerName(index) & " (Moderator) has joined " & GameName & "!", 12)
>     End If
>     If GetPlayerAccess(index) = 0 Then
>         Call GlobalMsg(GetPlayerName(index) & " has joined " & GameName & "!", 12)
>     End If
> End Sub
> End Sub

Take out the two "End Sub" statements there, then cut the text out and go to Sub JoinGame(index).  Once you find that, replace this segment:

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

With the code you cut out. 

Next, find this:

> *******Level Up Spell*********

And put a ' in front of it.  While you're there, find this:

> If GetPlayerMP(index) >= mpneeded Then 'Check if the player has the required amount of MP
>                 Call SetPlayerLevel(index,  GetPlayerLevel(Index) +1) 'Increase the player's level by one
>                 Call SetPlayerMP( Index, GetPlayerMP( Index) - mpneeded) 'Substract the MP thats needed
>                 Call SendStats( Index) 'Updates the player's stats
>       call playerMsg(Index, "You granted a level!", WHITE)
>          
>             End If
>     End Select
> End Sub

And take out the End Select and End Sub statements.

Next, find this:

> case 0
> Call SetPlayerLevel( Index, GetPlayerLevel( Index) +1)
> Sub TakeItem(Index, 5, 1)
> Call SendInventory( Index)

And change the "Sub" to "Call". 

Try that and see if it works.  With all of those syntax errors, it's no wonder you weren't dying properly.
Link to comment
Share on other sites

@Bone:

> I think that 'end select' needs to be there
> Seeing its after the cases, so it stops selecting cases
> but then theres a 'case else'
>
> I could be wrong
>
> A tip : Back up your Main.txt after every script

There does need to be an End Select, but only one; otherwise the script complains.  The one already there after Case Else is the one that should be kept. 

And yes, that's a very good tip.
Link to comment
Share on other sites

ok i did everything you asked. i still respawn in the same place that im killed, and changing the scripted item case 0 one, i changed it from Sub to Call, and no it didnt fix it. but tyvvm for helping me get rid of a few minor bugs/erros :D  anybody else have any helpfull advice? all is much appreciated!
Link to comment
Share on other sites

*cringe*
All apologies for the long post. Syntactically correct here. If that doesn't fix the problem, it's something else.
```
' 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

Sub JoinGame(Index)
If Trim(MOTD) <> "" Then
           Call PlayerMsg(index, "MOTD: " & MOTD, 11)
     Call HighScore(Index)
   End If
   If GetPlayerAccess(index) = 4 Then 
       Call GlobalMsg(GetPlayerName(index) & " (Administrator) has joined " & GameName & "!", 12) 
   End If 
   If GetPlayerAccess(index) = 3 Then 
       Call GlobalMsg(GetPlayerName(index) & " (Developer) has joined " & GameName & "!", 12) 
   End If 
   If GetPlayerAccess(index) = 2 Then 
       Call GlobalMsg(GetPlayerName(index) & " (Mapper) has joined " & GameName & "!", 12) 
   End If 
   If GetPlayerAccess(index) = 1 Then 
       Call GlobalMsg(GetPlayerName(index) & " (Moderator) has joined " & GameName & "!", 12) 
   End If 
   If GetPlayerAccess(index) = 0 Then 
       Call GlobalMsg(GetPlayerName(index) & " has joined " & GameName & "!", 12) 
   End If   

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

   Call SendWhosOnline(Index)
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 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) + 1)
     Call SetPlayerExp(Index, TotalExp)
   Loop

   Call BattleMsg(Index, "You have " & GetPlayerPOINTS(Index) & " 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 > 1000 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 > 1000 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 > 1000 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 > 1000 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 PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "DEATH", "playerdie_map", GetPlayerMap(index))
       Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "DEATH", "playerdie_x", GetPlayerX(index))
       Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "DEATH", "playerdie_y", GetPlayerY(index))
       Exit Sub

Case 1
Call Uber_Scripted_Tiles(index)
   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

' 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.
'*******Level Up Spell*********
Sub ScriptedSpell(index, Script)
   Select Case Script 
       Case 0

           Dim mpneeded 'Declare the MP variable
           mpneeded = 5 'The amount of MP needed

           If GetPlayerMP(index) >= mpneeded Then 'Check if the player has the required amount of MP
               Call SetPlayerLevel(index,  GetPlayerLevel(Index) +1) 'Increase the player's level by one
               Call SetPlayerMP( Index, GetPlayerMP( Index) - mpneeded) 'Substract the MP thats needed
               Call SendStats( Index) 'Updates the player's stats
     Call playerMsg(Index, "You granted a level!", WHITE)

           End If

     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)
'********************************

On Error Resume Next 
Dim i
Dim TextSay
Dim n
Dim m
Dim C
Dim test
Dim mapnum
Dim x
Dim y
Dim tile 
Dim map

m = GetVar("Data.ini", "MAX", "MAX_MAPS")
TextSay = GetVar("Scripts\Command.ini", "TEMP", "Text" & index)     
i = 1
C = 0

'<><><><><>

   If LCase(Mid(TextSay, 1, 5)) = "/wish" Then
       If Len(TextSay) > 6 Then
           TextSay = Mid(TextSay, 6, Len(TextSay) - 5)         
           Do While C = 0
               If GetVar("wishes.ini", "WISH", "Wish" & i) <> "" Then
                   i = i + 1
               Else
                   Call PutVar("wishes.ini", "WISH", "Wish" & i, Trim(TextSay))
                   Call PlayerMsg(index, "Thank You For Wishing!", 10)
                   C = 1
               End If   
           Loop
       End If
       Exit Sub
   End If

'<><><><><>

   If LCase(Mid(TextSay, 1, 9)) = "/warpmeto" Then
       If Len(TextSay) > 10 Then
           TextSay = Mid(TextSay, 10, Len(TextSay) - 9)

           ' Prevent hacking
           If GetPlayerAccess(index) < 2 Then
               Call PlayerMsg(index, "You need be of a higher access to use this command!", 12)
               Exit Sub
           End If

           ' The player
           n = FindPlayer(TextSay)

           If n <> index Then
               If n > 0 Then
                   Call PlayerWarp(index, GetPlayerMap(n), GetPlayerX(n), GetPlayerY(n))
                   Call PlayerMsg(n, GetPlayerName(index) & " has warped to you.", 14)
                   Call PlayerMsg(index, "You have been warped to " & GetPlayerName(n) & ".", 10)
                   Call AddLog(GetPlayerName(index) & " has warped to " & GetPlayerName(n) & ", map #" & GetPlayerMap(n) & ".", ADMIN_LOG)
               Else
                   Call PlayerMsg(index, "Player is not online.", 12)
               End If
           Else
               Call PlayerMsg(index, "You cannot warp to yourself!", 12)
           End If
       End If
       Exit Sub
   End If

'<><><><><>

   If LCase(Mid(TextSay, 1, 10)) = "/setportal" Then
   n = Mid(TextSay, 11, Len(TextSay) - 10) 
       If GetPlayerAccess(index) >= 1 Then 
       Call PlayerMsg(index, "You have created a portal opening at this spot! You may now return to this spot at any time by typing /portal " & n, 10) 
       Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "map" & n, GetPlayerMap(index)) 
       Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "x" & n, GetPlayerX(index)) 
       Call PutVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "y" & n, GetPlayerY(index)) 
       Else 
       Call PlayerMsg(index, "You do not have that ability.", 12) 
       End If 
       Exit Sub 
   End If

'<><><><><> 

   If LCase(Mid(TextSay, 1, 7)) = "/portal" Then 
   n = Mid(TextSay, 8, Len(TextSay) - 7) 
   mapnum = GetVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "map" & n) 
   y = GetVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "y" & n) 
   x = GetVar("scripts\charextras\" & trim(GetPlayerName(index)) & ".ini", "PORTALS", "x" & n) 
       If GetPlayerAccess(index) >= 1 Then 
       Call PlayerWarp(index, mapnum, x, y) 
       Else 
       Call PlayerMsg(index, "You do not have that ability.", 12) 
       End If 
     Exit Sub 
   End If

'<><><><><>

   If LCase(Mid(TextSay, 1, 9)) = "/warptome" Then
       If Len(TextSay) > 10 Then
           If GetPlayerAccess(index) < 2 Then
               Call PlayerMsg(index, "You need be of a higher access to use this command!", 12)
               Exit Sub
           End If

           n = Mid(TextSay, 10, Len(TextSay) - 9)
           n = FindPlayer(n)

           If n <> index Then
               If n > 0 Then
                   Call PlayerWarp(n, GetPlayerMap(index), GetPlayerX(index), GetPlayerY(index))
                   Call PlayerMsg(n, "You have been summoned by " & GetPlayerName(index) & ".", 14)
                   Call PlayerMsg(index, GetPlayerName(n) & " has been summoned.", 10)
                   Call AddLog(GetPlayerName(index) & " has warped " & GetPlayerName(n) & " to self, map #" & GetPlayerMap(index) & ".", ADMIN_LOG)
               Else
                   Call PlayerMsg(index, "Player is not online.", 12)
               End If
           Else
               Call PlayerMsg(index, "You cannot warp yourself to yourself!", 12)
           End If
       End If
       Exit Sub
   End If

'<><><><><>

   If LCase(Mid(TextSay, 1, 7)) = "/warpto" Then
       If Len(TextSay) > 8 Then
           TextSay = Mid(TextSay, 8, Len(TextSay) - 7)
           n = TextSay

           If n > 0 And n <= m Then
               If GetPlayerAccess(index) < 2 Then
                   Call PlayerMsg(index, "You need be of a higher access to use this command!", 12)
                   Exit Sub
               End If

               Call PlayerWarp(index, n, GetPlayerX(index), GetPlayerY(index))
               Call PlayerMsg(index, "You have been warped to map #" & n, 10)
               Call AddLog(GetPlayerName(index) & " warped to map #" & n & ".", ADMIN_LOG)
           Else
               Call PlayerMsg(index, "Invalid map number.", 12)
           End If
       End If
       Exit Sub
   End If

'<><><><><>

If LCase(Mid(TextSay, 1, 5)) = "/case" Then 

If int(getplayeraccess(index)) > 2 Then 

If Len(TextSay) > 6 Then 
TextSay = Mid(TextSay, 6, Len(TextSay) - 5) 

If trim(textsay) <> "" Then 

tile=int(getplayermapXY(index)) 
map=int(Getplayermap(index)) 

Call Putvar("scripts\mapextras\" & Int(map) & ".ini", "SCRIPT",Int(tile), trim(Textsay)) 
Call PlayerMsg(index, "You have bound tile number " & int(tile) & " to the script " & Textsay & "!", 13) 

Else 

Call Playermsg(index, "You must give a script name or number.", 13) 

End If 

End If 

Else 
Call Playermsg(index, "You have insufficient access to use this command.", 13) 
End If 

Exit Sub 
End If 

'<><><><><>

'-------------------------------
Select Case LCase(Trim(TextSay))
'-------------------------------

'<><><><><>

Case "/help"
Call PlayerMsg(index, "Social Commands:", 14)
Call PlayerMsg(index, "'msghere = Broadcast Message", 15)
Call PlayerMsg(index, "-msghere = Emote Message", 15)
Call PlayerMsg(index, "!namehere msghere = Player Message", 15)
Call PlayerMsg(index, "Available Commands: /help, /info, /who, /fps, /inv, /stats, /train, /party, /join, /leave, /refresh, /town, /8ball, /rainbow", 15)
Exit Sub

'<><><><><>

Case "/calladmins"
   If GetPlayerAccess(index) = 0 Then
       Call AdminMsg(GetPlayerName(index) & " needs an admin!", 14)
       Call PlayerMsg(index, "You have requested help from an admin.", 14)   
   Else
       Call PlayerMsg(index, "You are an admin, grow up and solve the problem.", 12)
   End If
Exit Sub

'<><><><><>

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

'<><><><><>

Case "/away"
   If GetPlayerAccess(index) >= 1 Then
       If GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status") = 0 Then
           Call GlobalMsg(GetPlayerName(index) & " is now away.", 14)
           Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status", 1)
           Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "TempPlayerName", GetPlayerName(index))
           Call SetPlayerName(index, GetPlayerName(index) & " - Away")
           Call SendPlayerData(index)
           Exit Sub
       ElseIf GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status") = 1 Then
           Call SetPlayerName(index, GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "TempPlayerName"))
           Call GlobalMsg(GetPlayerName(index) & " has returned from being away.", 14)
           Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status", 0)
           Call SendPlayerData(index)
           Exit Sub
       End If
   End If

'<><><><><> 

Case "/test"
Call testmain(index)
Exit Sub

'<><><><><> 

Case "/town"
Call use_town_portal(index)     
Exit Sub

'<><><><><>

Case "/top5" 
Call HighScore(index) 
Exit Sub 

'<><><><><>
End Select

Call PlayerMsg(index, "Thats not a valid command!", 12)
End Sub

'********************************
Sub Set_town_portal(index)
'******************************** 
Dim townmap
Dim townx
Dim towny

   townmap = 0 + GetPlayerMap(index)
   townx = 0 + GetPlayerX(index)
   towny = 0 + GetPlayerY(index)

   Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap", 0 + townmap)
   Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townx", 0 + townx)
   Call PutVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "towny", 0 + towny)

   Call PlayerMsg(index, "Your soul is now bound to this portal arch. Type /town to return here. " , 10)

End Sub

'********************************
Sub use_town_portal(index)       
'********************************

Dim townmap
Dim townx
Dim towny

If GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") <> "" Then

       townmap = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") )
       townx = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townx") )
       towny = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "towny") )

       Call PlayerWarp(index, Int(townmap), Int(townx), Int(towny) )
       Call Playermsg(index,"You summon a town portal returning you to town.", 10)

Else   
Call Playermsg(index,"You have not yet set a town to return to.", 12)           
End If 

End Sub 

'************************** 
'*AutoUpdatingHighScoreScript* 
'*******Version1.2********** 
'************************* 
Sub HighScore(index) 
Dim acc(50) 
Dim Char(50) 
Dim Charlvl(50) 
i=1 
j=1 
C=0 
Cnum = 0 
Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "Level" , GetPlayerLevel(Index)) 
Do While C = 0 
acc(i) = GetVar("accounts.ini", "Players", "Name" & i) 
If acc(i) <> "" Then 
'Call PlayerMsg(index, acc(i), 1) 
j = 1 
Do While j < 4 
If GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name") <> "" Then 
Cnum=Cnum+1 
Char(Cnum) = GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name") 
Charlvl(Cnum) = INT(GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Level")) 
End If 
j = j + 1 
Loop 
i = i + 1 
Else 
C=1 
Max=(i - 1) 
End If 
Loop 
Ca=1 
Cb=2 
Do While Ca < Cnum 
Do While Cb <= Cnum 
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1) 
If Charlvl(Ca) < Charlvl(Cb) Then 
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1) 
templvla = Charlvl(Ca) 
templvlb = Charlvl(Cb) 
tempnamea = Char(Ca) 
tempnameb = Char(Cb) 
Charlvl(Ca) = templvlb 
Charlvl(Cb) = templvla 
Char(Ca) = tempnameb 
Char(Cb) = tempnamea 
'Call PlayerMsg(index, "Switching", 1) 
End If 
Cb=(Cb + 1) 
Loop 
Ca=(Ca + 1) 
Cb=(Ca + 1) 
'Call PlayerMsg (index, Ca & Cb, 1) 
Loop 
Call battleMsg(index, "Top 5 Players by Level", 15, 0) 
Ca=1 
Do While Ca <= 5 
Call battleMsg(index, Char(Ca) & " = Level " & Charlvl(Ca), 12, 0) 
Ca=Ca+1 
Loop 
End Sub 

Sub UpdateScore(index) 
Dim acc(50) 
Dim Char(50) 
Dim Charlvl(50) 
i=1 
j=1 
C=0 
Cnum = 0 
Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "Level" , GetPlayerLevel(Index)) 
Do While C = 0 
acc(i) = GetVar("accounts.ini", "Players", "Name" & i) 
If acc(i) <> "" Then 
'Call PlayerMsg(index, acc(i), 1) 
j = 1 
Do While j < 4 
If GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name") <> "" Then 
Cnum=Cnum+1 
Char(Cnum) = GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Name") 
Charlvl(Cnum) = INT(GetVar("accounts\" & acc(i) & ".ini", "CHAR" & j, "Level")) 
End If 
j = j + 1 
Loop 
i = i + 1 
Else 
C=1 
Max=(i - 1) 
End If 
Loop 
Ca=1 
Cb=2 
Do While Ca < Cnum 
Do While Cb <= Cnum 
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1) 
If Charlvl(Ca) < Charlvl(Cb) Then 
'Call PlayerMsg(index, Charlvl(Ca) & " " & Charlvl(Cb), 1) 
templvla = Charlvl(Ca) 
templvlb = Charlvl(Cb) 
tempnamea = Char(Ca) 
tempnameb = Char(Cb) 
Charlvl(Ca) = templvlb 
Charlvl(Cb) = templvla 
Char(Ca) = tempnameb 
Char(Cb) = tempnamea 
'Call PlayerMsg(index, "Switching", 1) 
End If 
Cb=(Cb + 1) 
Loop 
Ca=(Ca + 1) 
Cb=(Ca + 1) 
'Call PlayerMsg (index, Ca & Cb, 1) 
Loop 
Call globalMsg(index, "Top 5 Players by Level", 15) 
Ca=1 
Do While Ca <= 5 
Call globalMsg(index, Char(Ca) & " = Level " & Charlvl(Ca), 12) 
Ca=Ca+1 
Loop 
End Sub

Sub SwimStart(index, sprite, message, color) 
   If GetPlayerSprite(index) = sprite Then 
       Call BlockPlayer(index) 
       Call PlayerMsg(index, "Sorry, you cant swim.", 1) 
   Else 
       Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "TempSprite" , 0) 
       Call PutVar("accounts\" & GetPlayerLogin(index) & ".ini " , "CHAR" & GetPlayerCharNum(Index) , "TempSprite" , GetPlayerSprite(index)) 
       Call SetPlayerSprite(index, sprite) 
       Call PlayerMsg(index, message, color) 
       Call SendPlayerData(index) 
   End If 
End Sub

'******************************** 
Function getplayermapXY(index) 
'******************************** 
Dim x 
Dim y 

x=1+GetPlayerX(index) 
y=GetPlayerY(index) 

getplayermapxy=x+(20*y) 

End Function 

'********************************
' 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

'********************************
Sub OnDeath(index)               
'********************************

Dim townmap
Dim townx
Dim towny

If GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") > 0 Then

       townmap = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townmap") )
       townx = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "townx") )
       towny = Int( GetVar("scripts\charextras\" & GetPlayerName(index) & ".ini", "TOWNPORTS", "towny") )
       Call PlayerWarp(index, Int(townmap), Int(townx), Int(towny) )

Else

townx=29
towny=22
townmap=1
Call PlayerWarp(index, Int(townmap), Int(townx), Int(towny) )

End If

Call Dropitems(index)
End Sub

'********************************

' Executes whenever a scripted item is used or double clicked.
Sub ScriptedItem(Index, Script)
   Select Case Script

Case 0
Call SetPlayerLevel( Index, GetPlayerLevel( Index) +1)
Call TakeItem(Index, 5, 1)
Call SendInventory( Index) 

     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

'**********************

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 getplayermapXY(index) 
'********************************
Dim x
Dim y

x=1+GetPlayerX(index)
y=GetPlayerY(index)

getplayermapxy=x+(20*y)

End Function

'********************************
Sub Uber_Scripted_Tiles(index)
'********************************
On Error Resume Next
Dim script
Dim map
Dim tile

tile=int(getplayermapXY(index))
map=int(Getplayermap(index))

script=Getvar("scripts\mapextras\" & Int(map) & ".ini", "SCRIPT",Int(tile))

Select Case script

   Case "Uber"
   Call playermsg(index, "This truly is an uber script. Done well Baron :D", 13)
   Exit Sub

   Case "savepoint"
   Call Set_town_portal(index)
   Exit Sub

   Case Else
   Call playermsg(index, "No script was found matching that title", 13)
   Exit Sub

End Select

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