Bounty Script

*Created by Taz.*

```
Using "RC_Core.rcm"
;Bounty hunter script
;By Tazco june 13 2012

;note need to make a black list that layers can add names to ;)

;Player bounty file will run as follows

				;Line 1 name
				;Line 2 Title
				;Line 3 Reward
				;Line 4 Date
				;Line 5 Reason
				;Line 6 Player that posted
				;Line 7 and 8 will be dud lines incase there is something else needed to add.

;POSIBILITY make a bounty that can go on a npc, would only need to change the find actor to look for npcs.
;It could work out as player set kill quests ;) shh dont tell anyone.
;when a players name is in the bounty master list an option to incress the reward amount will be offered.
;posting a name for bounty is working.
;Script to use with this one are Bounty lisdtings.rsl and BountyCheck.rsl

;npc names seem to be case sensitve
Function Main()

Player = Actor()
Target = ContextActor()
PName$ = Name(Player)

DateIssued$ = RealDate()
ScriptLog("Bounty running by " + Pname)

BML$ = "Bounty Master List.Txt"
Bountylist% = OpenFile(BML)
	If (BountyList = 0) ;write file if it is not there. avoid a server invalid steam crash
	WriteBM$ = WriteFile(BML)
	CloseFile(WriteBM)
	EndIf

	CloseFile(Bountylist)

	ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
	DialogOutPut(Player, ChatBox, "What would you like to do?")
	POption% = DialogInput(Player, ChatBox, "Check List of bountys,Post on bounty list,Bounty Hunting Instructions,Close")

			If (POption = 4) ;Closedialog and end script
				CloseDialog(Player, ChatBox)
				Return
			EndIf

			If (POption = 1) ;Check Bounty list
		    CloseDialog(Player, ChatBox)
			;Thread execute to Bounty listings script for bounty check to keep this one smaller and more organized.
			  ThreadExecute("Bounty listings", "Main", Player, 0)

			EndIf

			If (POption = 2) ;Post a bounty
			Repeat ;use if player needs to start over.
				CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(Player, ChatBox, "What is the name of the player to issue a bounty on?")
				PEnterName$ = Input(Player, "Enter name", "", 0)
               	Conrep% = 0
                ;Name Check
                	        If (PEnterName = PName)
         					   CloseDialog(Player, ChatBox)
						    	ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
         					   DialogOutPut(Player, ChatBox, "You can not add yourself to the bounty list")
         					   DialogInPut(Player, ChatBox, "Close")
         					   CloseDialog(Player, ChatBox)
         				 	   Return
      					    EndIf
    					  CloseDialog(Player, ChatBox)

						ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
						DialogOutPut(Player, ChatBox, "-----Please Wait while player name is checked-----")
                ;do repeat to search for actor.

 ;---------------------------------------------------------------------------------------------------------------------------------
  					;Check Actor
							    Repeat

							        ActorFound$ = FindActor(PEnterName, 3) ;find actor set to look for npcs for testing and may keep it that way
							        Doevents(10)
							    ;  OutPut(Player, "name finding is " + ActorFound)

							             If (ActorFound = 0) ;end loop if player not found
							               CloseDialog(Player, ChatBox)
							               ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
							               DialogOutPut(Player, ChatBox, "Player name not found.")
							               DialogInPut(Player, ChatBox, "Close")
							         	   CloseDialog(Player, ChatBox)
							               PlayerFound = 1
										   Return
							             EndIf

							     Until (ActorFound >= 1)
;---------------------------------------------------------------------------------------------------------------------------------

					;check if player name entered has a bounty already

					    Bountylistcheck% = OpenFile(+ PEnterName + " Bounty.Txt")

					    	If (Bountylistcheck >= 1)
					    			CloseFile(Bountylistcheck)
							     	;Allow player to add to a bounty reward instead of adding another bounty
									CloseDialog(Player, ChatBox)
									ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
									DialogOutPut(Player, Chatbox, +PEnterName + " already has a bounty on them, would you like to add to the reward?")
									POption% = DialogInput(Player, ChatBox, "Yes,No")

										If (POption = 2) ; close and tell player to wait to post.
											CloseDialog(Player, ChatBox)
											ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
											DialogOutput(Player, ChatBox, "Please wait till bounty is completed, to start a new one for this player.")
											DialogInput(Player, ChatBox, "Close")
											CloseDialog(Player, ChatBox)
											Return
										EndIf

									;set new amount of money to reward

									Repeat

										Repeat ;repeat player enter money
										CloseDialog(Player, ChatBox)
											ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
											DialogOutPut(Player, ChatBOx, "How much would you like to add to the bounty?")
											PAmount% = Input(Player, "Add money amount", "", 2)

											;Check if player has enough money

											PMoney% = Money(Player)
										   			If (PMoney < PAmount)
										   				CloseDialog(Player, ChatBox)
										   				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
										   				DialogOutPut(Player, ChatBox, "You do not have enough money, what would you like to do?")
										   				POption2% = DialogInput(Player, ChatBox, "Re enter amount,close")

										   					If (POption2 = 2) ;close
										   					CloseDialog(Player, ChatBox)
										   					Return
										   					EndIf

										   						If (POption2 = 1) ;re enter amount
										   							Reenter% = 0
										   						EndIf
										   			Else ;Player has enough money continue

										   				Reenter = 1
										   			EndIf

			   									DoEvents(100)

			  							 	Until(Reenter = 1) ;end repeat enter money

											CloseDialog(Player, ChatBox)
											ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
											DialogOutPut(Player, ChatBox, "Is the amount for " + PAmount + " right?")
											PlayOption% = DialogInput(Player, ChatBox, "Yes,No")

											 ;ask player if they want to reenter amount
											 If (PlayOption = 2)
											 	CloseDialog(Player, ChatBox)
										    	ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
											 	DialogOutPut(Player, ChatBox, "Would you like to re enter an amount?")
											 	POption1% = DialogInput(Player, ChatBox, "Yes,No")

											 	   If (POption1 = 2)
											 	  	CloseDialog(Player, ChatBox)
													ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
													DialogOutput(Player, ChatBox, "Please wait till bounty is completed, to start a new one for this player.")
													DialogInput(Player, ChatBox, "Close")
													CloseDialog(Player, ChatBox)
													Return
											 	   EndIf

											 		If (POption1 = 1)
											 			Restatamount% = 1
											 		EndIf

											 EndIf

										;player is fine with amount added it to bounty amout for player.
										If (PlayOption = 1)
										   ;Take money for bounty
											Moneytotake% = PMoney - PAmount
										    SetMoney(Player, Moneytotake)

										    ;Read reward amount from list to add it to total
												Namelisted1$ = + PEnterName + " Bounty.Txt"
												Bountylist1% = OpenFile(Namelisted1)

													NewRead1$ = ReadLine(Bountylist1) ;dud read
													Read1$ = NewRead1

													NewRead2$ = ReadLine(Bountylist1) ;dud read
													Read2$ = NewRead2

											    	ReadAmount1$ = ReadLine(Bountylist1) ;dud read ;reward

											    	NewRead3$ = ReadLine(Bountylist1) ;dud read
											    	Read3$ = NewRead3

											    	NewRead4$ = ReadLine(Bountylist1) ;dud read
											    	Read4$ = NewRead4

											    	NewRead5$ = ReadLine(Bountylist1) ;dud read
											    	Read5$ = NewRead5

													ReadAmount% = ReadAmount1
													TotalReward% = ReadAmount + PAmount

													TotRewardAsString$ = TotalReward

													CloseFile(Bountylist1)

													;Add new amount to bounty
													Namelisted$ = + PEnterName + " Bounty.Txt"
													Bountylist% = OpenFile(Namelisted)

													 WriteLine(Bountylist, Read1)  ;Name
													 WriteLine(Bountylist, Read2)	 ;title
													 WriteLine(Bountylist, TotRewardAsString) ;reward
													 WriteLine(Bountylist, Read3) ;enter date issued
													 WriteLine(Bountylist, Read4) ;reason
												     WriteLine(Bountylist, Read5) ;Player that posted

												;	 ReadLine(Bountylist) ;dud read
												;	 ReadLine(Bountylist) ;dud read
												;	 WriteLine(Bountylist, TotRewardAsString) ;reward new total

													CloseFile(Bountylist)

													CloseDialog(Player, ChatBox)
												    ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
													DialogOutPut(Player, ChatBox, "An amount of " + TotalReward + " is now being awarded, for " + PEnterName + "s bounty!")
													DialogInput(Player, ChatBox, "Close")
													CloseDialog(Player, ChatBox)
													Return

											EndIf

									  DoEvents(14)

							 		Until (Restatamount = 0) ;only used to loop the re entering amount for new reward total

							  EndIf

							     CloseFile(Bountylistcheck)

							     ;End Actor Check
;-------------------------------------------------------------------------------------------------------------------------------------------

				;Add bounty title
				CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(player, ChatBox, "Add a title for bounty.")
				PEnterTitle$ = Input(Player, "Enter a Title", "", 0) ;set to zero to add spaces while typing ingame

			Repeat
				;Add reward amout for bounty
				CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(Player, ChatBox, "How much is the reward for said bounty?")
			   	PEnterReward% = Input(Player, "Enter a reward", "", 2)

			   		PMoney% = Money(Player)
			   			If (PMoney < PEnterReward) 	;Check if player has enough money
			   				CloseDialog(Player, ChatBox)
			   				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
			   				DialogOutPut(Player, ChatBox, "You do not have enough money, what would you like to do?")
			   				POption2% = DialogInput(Player, ChatBox, "Re enter amount,close")

			   					If (POption2 = 2) ;close
			   					CloseDialog(Player, ChatBox)
			   					Return
			   					EndIf

			   						If (POption2 = 1) ;re enter amount
			   							Reenter% = 0
			   						EndIf
			   			Else ;Player has enough money continue

			   				Reenter = 1
			   			EndIf

			   	Until(Reenter = 1)

			    CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
                DialogOutPut(Player, ChatBox, "What is the reason for this bounty?")
               	PEnterReason$ = Input(Player, "Enter a reason", "", 0)

                 CloseDialog(Player, ChatBox)
			   	 ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				 DialogOutPut(Player, ChatBox, "Player Name     " + PEnterName)
				 DialogOutPut(Player, ChatBOx, "Bounty Title     " + PEnterTitle)
				 DialogOutPut(Player, ChatBox, "Bounty Reward     " + PEnterReward)
				 DialogOutPut(Player, ChatBox, "Bounty Reason     " + PEnterReason)

				 ;ask player if inof is right
				 ChatBox1$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				 DialogOutPut(Player, ChatBox1, "Is this info right?")
				 POption% = DialogInput(Player, ChatBox1, "Yes,No")

					If (POption = 1) ;Info is right add info to file.
						 CloseDialog(Player, ChatBox)
						 CloseDialog(Player, ChatBox1)
						Pready = 1
					EndIf

					If (POption = 2)
					  CloseDialog(Player, ChatBox)
					  CloseDialog(Player, ChatBox1)
					  ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
					  DialogOutPut(Player, ChatBox, "Would you like to start over?")
					  POption1% = DialogInput(Player, ChatBox, "Yes,No")

					    If (POption1 = 2) ;Close bounty
					    	CloseDialog(Player, ChatBox)
					    	CloseDialog(Player, ChatBox1)
					    	Return
					    EndIf

						If (POption1 = 1) ;restart post bounty
							 CloseDialog(Player, ChatBox)
					 		 CloseDialog(Player, ChatBox1)
							Pready = 0
						EndIf

					EndIf

						DoEvents(1000)
				Until (Pready = 1)

							 ;Take money for bounty
							Moneytotake% = PMoney - PEnterReward
							SetMoney(Player, Moneytotake)

				 ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(Player, ChatBox, "-----Please wait while info is added to the list.-----")

				;Add name to master list

;-----------------------------------------------------
;there is a file staying open in this area
;-----------------------------------------------------

				;Write Bounty file
				;Check if player has bounty already

				  MasterList$ = "Bounty Master List.Txt"
				  Bountylist% = ReadFile(MasterList)

				BountyinFile% = 0
				CountNames% = 0

				Repeat

							;to count names in list

							ReadBML$ = ReadLine(Bountylist)
							ReadBMLLine$ = ReadBML

								If (ReadBMLLine = PEnterName) ;player has a bounty
								;do nothing
								EndIf

						    	If (ReadBMLLine = "") ;no one in list end repeat
									nooneinlist% = 1
								Else
						    		CountNames% = CountNames + 1
								EndIf
								DoEvents(10)

								EndOfList% = EoF(Bountylist)  ;leave end of list check since it is counting players in list to use later.
									If (EndOfList = 1)
										BountyinFile1% = 2
									EndIf

				Until(BountyinFile1 >= 2)

					CloseFile(ReadBML)
					CloseFile(Bountylist)
					CloseFile(MasterList)

				;master bounty add player name

				If (CountNames >= 1) ;Add another name to bounty master list.

							;get names and write a temp file

							BMLTemp$ = "Bounty Master ListTemp.Txt"
							BountylistTemp% = OpenFile(BMLTemp)
								If (BountylistTemp = 0) ;write file if it is not there. avoid a server invalid steam crash
									WriteBMTemp$ = WriteFile(BMLTemp)
									CloseFile(WriteBMTemp)

								EndIf
							CloseFile(BMLTemp)
							CloseFile(BountylistTemp)

							;open master bounty list
							BML$ = "Bounty Master List.Txt"
							Bountylist% = OpenFile(BML)

							;open temp bounty list to copy to.
							BMLTemp$ = "Bounty Master ListTemp.Txt"
							BountylistTemp% = OpenFile(BMLTemp)

							CountNames% = CountNames ;number of lines to read
							BakNameCOunt% = CountNames  ;keep backup of amount of names in list add 1 for player to be added

							Repeat ;copy lines from txt to text.
							ReadTxtLine$ = ReadLine(Bountylist) ;readmaster list

							WriteLine(BountylistTemp, ReadTxtLine)  ;Write to temp list

							DoEvents(10)
							CountNames% = CountNames - 1
							Until (CountNames <= 0)

						;Close All files that are open
							CloseFile(ReadTxtLine)
							CloseFile(Bountylist)
							CloseFile(BountylistTemp)
							DeleteFile("Bounty Master List.Txt") ;remove file to remake and add changes.

							;Remake master bounty file
							BML$ = "Bounty Master List.Txt"
							Bountylist% = OpenFile(BML)
								If (BountyList = 0) ;write file if it is not there. avoid a server invalid steam crash
									WriteBM$ = WriteFile(BML)
									CloseFile(WriteBM)

								EndIf

								CloseFile(Bountylist)

							BML$ = "Bounty Master List.Txt"
							Bountylist% = OpenFile(BML)

						    BMLTemp$ = "Bounty Master ListTemp.Txt"
							BountylistTemp% = OpenFile(BMLTemp)
							SeekFile(BountylistTemp, 0)
								WriteLine(Bountylist, PEnterName)
								Repeat ;rewrite main file

								    	TempRead$ = ReadLine(BountylistTemp)

									WriteLine(Bountylist, TempRead)
									DoEvents(10)
							    	BakNameCOunt% = BakNameCOunt - 1

								Until (BakNameCOunt <= 0)

								CloseFile(Bountylist)
								CloseFile(BountylistTemp)
								DeleteFile("Bounty Master ListTemp.Txt") ;remove temp file

					;Make bounty file for player
						Namelisted$ = + PEnterName + " Bounty.Txt"
						Bountylist% = OpenFile(Namelisted)

							WriteBM$ = WriteFile(Namelisted)
							CloseFile(WriteBM)
							CloseFile(Bountylist)

					;add info for bounty to list
						Namelisted$ = + PEnterName + " Bounty.Txt"
						Bountylist% = OpenFile(Namelisted)

						 WriteLine(Bountylist, PEnterName)  ;Name
						 WriteLine(Bountylist, PEnterTitle)	 ;title
						 WriteLine(Bountylist, PEnterReward) ;reward
						 WriteLine(Bountylist, DateIssued) ;enter date issued
						 WriteLine(Bountylist, PEnterReason) ;reason
					     WriteLine(Bountylist, PName) ;Player that posted
						CloseFile(Bountylist)

						If (CountNames = 0); there is no one in list just add name
							BML$ = "Bounty Master List.Txt"
							Bountylist% = OpenFile(BML)
							WriteLine(Bountylist, PEnterName)
							CloseFile(Bountylist)

						EndIf

					EndIf

					If (nooneinlist = 1) ;player has no bounty make bounty file for them
						;Write name of player to master bounty list
							BML$ = "Bounty Master List.Txt"
							Bountylist% = OpenFile(BML)
							WriteLine(Bountylist, PEnterName)

							CloseFile(BML)
							CloseFile(Bountylist)

					;Make bounty file for player
						Namelisted$ = + PEnterName + " Bounty.Txt"
						Bountylist% = OpenFile(Namelisted)

							WriteBM$ = WriteFile(Namelisted)
							CloseFile(WriteBM)
							CloseFile(Bountylist)

					;add info for bounty to list
						Namelisted$ = + PEnterName + " Bounty.Txt"
						Bountylist% = OpenFile(Namelisted)

						 WriteLine(Bountylist, PEnterName)  ;Name
						 WriteLine(Bountylist, PEnterTitle)	 ;title
						 WriteLine(Bountylist, PEnterReward) ;reward
						 WriteLine(Bountylist, DateIssued) ;enter date issued
						 WriteLine(Bountylist, PEnterReason) ;reason
						 WriteLine(Bountylist, PName) ;Player that posted

						CloseFile(Bountylist)
					EndIf

				CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(Player, ChatBox, "Bounty added successfully!")
				DialogInput(Player, ChatBox, "Close")
				CloseDialog(Player, ChatBox)

				;Tell Target that there is a bounty on them and how they can get the details
				ScreenFlash(ActorFound, 255, 255, 255, 255, 9000, 439) ;flash bounty added to target
				OutPut(ActorFound, "There has been a bounty, for your death. The reward is " + PEnterReward + " You can check the details of this bounty by checking a wanted post.")

			EndIf
	If (POption = 3) ;give info on bounty hunting

	 Repeat
		CloseDialog(Player, ChatBox)
		ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
	    DialogOutPut(Player, ChatBox, "What would you like to know?")
	    POption2% = DialogInput(Player, ChatBOx, "How to post a Bounty,How to use the bounty list,Whats in it for me?,Whats the point?,Close")

	     		If (POption2 = 1) ;explain how to post bounty
	     		CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(Player, ChatBox, "Click post bounty, enter name of the player you would like to add a bounty on. Follow the instructions, there after, pay for the reward then someone can kill off the player or npc that was bugging you. A player with a bounty already, will allow you to add more money to sweeten the pot.")
	     		POPtion4% = DialogInput(Player, ChatBox, "Back,Close")
	     			If (POPtion4 = 2)
	     				InfoDone% = 1
	     				CloseDialog(Player, ChatBox)
	     			EndIf

	     		EndIf

	     If (POption2 = 2) ;how to use the bounty list
	     		CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
	     		DialogOutPut(Player, ChatBox, "A list of names that are bountys will be printed, on 2 different window. You can move the windows to see both pages, the list will give you all info you need about the bounty. Remeber that the current zone of the bounty is as of the time you check the list, By checking signs you will always get the most current zone of the bounty.")
	     		POption5% = DialogInput(Player, ChaTbox, "Back,Close")
	     			If (POption5 = 2) ;Close
	     				InfoDone% = 1
	     				CloseDialog(Player, ChatBox)

	     			EndIf

	     EndIf

	     If (POption2 = 3) ;whats in it for me
	     		CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOutPut(Player, ChatBox, "That player that keeps holding you in place, or killing you. Place a bounty on them, pay the reward and have someone else deal with them. Do you know what its like to keep having to look behind you? Don`t get a bounty on yourself and you will not have to find out.")
					   POption6% = DialogInput(Player, ChaTbox, "Back,Close")
	     			If (POption6 = 2) ;Close
	     				InfoDone% = 1
	     				CloseDialog(Player, ChatBox)
	     			EndIf

	     EndIf

	    If (POption2 = 4) ;whats in it for me
	     		CloseDialog(Player, ChatBox)
				ChatBox$ = OpenDialog(Player, Target, "Bounty Hunter", 521) ;added default textre
				DialogOUtPUt(Player, ChatBox, "The point is simple, pay someone to do your durty work. Also gain rep in either faction, by picking the ones based on what your faction rating will be on a kill.")
					POption6% = DialogInput(Player, ChaTbox, "Back,Close")
	     			If (POption6 = 2) ;Close
	     				InfoDone% = 1
	     				CloseDialog(Player, ChatBox)
	     			EndIf

		EndIf

		If (POption2 = 5) ;close
			CloseDialog(Player, CHatBox)
			InfoDone% = 1
		EndIf

	 Until (InfoDone = 1)

	EndIf

Return
End Function

```