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

CreatureEvent [AntiCheat] For Pvp-Enforced Servers

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
This script is a request of GarQet, here -> http://otland.net/f132/script-server-hardcore-pvp-60276/

First, execute this in phpMyAdmin:
PHP:
alter table players add lastKill int(11) not null default 0;
alter table players add lastKillTime int(11) not null default 0;

Now, go to /data/creaturescripts/scripts, create a file named anticheat.lua and paste this:
Lua:
function onKill(cid, target, lastHit)

local timeWithinKill = 300 --in seconds
local killsLimit = 3 --limit to die
local lastKill, lastKillTime = nil, nil
local storage = 65535 --storage to check if player has killed another player 'killsLimit' times

	if(isPlayer(target) == false) or (isMonster(cid) == true) then
		return true
	end

	query = db.getResult("select lastKill, lastKillTime from players where id = " .. getPlayerGUID(cid) .. ";")
	if(query:getID() ~= -1) then
		lastKill, lastKillTime = query:getDataInt("lastKill"), query:getDataInt("lastKillTime")
		if(lastKill == getPlayerGUID(target)) then
			if(os.clock() - lastKillTime) < timeWithinKill then
				if(getPlayerStorageValue(cid, storage) < 0) then
					doPlayerSetStorageValue(cid, storage, 0)
				end
				doPlayerSetStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
				if(getPlayerStorageValue(cid, storage) >= killsLimit) then
					doCreatureAddHealth(cid, -getCreatureHealth(cid))
				end
			else
				doPlayerSetStorageValue(cid, storage, 0)
			end
		end
		db.executeQuery("update players set lastKill = " .. getPlayerGUID(target) .. ", lastKillTime = " .. os.clock() .. " where id = " .. getPlayerGUID(cid) .. ";")
	else
		return LUA_ERROR
	end
	return true
end

Paste this in login.lua:
Lua:
registerCreatureEvent(cid, "AntiCheat")

Paste this in creaturescripts.xml:
PHP:
	<event type="kill" name="AntiCheat" event="script" value="anticheat.lua"/>

How this works?
If the player kill another player 'killsLimit' times or (3) times before 'timeWithinKill' minutes or (5) minutes, the killer dies.
 
Last edited:
either sql or storages, it's the same purpose
ofc sql queries are lag-er
 
me and colandus did this earlier, but we edited source so we could deny exp instead of killing them :p nice script btw
 
This is kinda retarded, because what happend was that people on my server used fire bombs, then same player went out and died 3 times on the fire and the one who made firebomb, died.
 
This is kinda retarded, because what happend was that people on my server used fire bombs, then same player went out and died 3 times on the fire and the one who made firebomb, died.

I was just going to say that. The player should stop gaining experience from that player..
 
Good idea and I think it should be implemented into 0.4.
 
This is kinda retarded, because what happend was that people on my server used fire bombs, then same player went out and died 3 times on the fire and the one who made firebomb, died.
 
This is kinda retarded, because what happend was that people on my server used fire bombs, then same player went out and died 3 times on the fire and the one who made firebomb, died.

Just make so they dont gain the experience?

Edit my version:
Lua:
  function onKill(cid, target, lastHit)

local timeWithinKill = 1800 --in seconds
local killsLimit = 3 --limit to die
local lastKill, lastKillTime = nil, nil
local storage = 65535 --storage to check if player has killed another player 'killsLimit' times
local teleport = { x = 100, y = 100, z = 7 }

        if(isPlayer(target) == false) or (isMonster(cid) == true) then
                return true
        end

        query = db.getResult("select lastKill, lastKillTime from players where id = " .. getPlayerGUID(cid) .. ";")
        if(query:getID() ~= -1) then
                lastKill, lastKillTime = query:getDataInt("lastKill"), query:getDataInt("lastKillTime")
                if(lastKill == getPlayerGUID(target)) then
                        if(os.clock() - lastKillTime) < timeWithinKill then
                                if(getPlayerStorageValue(cid, storage) < 0) then
                                        doPlayerSetStorageValue(cid, storage, 0)
                                end
                                doPlayerSetStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
                                if(getPlayerStorageValue(cid, storage) >= killsLimit) then
                                        doCreatureAddHealth(cid, getCreatureHealth(cid))
										doTeleportThing(cid, teleport)
										doPlayerSendTextMessage(cid, 19, "You have been teleported to temple because of getting killed by the same player more than 3 times (Anti Cheat).")
                                end
                        else
                                doPlayerSetStorageValue(cid, storage, 0)
                        end
                end
                db.executeQuery("update players set lastKill = " .. getPlayerGUID(target) .. ", lastKillTime = " .. os.clock() .. " where id = " .. getPlayerGUID(cid) .. ";")
        else
                return LUA_ERROR
        end
        return false
end
Teleports to temple, and gives warning.
"Edit
Just tested the script, it isn't working.
 
Last edited:
i use sqlite,
and i cant execute this:
alter table players add lastKill int(11) not null default 0;
alter table players add lastKillTime int(11) not null default 0;
please help me to execute or create one by storage..
fast :///
 
This is kinda retarded, because what happend was that people on my server used fire bombs, then same player went out and died 3 times on the fire and the one who made firebomb, died.

Dude as I said before...u r the "retarded" guy that steal ppl's work all the time...so stop saying that ppl's work is retarded if u can't even do half of it...and something else as u r the "man" that tracked full rl tibia with scripts and stuff and u can't do a simple script like this....shame (lier)
Best regards,
Joseph :thumbup:
 
Last edited:
i dont know where to add this on sqlitestudio:
alter table players add lastKill int(11) not null default 0;
alter table players add lastKillTime int(11) not null default 0;
 
Just make so they dont gain the experience?

Edit my version:
Lua:
  function onKill(cid, target, lastHit)

local timeWithinKill = 1800 --in seconds
local killsLimit = 3 --limit to die
local lastKill, lastKillTime = nil, nil
local storage = 65535 --storage to check if player has killed another player 'killsLimit' times
local teleport = { x = 100, y = 100, z = 7 }

        if(isPlayer(target) == false) or (isMonster(cid) == true) then
                return true
        end

        query = db.getResult("select lastKill, lastKillTime from players where id = " .. getPlayerGUID(cid) .. ";")
        if(query:getID() ~= -1) then
                lastKill, lastKillTime = query:getDataInt("lastKill"), query:getDataInt("lastKillTime")
                if(lastKill == getPlayerGUID(target)) then
                        if(os.clock() - lastKillTime) < timeWithinKill then
                                if(getPlayerStorageValue(cid, storage) < 0) then
                                        doPlayerSetStorageValue(cid, storage, 0)
                                end
                                doPlayerSetStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
                                if(getPlayerStorageValue(cid, storage) >= killsLimit) then
                                        doCreatureAddHealth(cid, getCreatureHealth(cid))
										doTeleportThing(cid, teleport)
										doPlayerSendTextMessage(cid, 19, "You have been teleported to temple because of getting killed by the same player more than 3 times (Anti Cheat).")
                                end
                        else
                                doPlayerSetStorageValue(cid, storage, 0)
                        end
                end
                db.executeQuery("update players set lastKill = " .. getPlayerGUID(target) .. ", lastKillTime = " .. os.clock() .. " where id = " .. getPlayerGUID(cid) .. ";")
        else
                return LUA_ERROR
        end
        return false
end
Teleports to temple, and gives warning.
"Edit
Just tested the script, it isn't working.

It's working but not perfect.. All time i get tp to temple and killed player don't die. Your script its good idea but don;t working perfect ;p
 
Back
Top