tslusny Posted March 22, 2013 Author Share Posted March 22, 2013 **For Miracle Classic users**: Use this tutorial instead, it is optimized to work with MC - http://eatenbrain.com/forums/showthread.php?tid=16&pid=38#pid38Now search for this in modCombat:This tut was originally for Mirage Source 4, but i converted it to work with Eclipse and engines based on it (Miracle Classic, Eclipse Reborn).Here is link to original tutorial: [http://web.miragesou…hp?f=183&t=4961](http://web.miragesource.net/forums/viewtopic.php?f=183&t=4961)This feature gives you two different commands:/bounty (playername) (price of bounty)/bounties (Displays the list of people with prices on their head, and how much)Also it allows you to use two new functions: GetPlayerBounty, and SetPlayerBounty. Have fun.Also, remember to read the code. After all, it will require one or two tweaks, such as replacing the 1's with the number slot that your currency is, etc, etc.So… Let´s begin ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)**Client side:**Search for in modEnumerations:```CMSG_COUNT```And add this ABOVE:```CSetBountyCBountyList```Then search for this in modInput:```Case "/help"Call AddText("Social Commands:", HelpColor)Call AddText("'msghere = Broadcast Message", HelpColor)Call AddText("-msghere = Emote Message", HelpColor)Call AddText("!namehere msghere = Player Message", HelpColor)Call AddText("Available Commands: /stats, /who, /fps, /fpslock, /emotes", HelpColor)```And add this under it:```Case "/bounty"If UBound(Command) < 2 ThenAddText "Usage: /bounty (name) (price)", AlertColorGoTo ContinueEnd IfIf IsNumeric(Command(1)) = True Or IsNumeric(Command(2)) = False ThenAddText "Usage: /setname (name) (price)", AlertColorGoTo ContinueEnd IfSendSetBounty Command(1), (Command(2))Case "/bounties"SendBountyList```Now add this 2 subs at bottom of modCientTCP:```Public Sub SendBountyList()Dim buffer As clsBuffer' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo ErrorHandlerSet buffer = New clsBufferbuffer.WriteLong CBountyListSendData buffer.ToArray()Set buffer = Nothing' Error handlerExit SubErrorHandler:HandleError "SendBountyList", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubPublic Sub SendSetBounty(ByVal Name As String, ByVal Bounty As Long)Dim buffer As clsBuffer' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo ErrorHandlerSet buffer = New clsBufferbuffer.WriteLong CSetBountybuffer.WriteString Namebuffer.WriteLong BountySendData buffer.ToArray()Set buffer = Nothing' Error handlerExit SubErrorHandler:HandleError "SendSetBounty", "modClientTCP", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```**Server side:**Search for in modEnumerations:```CMSG_COUNT```And add this ABOVE:```CSetBountyCBountyList```Now add this at bottom of Sub InitMessages in modHandleData:```HandleDataSub(CSetBounty) = GetAddress(AddressOf HandleSetBounty)HandleDataSub(CBountyList) = GetAddress(AddressOf HandleBountyList)```Almost done ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)Now add this at bottom of modHandleData:```' :::::::::::::::::::::::' :: Set access packet ::' :::::::::::::::::::::::Sub HandleSetBounty(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim N As LongDim i As LongDim buffer As clsBufferOn Error GoTo ErrorHandlerSet buffer = New clsBufferbuffer.WriteBytes Data()' The indexN = FindPlayer(buffer.ReadString) 'Parse(1))' The accessi = buffer.ReadLong 'CLng(Parse(2))Set buffer = Nothing' Check if player is onIf N > 0 ThenIf N <> index ThenIf GetPlayerLevel(N) >= 10 ThenIf GetPlayerBounty(N) = 0 ThenIf TakeGold(index, 1, i) ThenCall GlobalMsg(GetPlayerName(index) & " has just had a " & i & " dollar bounty put on " & GetPlayerName(N) & "!", BrightBlue)Call SetPlayerBounty(N, i)Call SendPlayerData(N)Call AddLog(GetPlayerName(index) & " has put a " & i & " bounty on " & GetPlayerName(N), ADMIN_LOG)ElseCall PlayerMsg(index, "You don't have sufficient funds for this action!", BrightRed)End IfElseCall PlayerMsg(index, GetPlayerName(N) & " already has a price on their head!", BrightRed)End IfElseCall PlayerMsg(index, "Player must be level 10 or higher!", BrightRed)End IfElseCall PlayerMsg(index, "You cant set a hit out on yourself!", BrightRed)End IfElseCall PlayerMsg(index, "Player isn't online!", BrightRed)End If' Error handlerExit SubErrorHandler:HandleError "HandleSetAccess", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub' :::::::::::::::::::::::' :: Who online packet ::' :::::::::::::::::::::::Sub HandleBountyList(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)On Error GoTo ErrorHandlerCall SendBountyList(index)' Error handlerExit SubErrorHandler:HandleError "HandleWhosOnline", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Now add this to bottom of Type PlayerRec in modTypes (or Type CharRec if you are using Miracle Classic with multiple chars per account)```Bounty As Long```Now add this at bottom of modPlayer:```Function GetPlayerBounty(ByVal index As Long) As LongOn Error GoTo ErrorHandlerIf index > MAX_PLAYERS Then Exit FunctionGetPlayerBounty = Player(index).Bounty' Error handlerExit FunctionErrorHandler:HandleError "GetPlayerPK", "modPlayer", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit FunctionEnd FunctionSub SetPlayerBounty(ByVal index As Long, ByVal Bounty As Long)On Error GoTo ErrorHandlerPlayer(index).Bounty = Bounty' Error handlerExit SubErrorHandler:HandleError "SetPlayerPK", "modPlayer", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd SubFunction TakeGold(ByVal index As Long, ByVal ItemNum As Long, ByVal ItemVal As Long) As BooleanDim i As Long, N As LongTakeGold = False' Check for subscript out of rangeIf IsPlaying(index) = False Or ItemNum <= 0 Or ItemNum > MAX_ITEMS ThenExit FunctionEnd IfFor i = 1 To MAX_INV' Check to see if the player has the itemIf GetPlayerInvItemNum(index, i) = ItemNum ThenIf Item(ItemNum).Type = ITEM_TYPE_CURRENCY Then' Is what we are trying to take away more then what they have? If so just set it to zeroIf ItemVal <= GetPlayerInvItemValue(index, i) ThenCall SetPlayerInvItemValue(index, i, GetPlayerInvItemValue(index, i) - ItemVal)Call SendInventoryUpdate(index, i)TakeGold = TrueExit FunctionEnd IfEnd IfEnd IfNext iEnd Function```Now add this to bottom of modServerTCP:```Sub SendBountyList(ByVal index As Long)Dim s As StringDim N As Long, i As LongFor i = 1 To MAX_PLAYERSIf IsPlaying(i) ThenIf i <> index ThenIf GetPlayerBounty(i) > 0 Thens = s & GetPlayerName(i) & "(" & GetPlayerBounty(i) & ")" & ", "N = N + 1End IfEnd IfEnd IfNext iIf N = 0 Thens = "No one has a bounty!"Elses = Mid$(s, 1, Len(s) - 2)s = "There are " & N & " players with bounties: " & s & "."End IfCall PlayerMsg(index, s, WhoColor)' Error handlerExit SubErrorHandler:HandleError "SendBountyList", "modServerTCP", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Now search for this in modCombat:```' Player is deadCall GlobalMsg(GetPlayerName(victim) & " has been killed by " & GetPlayerName(attacker), BrightRed)```IN! Sub PlayerAttackPlayer (there is similar thing in NPCAttackPlayer so..)And add this under it:```If GetPlayerBounty(victim) > 0 Then'Give the rewardCall GiveInvItem(attacker, 1, GetPlayerBounty(victim))'Send the messagesCall PlayerMsg(attacker, "You have received: " & GetPlayerBounty(victim) & " dollars for killing " & GetPlayerName(victim), BrightGreen)Call GlobalMsg(GetPlayerName(victim) & " has been slain by " & GetPlayerName(attacker) & " and has collected the " & GetPlayerBounty(victim) & " dollar bounty on his/her head", BrightGreen)'Set the bounty to 0Call SetPlayerBounty(victim, 0)End If``` Link to comment Share on other sites More sharing options...
Guest Posted March 22, 2013 Share Posted March 22, 2013 Looks pretty legit, and not too long. Good job, your pretty efficient as far as coding goes. The system seems to work nice. I'll test it later when my VB6 is available. Link to comment Share on other sites More sharing options...
Alerd Posted March 22, 2013 Share Posted March 22, 2013 Thanx for tut ;] Link to comment Share on other sites More sharing options...
DeathlyCreation Posted March 22, 2013 Share Posted March 22, 2013 When you say "Search for:" you don't tell us which module your telling us to search in. Can you please say each module where you search in. Even tho i'm guessing it's in modEnum Link to comment Share on other sites More sharing options...
XXGameMasterxXx Posted March 22, 2013 Share Posted March 22, 2013 Good work! Link to comment Share on other sites More sharing options...
tslusny Posted March 22, 2013 Author Share Posted March 22, 2013 > When you say "Search for:" you don't tell us which module your telling us to search in. Can you please say each module where you search in. Even tho i'm guessing it's in modEnumYea, it is in modEnums.I do not added to search in what module, becouse you can just search entire project with CTRL+F ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png). I did this in rush, but ok i will add it. Link to comment Share on other sites More sharing options...
Stach Posted March 22, 2013 Share Posted March 22, 2013 > When you say "Search for:" you don't tell us which module your telling us to search in. Can you please say each module where you search in. Even tho i'm guessing it's in modEnumSearch the entire project then. Link to comment Share on other sites More sharing options...
DeathlyCreation Posted March 22, 2013 Share Posted March 22, 2013 In server I get error in modHandleData;Call SendBountyList(index)not defined Link to comment Share on other sites More sharing options...
DMF Posted March 22, 2013 Share Posted March 22, 2013 this acutaly looks useful. XD nice Link to comment Share on other sites More sharing options...
Elihu Posted March 22, 2013 Share Posted March 22, 2013 Nice, Player Killers will suffer like hell for their transgressions with a bunch of greedy bastards looking to make a quick sack of gold off their heads XD. Link to comment Share on other sites More sharing options...
tslusny Posted March 22, 2013 Author Share Posted March 22, 2013 > In server I get error in modHandleData;> > Call SendBountyList(index)> > not definedYea, i forgot add that sub to tut. Updated.Here is that sub (add it to bottom of modServerTCP)```Sub SendBountyList(ByVal index As Long)Dim s As StringDim N As Long, i As LongFor i = 1 To MAX_PLAYERSIf IsPlaying(i) ThenIf i <> index ThenIf GetPlayerBounty(i) > 0 Thens = s & GetPlayerName(i) & "(" & GetPlayerBounty(i) & ")" & ", "N = N + 1End IfEnd IfEnd IfNext iIf N = 0 Thens = "No one has a bounty!"Elses = Mid$(s, 1, Len(s) - 2)s = "There are " & N & " players with bounties: " & s & "."End IfCall PlayerMsg(index, s, WhoColor)' Error handlerExit SubErrorHandler:HandleError "SendBountyList", "modServerTCP", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub``` Link to comment Share on other sites More sharing options...
DeathlyCreation Posted March 22, 2013 Share Posted March 22, 2013 Now I get this error.```Function GetPlayerBounty(ByVal index As Long) As LongOn Error GoTo ErrorHandlerIf index > MAX_PLAYERS Or TempPlayer(index).CurChar = 0 Then Exit FunctionGetPlayerBounty = Player(index).Char(TempPlayer(index).CurChar).Bounty' Error handlerExit FunctionErrorHandler:HandleError "GetPlayerPK", "modPlayer", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit FunctionEnd Function```Highlighting on this line```If index > MAX_PLAYERS Or TempPlayer(index).CurChar = 0 Then Exit Function```Only the```.CurChar```Part Link to comment Share on other sites More sharing options...
DeathlyCreation Posted March 22, 2013 Share Posted March 22, 2013 After fixing that errorGetPlayerBounty = Player(index).Char(TempPlayer(index).CurChar).BountyI reapeated and fixed this errorPlayer(index).Char(TempPlayer(index).CurChar).Bounty = BountyNow I got this errorIf Item(ItemNum).Type = ItemCurrency ThenVarriable not defined Link to comment Share on other sites More sharing options...
DeathlyCreation Posted March 22, 2013 Share Posted March 22, 2013 Call GiveInvItem(attacker, 1, GetPlayerBounty(victim))attacker variable not defined Link to comment Share on other sites More sharing options...
DeathlyCreation Posted March 22, 2013 Share Posted March 22, 2013 ```If GetPlayerBounty(victim) > 0 Then'Give the rewardCall GiveInvItem(attacker, 1, GetPlayerBounty(victim))'Send the messagesCall PlayerMsg(attacker, "You have received: " & GetPlayerBounty(victim) & " dollars for killing " & GetPlayerName(victim), BrightGreen)Call GlobalMsg(GetPlayerName(victim) & " has been slain by " & GetPlayerName(attacker) & " and has collected the " & GetPlayerBounty(victim) & " dollar bounty on his/her head", BrightGreen)'Set the bounty to 0Call SetPlayerBounty(victim, 0)End If``````Call GiveInvItem(attacker, 1, GetPlayerBounty(victim))```attacker variable not defined Link to comment Share on other sites More sharing options...
Wortel Angels Posted March 22, 2013 Share Posted March 22, 2013 If i understand that corrects does it set an price of you for killing you ?So if i would type /bounty MortalAngels 1000Would the one which kill me get 1000 ?I cant test it so i ask xD (Not at home) Link to comment Share on other sites More sharing options...
tslusny Posted March 22, 2013 Author Share Posted March 22, 2013 > If i understand that corrects does it set an price of you for killing you ?> > So if i would type /bounty MortalAngels 1000> > Would the one which kill me get 1000 ?> > I cant test it so i ask xD (Not at home)Yea, put you can´t set bounty on yourself ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png)And everything in tutorial is now fixed (thx to Deathly for reporting bugs ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) ) Link to comment Share on other sites More sharing options...
Alerd Posted March 22, 2013 Share Posted March 22, 2013 System without errors?Strongly slows down the server? Link to comment Share on other sites More sharing options...
tslusny Posted March 22, 2013 Author Share Posted March 22, 2013 > System without errors?> > Strongly slows down the server?1\. Yes2\. Not at all ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
WiseRock Posted March 24, 2013 Share Posted March 24, 2013 Could you make so it if you kill some1 that has a bounty on them you don't become a player killer? Link to comment Share on other sites More sharing options...
tslusny Posted March 24, 2013 Author Share Posted March 24, 2013 > Could you make so it if you kill some1 that has a bounty on them you don't become a player killer?But…. When you kill player, you ARE player killer ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) ![:D](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/biggrin.png) Link to comment Share on other sites More sharing options...
elementaldisaster Posted March 27, 2013 Share Posted March 27, 2013 > ```> If GetPlayerBounty(victim) > 0 Then> > 'Give the reward> > Call GiveInvItem(attacker, 1, GetPlayerBounty(victim))> > 'Send the messages> > Call PlayerMsg(attacker, "You have received: " & GetPlayerBounty(victim) & " dollars for killing " & GetPlayerName(victim), BrightGreen)> > Call GlobalMsg(GetPlayerName(victim) & " has been slain by " & GetPlayerName(attacker) & " and has collected the " & GetPlayerBounty(victim) & " dollar bounty on his/her head", BrightGreen)> > 'Set the bounty to 0> > Call SetPlayerBounty(victim, 0)> > End If> ```> > ```> Call GiveInvItem(attacker, 1, GetPlayerBounty(victim))> ```> > attacker variable not definedStill not defined… Link to comment Share on other sites More sharing options...
DMF Posted March 28, 2013 Share Posted March 28, 2013 is this done o-o just watchin since up up and bored.. Link to comment Share on other sites More sharing options...
tslusny Posted March 28, 2013 Author Share Posted March 28, 2013 > Still not defined…Becouse you put it in wrong sub…. Read tutorial carefully.> is this done o-o just watchin since up up and bored..Yea this tut is 100% working. Link to comment Share on other sites More sharing options...
Kumi Posted April 10, 2013 Share Posted April 10, 2013 It's not working for me, i think i done some error but a error appears saying "Compile error: Variable not defined" and highlights this 'AddressOf HandleSetBounty' Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now