Print Page | Close Window

AutoGet tutorial

Printed From: Mirage Source
Category: Tutorials
Forum Name: Temporary Archive (Read Only)
Forum Discription: Temporary 3.0.3 archive tutorials, will be deleted when converted.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=214
Printed Date: 20 December 2006 at 5:53pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: AutoGet tutorial
Posted By: Sync
Subject: AutoGet tutorial
Date Posted: 11 February 2006 at 3:36pm
Easy 1/5

CLIENT

Add:

AutoGet As Boolean

to PlayerRec

Above player direction packet add:

    ' :::::::::::::::::
    ' :: New AutoGet ::
    ' :::::::::::::::::
    If (LCase(Parse(0)) = "newget") Then
        Player(MyIndex).AutoGet = Parse(1)
    End If


make a cmd and call it cmdAutoGet in frmMirage

Private Sub cmdAutoGet_Click()
    If Player(MyIndex).AutoGet = True Then
        Player(MyIndex).AutoGet = False
        cmdAutoGet.Caption = "AutoGet Off"
    Else
        Player(MyIndex).AutoGet = True
        cmdAutoGet.Caption = "AutoGet On"
    End If
    Call SendData("AUTOGETS" & SEP_CHAR & Player(MyIndex).AutoGet & SEP_CHAR & END_CHAR)
End Sub



SERVER SIDE

Add

AutoGet As Boolean

to PlayerRec

Under:

        Player(Index).Char(i).MAGI = 0


add:

        Player(Index).Char(i).AutoGet = False


Replace sun give item with:

Sub GiveItem(ByVal Index As Long, ByVal ItemNum As Long, ByVal ItemVal As Long)
Dim i As Long

    ' Check for subscript out of range
    If IsPlaying(Index) = False Or ItemNum <= 0 Or ItemNum > MAX_ITEMS Then
        Exit Sub
    End If
    
    i = FindOpenInvSlot(Index, ItemNum)
   
    ' Check to see if inventory is full
    If i <> 0 Then
        Call SetPlayerInvItemNum(Index, i, ItemNum)
        Call SetPlayerInvItemValue(Index, i, GetPlayerInvItemValue(Index, i) + ItemVal)
       
        If (Item(ItemNum).Type = ITEM_TYPE_ARMOR) Or (Item(ItemNum).Type = ITEM_TYPE_WEAPON) Or (Item(ItemNum).Type = ITEM_TYPE_HELMET) Or (Item(ItemNum).Type = ITEM_TYPE_SHIELD) Then
             Call SetPlayerInvItemDur(Index, i, Item(ItemNum).Data1)
        End If
       
        Call SendInventoryUpdate(Index, i)
    ElseIf Player(Index).Char(Player(Index).CharNum).AutoGet = True Then
        Player(Index).Char(Player(Index).CharNum).AutoGet = False
        Call SendDataTo(Index, ("NEWGET" & SEP_CHAR & "False" & SEP_CHAR & END_CHAR))
        Call SpawnItem(ItemNum, ItemVal, GetPlayerMap(Index), GetPlayerX(Index), GetPlayerY(Index))
    Else
        Call PlayerMsg(Index, "Your inventory is full.", BrightRed)
    End If
End Sub


In attackNPC sub replace from

'Drop the goods if they get them


to


' Now set HP to 0 so we know to actually kill them in the server loop (this prevents subscript out of range)


with:

        'Drop the goods if they get them
        N = Int(Rnd * Npc(NpcNum).DropChance) + 1
        If N = 1 Then
             If Player(Attacker).Char(Player(Attacker).CharNum).AutoGet = True Then
                 Call GiveItem(Attacker, Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue)
                 If Npc(NpcNum).DropItem > 0 Then
                     If Item(Npc(NpcNum).DropItem).Type = ITEM_TYPE_CURRENCY Then
                           Call PlayerMsg(Attacker, "You have gained: " & Npc(NpcNum).DropItemValue & " - " & Item(Npc(NpcNum).DropItem).Name, Yellow)
                     Else
                           Call PlayerMsg(Attacker, "You have gained " & Item(Npc(NpcNum).DropItem).Name & ".", Yellow)
                     End If
                 End If
             Else
                 Call SpawnItem(Npc(NpcNum).DropItem, Npc(NpcNum).DropItemValue, MapNum, MapNpc(MapNum, MapNpcNum).X, MapNpc(MapNum, MapNpcNum).Y)
             End If
        End If


under save player packet add:

    ' :::::::::::::::::::::::::::
    ' :: Inventory list update ::
    ' :::::::::::::::::::::::::::
    If LCase(Parse(0)) = "autogets" Then
       Player(Index).Char(Player(Index).CharNum).AutoGet = Parse(1)
    End If



modDatabse

SavePlayer sub

under 'general add

Call PutVar(filename, "CHAR" & i, "PK", Player(Index).Char(i).AutoGet)


LoadPlayer

under 'general add

 Player(Index).Char(i).AutoGet = GetVar(filename, "CHAR" & i, "AutoGet")


that should be it.
[/code]



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info