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

TalkAction Premium Points for big guilds [~automatic]

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,966
Solutions
99
Reaction score
3,383
Location
Poland
GitHub
gesior
My friend requested this script.
BETA
NOT TESTED, REPORT BUGS
Guild leader [not only owner] can say command (add in talkactions.xml) and script check if in his guild is enought players [online] with required level that never received premium points (block possiblity to make new guilds and request new points). It also requires different IPs [not all members, but block MC noobs].
Default config requires 10 players online with minimum 150 lvl and they all together must have 6 or more different IPs, each of them will receive 100 points. If to guild join another 10 players and get 150 lvl they can get get their points too [if leader use command].
If you configure good level for your OTS, it will be not easy to abuse script.
Lua:
local playersNeeded = 10
local ipsNeeded = 6
local minimumLevel = 150
local storageId = 47578
local pointsForPlayer = 100

local function sendPlayersList(cid, list)
	for i, pid in ipairs(list) do
		local level = getPlayerLevel(pid) < minimumLevel and " - " .. getPlayerLevel(cid) .. " level " or ""
		local valid = getCreatureStorage(pid, storageId) > 1 and " - already received!" or ""
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(pid) .. level)
	end
end

function onSay(cid, words, param, channel)
	if(getPlayerGuildLevel(cid) == 3) then
		local leaderGuild = getPlayerGuildId(cid)
		local players = getPlayersOnline()
		local guildMembersValid = {}
		local guildMembersInvalid = {}
		for i, pid in ipairs(players) do
			if(leaderGuild == getPlayerGuildId(pid)) then
				if(getPlayerLevel(pid) >= minimumLevel and tonumber(getCreatureStorage(pid, storageId)) < 2) then
					table.insert(guildMembersValid, pid)
				else
					table.insert(guildMembersInvalid, pid)
				end
			end
		end

		if(#guildMembersValid >= playersNeeded) then
			local IPs = {}
			for i, pid in ipairs(guildMembersValid) do
				local ip = getPlayerIp(pid)
				if(IPs[ip] == nil) then
					IPs[ip] = ip
				end
			end
			if(#IPs >= ipsNeeded) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players that received points:")
				sendPlayersList(cid, guildMembersValid)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players that did not receive points:")
				sendPlayersList(cid, guildMembersInvalid)
				local accounts = {}
				for i, pid in ipairs(guildMembersValid) do
					table.insert(accounts, getPlayerAccountId(pid))
					doCreatureSetStorage(pid, storageId, os.time())
				end
				db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points`+" .. pointsForPlayer .. " WHERE `id` IN (" .. table.concat(accounts, ',') .. ");")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, #guildMembersValid .. " players from your guild are valid (" .. playersNeeded .. " required), but you have together only " .. #IPs .. " IPs (" .. ipsNeeded .. " required)")
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Valid players:")
				sendPlayersList(cid, guildMembersValid)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Invalid players:")
				sendPlayersList(cid, guildMembersInvalid)
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, #guildMembersValid .. " players from your guild are valid, " .. playersNeeded .. " required. Minimum level required is " .. minimumLevel)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Valid players:")
			sendPlayersList(cid, guildMembersValid)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Invalid players:")
			sendPlayersList(cid, guildMembersInvalid)
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Only guild leader can request points.")
	end
	return true
end
 
Hey, i've a problem. I changed to:

local playersNeeded = 10
local ipsNeeded = 5
local minimumLevel = 1300
local storageId = 47578
local pointsForPlayer = 10

and I wanted to use this command by guild leader. Text which showed to me:

11:07 6 players from your guild are valid, 10 required. Minimum level required is 1300
11:07 Valid players:
11:07 Pro Bluzgam
11:07 Kwazi Wariat
11:07 Mistyczny Zjadacz Parowek
11:07 Raqqen
11:07 Don Kwazi
11:07 Bokol
11:07 Invalid players:

All players have 1300+ level, you can look here.
I'll add I've TFS 0.3.6
What's wrong? Thanks for reply.
 
Create a new guild and they will still have free points??
 
Hey, i've a problem. I changed to:



and I wanted to use this command by guild leader. Text which showed to me:



All players have 1300+ level, you can look here.
I'll add I've TFS 0.3.6
What's wrong? Thanks for reply.

It checks online people I believe (reading description) so all 10 have to be online to get it.
 
I have a problem when I set a limit ip for 7, after entering a command !points shows that 0 is different ip addresses.

"4:41 10 players from your guild are valid (10 required), but you have together only 0 IPs (7 required) "
 
try changing this:

Lua:
local ip = getPlayerIp(pid)

to

Lua:
local ip = getPlayerIp(cid)

not tested but it's the only thought which comes on my mind
 
Back
Top