' 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)
    	NUM = 1
    	Do While NUM <= 500
    	Call PutVar("Questy\Gracze\" & GetPlayerName(index) & ".ini", "QUEST", "Quest" & NUM, 0)
    	NUM = NUM + 1
   	Loop
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)

    Map = GetPlayerMap(index)
    Wymaga=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga")) + 0
    Daje=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Daje")) + 0
    Ile=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Ile")) + 0
    Wymaga=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga")) + 0
    Wymaga2=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga2")) + 0
    Wymaga3=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga3")) + 0
    Wymaga4=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga4")) + 0

    Select Case Clicked_Index        
    Case 3
        Call PutVar("Questy\Gracze\" & GetPlayerName(index) & ".ini", "QUEST", "Quest"&Map, 1)
        Call CustomMenuClose(index)
    Exit Sub

    Case 4
        Call CustomMenuClose(index)
    Exit Sub

    Case 5
        If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 1 Then
            Call TakeItem(index, Wymaga)
        End If

        If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 2 Then
            Call TakeItem(index, Wymaga)
            Call TakeItem(index, Wymaga2)
        End If

        If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 3 Then
            Call TakeItem(index, Wymaga)
            Call TakeItem(index, Wymaga2)
            Call TakeItem(index, Wymaga3)
        End If

        If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 4 Then
            Call TakeItem(index, Wymaga)
            Call TakeItem(index, Wymaga2)
            Call TakeItem(index, Wymaga3)
            Call TakeItem(index, Wymaga4)
        End If
            Call PlayerMsg(Index, "Zadanie wykonane!", WHITE)
            Call CustomMenuClose(index)
            Call GiveItem(index, Daje, Ile)
            Call PutVar("Questy\Gracze\" & GetPlayerName(index) & ".ini", "QUEST", "Quest"&Map, 2)
    Exit Sub

    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) & " dołączył do " & GameName & "!", YELLOW)
	End If

	Call PlayerMsg(Index, "Witamy w " & 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) & " odszedł z " & 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, "Obecnie posiadasz " & GetPlayerPOINTS(Index) & " punktów statystyk.", 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, "Posidasz maksimum siły!", BRIGHTRED, 0)
				Exit Sub
			End If
			Call SetPlayerSTR(Index, GetPlayerSTR(Index) + 1)
			Call BattleMsg(Index, "Otrzymałeś więcej siły!", WHITE, 0)

		Case 1
			If GetPlayerDEF(Index) + 1 > 1000 Then
				Call BattleMsg(Index, "Posiadasz maksimum wytrzymałości!", BRIGHTRED, 0)
				Exit Sub
			End If
			Call SetPlayerDEF(Index, GetPlayerDEF(Index) + 1)
			Call BattleMsg(Index, "Otrzymałeś więcej wytrzymałości!", WHITE, 0)

		Case 2
			If GetPlayerMAGI(Index) + 1 > 1000 Then
				Call BattleMsg(Index, "Posiadasz maksimum magii!", BRIGHTRED, 0)
				Exit Sub
			End If
			Call SetPlayerMAGI(Index, GetPlayerMAGI(Index) + 1)
			Call BattleMsg(Index, "Otrzymałeś więcej magii!", WHITE, 0)

		Case 3
			If GetPlayerSPEED(Index) + 1 > 1000 Then
				Call BattleMsg(Index, "Posiadasz maksimum szybkości!", BRIGHTRED, 0)
				Exit Sub
			End If
			Call SetPlayerSPEED(Index, GetPlayerSPEED(Index) + 1)
			Call BattleMsg(Index, "Otrzymałeś więcej szybkości!", 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 PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
			Exit Sub
                Case 1
         If FindItemSlot(index, 3) Then
                      Call GiveItem(index, 4, 1)
 
                      Call PlayerMsg(index, "Udało ci się ", RED)
         Else
                      Call PlayerMsg(index, "Nie masz narzędzi!", RED)
         End If
               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, "Zabiłeś " & 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) & " zaostał zabity przez " & 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) & " został zabity na arenie przez " & 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 PlayerMsg(Index, "This scripted spell has no apparent use.", WHITE)
			Exit 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 1
                      Call SetPlayerHP(Index, GetPlayerMaxHP(Index))
 
                      Call PlayerMsg(index, "Uleczyłeś się", YELLOW)
                Exit Sub
    		Case 2
        			Call QuestSystem(index)
    		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
			Call PlayerMsg(Index, "This scripted item has no apparent use.", WHITE)
			Exit Sub
                Case 1
		Call PlayerWarp(Index, 2, 3, 5)
                       Exit Sub
		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

Sub OnClickPlayer(Index)
         Call CustomMenuShow(index, "Player Profile", "\GUI\profil.gif", 1)
         Call CustomMenuLabel(index, 1, "Gracz : " & GetTargetName(index), 150, 50, 10, 0, 0, 400, 20)
         Call CustomMenuLabel(index, 2, "Poziom : " & GetTargetLevel(index), 20, 100, 10, 0, 0, 400, 20)
         Call CustomMenuLabel(index, 4, "Gildia : " & GetTargetGuild(index), 20, 140, 10, 0, 0, 400, 20)
         Call CustomMenuLabel(index, 5, "Atak : " & GetTargetStr(index), 20, 160, 10, 0, 0, 400, 20)
         Call CustomMenuLabel(index, 6, "Obrona : " & GetTargetDef(index), 20, 180, 10, 0, 0, 400, 20)
         Call CustomMenuLabel(index, 7, "Magia : " & GetTargetMagi(index), 20, 200, 10, 0, 0, 400, 20)
         Call CustomMenuLabel(index, 8, "Szybkosc : " & GetTargetSpeed(index), 20, 220, 10, 0, 0, 400, 20)
End Sub

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

Sub TakeItem(index, item)
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

Function FindItemSlot(index, item)
slot = 1
Do While slot <= 24
If GetPlayerInvItemNum(index, Slot) = item Then
FindItemSlot = slot
slot = 24
Else
FindItemSlot = 0
End If
slot = slot + 1
Loop
End Function

Sub QuestSystem(index)
    Map = GetPlayerMap(index)
    Nazwa = GetVar("Questy\" & map & ".ini", "QUEST", "Nazwa")
    Mowa = GetVar("Questy\" & map & ".ini", "QUEST", "Mowa")
    WymagaLevel=Int(GetVar("Questy\" & map & ".ini", "QUEST", "WymagaLevel")) + 0
    OpcjaYes = GetVar("Questy\" & map & ".ini", "QUEST", "OpcjaYes")
    OpcjaNo = GetVar("Questy\" & map & ".ini", "QUEST", "OpcjaNo")
    MowaKoncowa=GetVar("Questy\" & map & ".ini", "QUEST", "MowaKoncowa")
    Wymaga=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga")) + 0
    Wymaga2=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga2")) + 0
    Wymaga3=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga3")) + 0
    Wymaga4=Int(GetVar("Questy\" & map & ".ini", "QUEST", "Wymaga4")) + 0

    If GetPlayerLevel(index) => WymagaLevel Then
        If GetVar("Questy\Gracze\" & GetPlayerName(index) & ".ini","QUEST", "Quest" &Map) = 0 Then
            Call CustomMenuShow(index, "quest", "\GFX\quest.gif", 1)
            Call CustomMenuLabel(index, 1, "Nazwa: "&Nazwa, 130, 10, 15, 0, 0, 408, 30)
            Call CustomMenuLabel(index, 2, Mowa, 40, 60, 10, 0, 0, 408, 110)
            Call CustomMenuLabel(index, 3, "-" & OpcjaYes, 40, 210, 10, 0, 0, 408, 17)
            Call CustomMenuLabel(index, 4, "-" & OpcjaNo, 40, 230, 10, 0, 0, 408, 17)
        End If
    Else
        Call PlayerMsg(index, "Nie posiadasz " & WymagaLevel &" levela!" ,RED)
    End If

    If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 1 Then
        If GetVar("Questy\Gracze\" & GetPlayerName(index) & ".ini","QUEST", "Quest" &Map) = 1 Then
            If FindItemSlot(index, Wymaga) Then
                Call CustomMenuShow(index, "quest", "\GFX\quest.gif", 1)
                Call CustomMenuLabel(index, 1, "Nazwa: "&Nazwa, 130, 10, 15, 0, 0, 408, 30)
                Call CustomMenuLabel(index, 2, MowaKoncowa, 40, 60, 10, 0, 0, 408, 110)
                Call CustomMenuLabel(index, 5, "Odbierz Nagrode", 70, 210, 10, 0, 0, 408, 17)
            Else
                Call PlayerMsg(Index, "Pospiesz się!", WHITE)
            End If
        End If
    End If

    If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 2 Then
        If GetVar("Questy\Gracze\" & GetPlayerName(index) & ".ini","QUEST", "Quest" &Map) = 1 Then
            If FindItemSlot(index, Wymaga) Then
                If FindItemSlot(index, Wymaga2) Then
                    Call CustomMenuShow(index, "quest", "\GFX\quest.gif", 1)
                    Call CustomMenuLabel(index, 1, "Nazwa: "&Nazwa, 130, 10, 15, 0, 0, 408, 30)
                    Call CustomMenuLabel(index, 2, MowaKoncowa, 40, 60, 10, 0, 0, 408, 110)
                    Call CustomMenuLabel(index, 5, "Odbierz Nagrode", 70, 210, 10, 0, 0, 408, 17)
                End If
            Else
                Call PlayerMsg(Index, "Pospiesz sie!", WHITE)
            End If
        End If
    End If

    If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 3 Then
        If GetVar("Questy\Gracze\" & GetPlayerName(index) & ".ini","QUEST", "Quest" &Map) = 1 Then
            If FindItemSlot(index, Wymaga) Then
                If FindItemSlot(index, Wymaga2) Then
                    If FindItemSlot(index, Wymaga3) Then
                        Call CustomMenuShow(index, "quest", "\GFX\quest.gif", 1)
                        Call CustomMenuLabel(index, 1, "Nazwa: "&Nazwa, 130, 10, 15, 0, 0, 408, 30)
                        Call CustomMenuLabel(index, 2, MowaKoncowa, 40, 60, 10, 0, 0, 408, 110)
                        Call CustomMenuLabel(index, 5, "Odbierz Nagrode", 70, 210, 10, 0, 0, 408, 17)
                    End If
                End If
            Else
                Call PlayerMsg(Index, "Pospiesz sie!", WHITE)
            End If
        End If
    End If

    If GetVar("Questy\" & Map & ".ini","QUEST", "Item") = 4 Then
        If GetVar("Questy\Gracze\" & GetPlayerName(index) & ".ini","QUEST", "Quest" &Map) = 1 Then
            If FindItemSlot(index, Wymaga) Then
                If FindItemSlot(index, Wymaga2) Then
                    If FindItemSlot(index, Wymaga3) Then
                        If FindItemSlot(index, Wymaga4) Then
                            Call CustomMenuShow(index, "quest", "\GFX\quest.gif", 1)
                            Call CustomMenuLabel(index, 1, "Nazwa: "&Nazwa, 130, 10, 15, 0, 0, 408, 30)
                            Call CustomMenuLabel(index, 2, MowaKoncowa, 40, 60, 10, 0, 0, 408, 110)
                            Call CustomMenuLabel(index, 5, "Odbierz Nagrode", 70, 210, 10, 0, 0, 408, 17)
                        End If
                    End If
                End If
            Else
                Call PlayerMsg(Index, "Pospiesz sie!", WHITE)
            End If
        End If
    End If



    If GetVar("Questy\Gracze\" & GetPlayerName(index) & ".ini","QUEST", "Quest" &Map) = 2 Then
        Call PlayerMsg(Index, MowaKoncowa, WHITE)
    End If

End Sub