• 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!

Frag punishment script

Michael Orsino

Premium User
Staff member
Premium User
Support Team
Joined
Nov 15, 2007
Messages
864
Solutions
10
Reaction score
452
Location
Western Australia
Hey there,
Seeking some help with a script I am trying to write

Basically the script is meant to..

if the victim did NOT attack first then -- no idea how to deal with this, currently doing it badly I am sure of it.
if the victim was a 'noob' then
remove a bunch of exp dictated by a rather large formula

Anyway, it doesn't work. I hope that someone will be able to help

Thanks,
Michael

Code:
local expCalc = ((getPlayerLevel(cid) - getPlayerLevel(target)) / 100) -1) * getExperienceForLevel(getPlayerLevel(target))

function onKill(cid, target, lastHit)
if(isPlayer(cid) and isPlayer(target))  then
if getCreatureSkullType(target) ~= 1 or isPlayerPzLocked(target) == FALSE then
if (getPlayerLevel(cid)/getPlayerLevel(target)) <= 0.5 then
doPlayerAddExperience(cid, -(expCalc))
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You just fragged a noob! You lose " .. expCalc .. "exp. Don't power abuse!")
end
return TRUE
end
end
 
Not tested.

Code:
function onKill(cid, target)
        local loss = (getPlayerLevel(cid) - getPlayerLevel(target) / 100) * (getExperienceForLevel(getPlayerLevel(target)))
	if isPlayer(cid) and isPlayer(target) then
		if getCreatureSkullType(target) == SKULL_NONE or isPlayerPzLocked(target) == false then
			if (getPlayerLevel(cid) / getPlayerLevel(target)) >= 0.5 then
				doPlayerAddExperience(cid, - loss)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been punished for killing a newb.")
			end
			return true
		end
	end
end
 
Thanks a lot JDB, although your script did not work it did help me to fix the issues.
Finished product below, should work fine.
Code:
function onKill(cid, target, lastHit)
        local loss = (((getPlayerLevel(cid) - getPlayerLevel(target)) / 100)-1) * (getExperienceForLevel(getPlayerLevel(target)))
	if(isPlayer(cid) and isPlayer(target)) then
		if getCreatureSkullType(target) == SKULL_NONE or isPlayerPzLocked(target) == false then
			if (getPlayerLevel(target) / getPlayerLevel(cid)) < 0.5 then
				doPlayerAddExperience(cid, -loss)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been punished for killing a noob.")
			end
			return true
		end
	end
end
Edit: Heh, if a low level kills a higher level, the higher level doesnt die. Interesting.
Not sure what the issue is yet
 
Back
Top