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

Enforced Scripts. [ LUA ] OR [ C++]

DukeeH

Active Member
Joined
Dec 6, 2010
Messages
550
Solutions
3
Reaction score
39
Hello OTlanders.
Im here to request 3 Scripts ;x

[TFS 0.4 Trunk 3884] [8.6]

First.
Code:
 The Most Fragger Player Online Gots A Skull And If Somewone Get's more frags. The Skull Disappear From First Player And Goes To New Player

Second.
Code:
 As The First. But Broadcast The Top Fragger Like:
"PlayerName Is The Most Fragger, Let's Kill Him!"

X. Third. a little hard. { DONE. Link. }
Code:
 I Want a working 'No exp from same ip', in c++ prefered, cuz lua i think lags.
The one on c++ resources isn't working and the owner don't answer..

Help with u can.
I Will Be Thankful!
Thanks!
 
Last edited:
ANTI MC EXP
In player.cpp find:
PHP:
double Player::getGainedExperience(Creature* attacker) const
{
	if(!skillLoss)
		return 0;

	double rate = g_config.getDouble(ConfigManager::RATE_PVP_EXPERIENCE);
	if(rate <= 0)
		return 0;

	Player* attackerPlayer = attacker->getPlayer();
	if(!attackerPlayer || attackerPlayer == this)
		return 0;
and under paste:
PHP:
if(getIP() == 0 || attackerPlayer->getIP() == 0 || getIP() == attackerPlayer->getIP())
return 0;

I won't paste first and second scripts, because I make my own war server and don't want other too good servers :rolleyes:
I pasted anti mc, because I'll use much better scripted in C++ + LUA to block 'frag-giving' :P
 
haha, thanks man.
and i hope u have a nice server.
mine is just a 'home server' for max 50 ppl.
:)
anyway. thanks :D
 
¹trying to recompile.
-
²SORRY FOR DOUBLE. I've problems with edit. I'll Learn, I Promise.
-
³When finishes to compile i tell if works :D


==
Finished, Works Fine.
Waiting for Second and Third.
==
 
Last edited:
1 & 2 scripts

Add globalevent:
PHP:
<globalevent name="skullCheck" interval="3" event="script" value="skullCheck.lua"/>
It refresh skulls and show top players [if top changed] every interval.
skullCheck.lua
PHP:
local bu, bf, ru, rf, wu, wf = 10, 11, 20, 21, 30, 31 -- global storage values used to store skulls
local frags_storage = 15000 -- storage id where frags are stored

function onThink(interval, lastExecution, thinkInterval)
	local players = getPlayersOnline()
	local black_uid, black_frags = getStorage(bu), getStorage(bf)
	local red_uid, red_frags = getStorage(ru), getStorage(rf)
	local white_uid, white_frags = getStorage(wu), getStorage(wf)
	for i, uid in pairs(players) do
		local uid_frags = getCreatureStorage(uid, frags_storage)
		if(uid_frags > 0) then
			if(uid_frags > black_frags) then
				white_frags = red_frags
				white_uid = red_uid
				red_frags = black_frags
				red_uid = black_uid
				black_frags = uid_frags
				black_uid = uid
			elseif(uid_frags > red_frags) then
				white_frags = red_frags
				white_uid = red_uid
				red_frags = uid_frags
				red_uid = uid
			elseif(uid_frags > white_frags) then
				white_frags = uid_frags
				white_uid = uid
			end
		end
		doCreatureSetSkullType(cid, SKULL_NONE)
	end
	if(white_uid > 0) then
		doCreatureSetSkullType(white_uid, SKULL_WHITE)
	end
	if(red_uid > 0) then
		doCreatureSetSkullType(red_uid, SKULL_RED)
	end
	if(black_uid > 0) then
		doCreatureSetSkullType(black_uid, SKULL_BLACK)
	end
	if(white_uid ~= getStorage(wu) or red_uid ~= getStorage(ru) or black_uid ~= getStorage(bu)) then
		--doBroadcastMessage("Top 3 of server:\n1. ".. getCreatureName(black_uid) .." - ".. black_frags .." frags\n2. ".. getCreatureName(red_uid) .." - ".. red_frags .." frags\n3. ".. getCreatureName(white_uid) .." - ".. white_frags .." frags")
	end
	doSetStorage(wf, white_frags)
	doSetStorage(wu, white_uid)
	doSetStorage(rf, red_frags)
	doSetStorage(ru, red_uid)
	doSetStorage(bf, black_frags)
	doSetStorage(bu, black_uid)
	return true
end
Add new creature scripts event to count frags.
creaturescripts.xml
PHP:
	<event type="login" name="fragCounterLogin" event="script" value="fragCounter.lua"/>
	<event type="kill" name="fragCounterKill" event="script" value="fragCounter.lua"/>
fragCounter.lua
PHP:
local frags_storage = 15000 -- storage id where frags are stored

function onLogin(cid)
	doCreatureSetStorage(cid, frags_storage, 0)
	registerCreatureEvent(cid, "fragCounterKill")
	return true
end

function onKill(cid, target, lastHit)
	if(isPlayer(target) and lastHit) then
		doCreatureSetStorage(cid, frags_storage, getCreatureStorage(cid, frags_storage) + 1)
	end
	return true
end
NOT TESTED
 
Last edited:
my attempt, incomplete
LUA:
local SKULL = SKULL_RED

function getMostFragger()
    result = db.getResult('SELECT `p`.`id` AS `id`, COUNT(`p`.`id`) as `frags` FROM `killers` k LEFT JOIN `player_killers` pk ON `k`.`id` = `pk`.`kill_id` LEFT JOIN `players` p ON `pk`.`player_id` = `p`.`id` WHERE `k`.`unjustified` = 1 AND `k`.`final_hit` = 1 GROUP BY `id` ORDER BY `frags` DESC, `id` ASC LIMIT 1;')
    data = result:getDataInt('id')
    result:free()
    return data
end

function onLogin(cid)
    if getMostFragger() == getPlayerGUID(cid) then
        doCreatureSetSkullType(cid, SKULL)
    else
        doCreatureSetSkullType(cid, SKULL_NONE)
    end
    return true
end

function onKill(cid, target, damage, flags)
    if isPlayer(target) and getMostFragger() == getPlayerGUID(cid) then
        local pid = getPlayersOnline()
        for i = 1, #pid do
            if getCreatureSkullType(pid[i]) == SKULL then
                doCreatureSetSkullType(pid[i], SKULL_NONE)
            end
        end
        doCreatureSetSkullType(cid, SKULL)
    end
    return true
end
 
Nice code CyberM, but I talk with him at MSN and he want stats for ots with 1/1 login and no characters save (reset frags after relog/death).

FIXED my code again, disabled broadcast top fraggers. I'll fix it tommorow.
 
LUA:
local bu, bf, ru, rf, wu, wf = 10, 11, 20, 21, 30, 31 -- global storage values used to store skulls
local frags_storage = 15000 -- storage id where frags are stored

function onThink(interval, lastExecution, thinkInterval)
    local players = getPlayersOnline()
    local black_uid, black_frags = getStorage(bu), getStorage(bf)
    local red_uid, red_frags = getStorage(ru), getStorage(rf)
    local white_uid, white_frags = getStorage(wu), getStorage(wf)
    for i, uid in pairs(players) do
        local uid_frags = getCreatureStorage(uid, frags_storage)
        if(uid_frags > 0) then
            if(uid_frags > black_frags) then
                white_frags = red_frags
                white_uid = red_uid
                red_frags = black_frags
                red_uid = black_uid
                black_frags = uid_frags
                black_uid = uid
            elseif(uid_frags > red_frags) then
                white_frags = red_frags
                white_uid = red_uid
                red_frags = uid_frags
                red_uid = uid
            elseif(uid_frags > white_frags) then
                white_frags = uid_frags
                white_uid = uid
            end
        end
        doCreatureSetSkullType(cid, SKULL_NONE)
    end
    if(white_uid > 0) then
        doCreatureSetSkullType(white_uid, SKULL_WHITE)
    end
    if(red_uid > 0) then
        doCreatureSetSkullType(red_uid, SKULL_RED)
    end
    if(black_uid > 0) then
        doCreatureSetSkullType(black_uid, SKULL_BLACK)
    end
    if(white_uid ~= getStorage(wu) or red_uid ~= getStorage(ru) or black_uid ~= getStorage(bu)) then
        --doBroadcastMessage("Top 3 of server:\n1. ".. getCreatureName(black_uid) .." - ".. black_frags .." frags\n2. ".. getCreatureName(red_uid) .." - ".. red_frags .." frags\n3. ".. getCreatureName(white_uid) .." - ".. white_frags .." frags")
    end
    doSetStorage(wf, white_frags)
    doSetStorage(wu, white_uid)
    doSetStorage(rf, red_frags)
    doSetStorage(ru, red_uid)
    doSetStorage(bf, black_frags)
    doSetStorage(bu, black_uid)
    return true
end
By : Phowned;

Somewone can fix?
It Doesn't add the skull, And Fix the broadcast Part.

And, Error.
Screen:
semttuloekq.jpg
 
change:
LUA:
doCreatureSetSkullType(cid, SKULL_NONE)
to:
LUA:
doCreatureSetSkullType(uid, SKULL_NONE)



kind regards, Evil Hero.
 
Nice, No More errors, BUT...
The skull doesn't appears.
- How do you know that is working?
Cuz the top frags can't spell area.

I already know to fix the blackskull things..
but the skull doesn't appears, just the effect of black.
 
Last edited:
try this instead...

LUA:
local top_kills = 2000 
local top_killers_guid = 2001
local store_kills = 2002
function addKill(cid)
	if getPlayerStorageValue(cid, store_kills) == -1 then
		setPlayerStorageValue(cid, store_kills, 0)
	end
	return setPlayerStorageValue(cid, store_kills, getPlayerStorageValue(cid, store_kills) + 1)
end

function getTopKiller()
	return getPlayerByGUID(getGlobalStorageValue(top_killers_guid))
end
	
function onKill(cid, target, damage, flags)
	if isPlayer(cid) and isPlayer(target) then
		addKill(cid)
		if getGlobalStorageValue(top_kills) < getPlayerStorageValue(cid, store_kills) then
			if getPlayerGUID(cid) ~= getTopKiller() then
				doCreatureSetSkullType(getTopKiller(), SKULL_NONE)
				setGlobalStorageValue(top_kills, getPlayerStorageValue(cid, store_kills))
				setGlobalStorageValue(top_killers_guid, getPlayerGUID(cid))
				doCreatureSetSkullType(cid, SKULL_RED)
				doBroadcastMessage(getCreatureName(cid) .." is the Top Killer, let's kill him!", TALKTYPE_BROADCAST)
			else
				setGlobalStorageValue(top_kills, getPlayerStorageValue(cid, store_kills))
			end
		end
	end
	return true
end


I've didn't tested it but it should be working.



kind regards, Evil Hero.
 
Last edited:
not working, i registered like this:
XML:
	<event type="kill" name="Skull" event="script" value="SKULL.lua"/>

Login.lua
LUA:
	registerCreatureEvent(cid, "Skull")

Any errors, any skulls :/
 
Back
Top