Jump to content
flamyman1412

AddMoney Mob

Recommended Posts

4 hours ago, flamyman1412 said:

I will kill a mob by giving money, for example lv
1-20 mob gives 1000 G.
21-40 gives 2000 G
what do i have to do

Look into this thread, you might find something similar or use it (it defines mobs by ID)

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Hello @flamyman1412!

 

Add this script to file functions.lua:

-- Player killed monster event
GetExp_PKM__Original = GetExp_PKM
GetExp_PKM = function(monster, role)
	
	-- Call original function GetExp_PKM()
	GetExp_PKM__Original(monster, role)
	
	-- Get killed monster level
	local level = Lv(monster)
	
	-- Give money to player
	if (level < 21) then
		AddMoney(role, 0, 1000)
	else
		if (level < 41) then
			AddMoney(role, 0, 2000)
		end
	end
	
end

 


Share this post


Link to post
Share on other sites
On 11/21/2021 at 12:58 AM, V3ct0r said:

Hello @flamyman1412!

 

Add this script to file functions.lua:


-- Player killed monster event
GetExp_PKM__Original = GetExp_PKM
GetExp_PKM = function(monster, role)
	
	-- Call original function GetExp_PKM()
	GetExp_PKM__Original(monster, role)
	
	-- Get killed monster level
	local level = Lv(monster)
	
	-- Give money to player
	if (level < 21) then
		AddMoney(role, 0, 1000)
	else
		if (level < 41) then
			AddMoney(role, 0, 2000)
		end
	end
	
end

 

Why am I not leveling up and have to re-enter?

Share this post


Link to post
Share on other sites
21 hours ago, flamyman1412 said:

Why am I not leveling up and have to re-enter?

It is hard to say what is the problem. Perhaps your server files contains some modifications that led to the existance of such a bug.


Share this post


Link to post
Share on other sites
21 час назад, flamyman1412 сказал:

Why am I not leveling up and have to re-enter?

Replace this:

-- Give money to player
	if (level < 21) then
		AddMoney(role, 0, 1000)
	else
		if (level < 41) then
			AddMoney(role, 0, 2000)
		end
	end

On this:

-- Give money to player
  if (level < 21) then
  
    AddMoney(role, 0, 1000)
  
  elseif (level < 41)  then
  
      AddMoney(role, 0, 2000)
  
  else -- >= 41
  
  	 AddMoney(role, 0, 3000)
  
  end

 

Share this post


Link to post
Share on other sites
1 hour ago, VItal13 said:

Replace this:


-- Give money to player
	if (level < 21) then
		AddMoney(role, 0, 1000)
	else
		if (level < 41) then
			AddMoney(role, 0, 2000)
		end
	end

On this:


-- Give money to player
  if (level < 21) then
  
    AddMoney(role, 0, 1000)
  
  elseif (level < 41)  then
  
      AddMoney(role, 0, 2000)
  
  else -- >= 41
  
  	 AddMoney(role, 0, 3000)
  
  end

 

Thanks, I'll try to test it again.

Share this post


Link to post
Share on other sites
2 hours ago, V3ct0r said:

It is hard to say what is the problem. Perhaps your server files contains some modifications that led to the existance of such a bug.

I will try to test  Find the cause of the bug again. Thanks for the suggestion.

Share this post


Link to post
Share on other sites
On 11/20/2021 at 8:58 PM, V3ct0r said:

Hello @flamyman1412!

 

Add this script to file functions.lua:


-- Player killed monster event
GetExp_PKM__Original = GetExp_PKM
GetExp_PKM = function(monster, role)
	
	-- Call original function GetExp_PKM()
	GetExp_PKM__Original(monster, role)
	
	-- Get killed monster level
	local level = Lv(monster)
	
	-- Give money to player
	if (level < 21) then
		AddMoney(role, 0, 1000)
	else
		if (level < 41) then
			AddMoney(role, 0, 2000)
		end
	end
	
end

 

 

The code above has a bug. Fixed version:

-- Player killed monster event
GetExp_PKM__Original = GetExp_PKM
GetExp_PKM = function(monster, role)
	
	-- Call original function GetExp_PKM()
	GetExp_PKM__Original(monster, role)
	
	-- Get killed monster level
	local level = Lv(monster)
	
	-- Gold amount
	local money = 0
	
	
	-- Check the monster level
	if (level < 21) then
		money = 1000 -- 1,000 g
	elseif (level < 41) then
		money = 2000 -- 2,000 g
	end
	
	-- Add gold
	if (money > 0) then
		
		-- Give gold
		role = TurnToCha(role)
		local tmp = GetChaAttr(role, ATTR_GD)
		SetChaAttr(role, ATTR_GD, tmp + money)
		
		-- Show a message
		SystemNotice(
			role, 
			string.format(
				"You killed (%s) and got (%d) gold!", 
				GetChaDefaultName(monster), 
				money
			)
		)
	
	end
	
end

 


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...