• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Request: All monster damage 70% less! Rep!

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,780
Solutions
31
Reaction score
2,299
Location
Sweden?
I need a script that all monster damage on player 70% with magic and melee damage.

Rep!
 
Lol this script is so simple it would be worth 2 cents:P
LUA:
local reduction = 70 --this means that the damage is reduced by 70%
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target)
return false,doCreatureAddHealth(target,-value*(1-(reduction/100))), doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!")
end
return true
end
something like this should do the trick
It might even be as simple as this:
LUA:
local reduction = 70 --70% reduction
function onStatsChange(target, attacker, type, combat, value)
value = value * (1-(reduction/100))
return true
but I'm not really sure if this works correctly.
Also the message that you get now when you take damage from creatures (using the first script) is probably a little different just change the line how you see fit.
 
Bro i get this error :(

Code:
[14/02/2012 16:03:11] [Error - CreatureScript Interface] 
[14/02/2012 16:03:11] data/creaturescripts/scripts/ld.lua:onStatsChange
[14/02/2012 16:03:11] Description: 
[14/02/2012 16:03:11] (luaDoPlayerSendTextMessage) Player not found
 
Last edited:
replace
doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!")

with
doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!")
 
Zyntax i think this script need rewrite i get this error now:
Code:
[14/02/2012 16:18:28] [Error - LuaScriptInterface::loadFile] data/creaturescripts/scripts/ld.lua:4: ')' expected near 'LT'
[14/02/2012 16:18:28] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/ld.lua)
[14/02/2012 16:18:28] data/creaturescripts/scripts/ld.lua:4: ')' expected near 'LT'
 
... take a look at what you copied (with my fail ofcourse)

doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAU_LT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!")

DEFAU"space"LT
O'course it can't load....

remove the space (marked red ^)
 
Try this:
LUA:
local reduction = 70 --this means that the damage is reduced by 70%
local storage = 815870 --the storage value used
function onStatsChange(target, attacker, type, combat, value)
if isCreature(attacker) and isPlayer(target) and (type == 1 or type == 3) then
	if getPlayerStorageValue(target,storage) ~= 1 then
		return false,doCreatureAddHealth(target,-value*(1-(reduction/100))), doPlayerSendTextMessage(target,MESSAGE_EVENT_DEFAULT, getCreatureName(attacker).. " dealt " ..value*(1-(reduction/100)).. " damage to you!"),setPlayerStorageValue(target,storage,1)
	else
		setPlayerStorageValue(target,storage,0)
	end
end
return true
end
I think it was crashing because addHealth also triggers this function.
 
You must register a event to creature (or player). Example with items:
LUA:
function onUse(cid, ...)
	registerCreatureEvent(cid, "event_name")
	return true
end
 

Similar threads

Replies
0
Views
276
Back
Top