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

OnKill noob char, teleport him and no frag.

Status
Not open for further replies.

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Hi there, I have been thinking a lot on how about to solve noob chars in wars...

Protection system just sux, it doesnt work really well...

So I have an idea:

When you kill a player that has level X or less, he gets teleported to temple and also the killer doesn't get a frag.


Here is an idea for the part of the death for player:

Lua:
local nonDieDelay = 3*60 --- 3 minuts
function onPrepareDeath(cid, deathList)  -- Script by mock the bear
        if getWorldUpTime() <= nonDieDelay then
                doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
                doCreatureAddMana(cid,getCreatureMaxMana(cid))
                doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
                doRemoveCreature(cid)
                return false
        end
        return true
end

Thanks to Mock.

Anyone can help?
I rep++++!
 
Lua:
function onKill(cid, target, lastHit)

	if not isPlayer(target) or not isPlayer(cid) then return true end

	if getPlayerLevel(target) <= x then
		doTeleportThing(target, getTownTemplePosition(getPlayerTown(target)))
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		doCreatureAddMana(target, getCreatureMaxMana(target))
		return false
	end
	return true
end

Should work
 
It didn't, after killing a player level lower than 100 (changed x to 100) the console said this:

dibujomyc.png
 
Obviously not.. But I think you need to use onStatsChange instead of the onKill function..
if value >= getCreatureHealth(cid) then ~~~~
 
is this errors from the script he wrote lol?

Yes it is, because if I remove the script and kill someone, then idle.lua doesn't give errors, something is wrong there... I think that the target part is not good as well...

Obviously not.. But I think you need to use onStatsChange instead of the onKill function..
if value >= getCreatureHealth(cid) then ~~~~

Not obviusly, just try it and check by yourself.




@idle.lua

Lua:
local config = {
	idleWarning = getConfigValue('idleWarningTime'),
	idleKick = getConfigValue('idleKickTime')
}

function onThink(cid, interval)
	if(getTileInfo(getCreaturePosition(cid)).nologout or getCreatureNoMove(cid) or
		getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_ALLOWIDLE)) then
		return true
	end

	local idleTime = getPlayerIdleTime(cid) + interval
	doPlayerSetIdleTime(cid, idleTime)
	if(config.idleKick > 0 and idleTime > config.idleKick) then
		doRemoveCreature(cid)
	elseif(config.idleWarning > 0 and idleTime == config.idleWarning) then
		local message = "You have been idle for " .. math.ceil(config.idleWarning / 60000) .. " minutes"
		if(config.idleKick > 0) then
			message = message .. ", you will be disconnected in "
			local diff = math.ceil((config.idleWarning - config.idleKick) / 60000)
			if(diff > 1) then
				message = message .. diff .. " minutes"
			else
				message = message .. "one minute"
			end

			message = message .. " if you are still idle"
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, message .. ".")
	end

	return true
end
 
try this:
creaturevent : new lua
Lua:
local lvl = 10  -- noob lvl
local corpse_ids = {
        [0] = 3065, -- female
        [1] = 3058 -- male
}
function onStatsChange(cid, attacker, type, combat, value)
        if combat == COMBAT_HEALING then
                return true
        end
 
        if getCreatureHealth(cid) > value then
                return true
        end
 if getPlayerLevel(cid) <= lvl then

         doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[Noob caharcter killll]") 
         doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
        doSendMagicEffect(getCreaturePosition(cid), 10)
 
        doRemoveConditions(cid)
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You lost nothng as you are stilla  nub character")
        if isPlayer(attacker) then
                doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You didnt got exp as you killed a noob character.")
        end
end
               
        return false
end

goto creature event :
Code:
<event type="statschange" name="Arena" event="script" value="xxxx.lua"/>
and regestire in login.lua
 
@damadgerz
It doesn't add frag to the killer?

Try
Lua:
local lvl = 10 -- noob lvl
local corpse_ids = {
        [0] = 3065, -- female
        [1] = 3058 -- male
}
local function removeFrag(cid)
db.executeQuery("UPDATE `killers` SET `unjustified` = `unjustified` - 1 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
end
function onStatsChange(cid, attacker, type, combat, value)
        if combat == COMBAT_HEALING then
                return true
        end
 
        if getCreatureHealth(cid) > value then
                return true
        end
 if getPlayerLevel(cid) <= lvl then
 
         doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[Noob caharcter killll]") 
         doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
        doSendMagicEffect(getCreaturePosition(cid), 10)
		addEvent(removeFrag, 500)
 
        doRemoveConditions(cid)
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
 
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You lost nothng as you are stilla  nub character")
        if isPlayer(attacker) then
                doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You didnt got exp as you killed a noob character.")
        end
end
 
        return false
end
Change
db.executeQuery(XXX
to
db.Query(XXX
If it doesn't work.
 
creaturescripts.xml add
Code:
<event type="kill" name="Noobkill" script="noobkill.lua"/>
login.lua add
Code:
	registerCreatureEvent(cid, "Noobkill")
noobkill.lua
Lua:
local function removeFrag(cid)
db.executeQuery("UPDATE `killers` SET `unjustified` = `unjustified` - 1 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = " .. getPlayerGUID(cid) .. ")")
end
local town = getTownTemplePosition(getPlayerTown(cid))
function onKill(cid, target, lastHit)
if isPlayer(cid) == true and isPlayer(target) == true then
  if getPlayerLevel(target) >= 100 then
        doTeleportThing(cid,town)
        doSendMagicEffect(getCreaturePosition(cid), 10)
		addEvent(removeFrag, 500)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_YELLOW)
		doCreatureSay(cid, "You have killed a noob character!", TALKTYPE_ORANGE_1)
  end
end
return true
end
Rep++
 
Status
Not open for further replies.
Back
Top