• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Points for Guilds by Gesior edited by Scooty

Scooty

Enemia.EU
Joined
Jul 24, 2010
Messages
564
Reaction score
14
Location
Kraków
Hi, i have changed something in Gesior's script

Credits for:
Gesior - for script
Oskar - for #IPs function


take a look, im not very good scripter but it works :D

first in mysql:

PHP:
ALTER TABLE  `guilds` ADD  `gotpoints` INT NOT NULL DEFAULT  '0';


PHP:
local playersNeeded = 15
local ipsNeeded = 12
local minimumLevel = 150
local storageId = 47578
local playerGotPoints = 47579
local pointsForPlayer = 60
local pointsForLeader = 200
local exhaustionInSec = 60
 
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 doAddPoints(cid, points)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end
 
function onSay(cid, words, param, channel)
        if exhaustion.check(cid, 2000) == false then
                exhaustion.set(cid, 2000, exhaustionInSec)
local gotpoints = db.getResult("SELECT `gotpoints` FROM `guilds` WHERE `id` = " .. getPlayerGuildId(cid) .. ";"):getDataInt("gotpoints")
if gotpoints == 0 then
	if getCreatureStorage(cid, playerGotPoints) ~= 1 then
	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 _, v in ipairs(guildMembersValid) do 
local ip = getPlayerIp(v) 
if isInArray(IPs, ip) == false then 
table.insert(IPs, 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 `guilds` SET `gotpoints` = 1 WHERE `id` = " .. getPlayerGuildId(cid) .. ";")
				doAddPoints(cid, (pointsForLeader - pointsForPlayer))
				setPlayerStorageValue(cid, playerGotPoints, 1)
				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
else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your guild have already recived points.")
end
else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your guild have already recived points.")
end
	else
		doPlayerSendCancel(cid, "You can use this command only 1 time per 60 sec.")
		end
	return true
end


TESTED ON 0.4
 
Last edited:
@kowal2443
Please use english here <_<.

@topic
Thanks, i'll use it on my server ;)
 
Hmm help?

[20:8:51.527] [Error - TalkAction Interface]
[20:8:51.527] data/talkactions/scripts/guildpoints.lua:eek:nSay
[20:8:51.528] Description:
[20:8:51.528] data/lib/004-database.lua:60: [Result:getDataInt] Result not set!
[20:8:51.528] stack traceback:
[20:8:51.528] [C]: in function 'error'
[20:8:51.528] data/lib/004-database.lua:60: in function 'getDataInt'
[20:8:51.528] data/talkactions/scripts/guildpoints.lua:25: in function <data/talkactions/scripts/guildpoints.lua:22>
^C
 
Please post the functions

[20:8:51.527] [Error - TalkAction Interface]
[20:8:51.527] data/talkactions/scripts/guildpoints.luanSay
[20:8:51.528] Description:
[20:8:51.528] data/lib/004-database.lua:60: [Result:getDataInt] Result not set!
[20:8:51.528] stack traceback:
[20:8:51.528] [C]: in function 'error'
[20:8:51.528] data/lib/004-database.lua:60: in function 'getDataInt'
[20:8:51.528] data/talkactions/scripts/guildpoints.lua:25: in function <data/talkactions/scripts/guildpoints.lua:22>
 
PHP:
ALTER TABLE  `guilds` ADD  `gotpoints` INT NOT NULL DEFAULT  '0';

did you added this query?


*i tested it on tfs 0.4, dont know how it works on older tfs versions
 
[Error - TalkAction Interface]
[17:26:47.358] data/talkactions/scripts/pguild.lua:eek:nSay
[17:26:47.358] Description:
[17:26:47.358] data/lib/034-exhaustion.lua:28: bad argument #1 to 'time' (table expected, got number)
[17:26:47.358] stack traceback:
[17:26:47.358] [C]: in function 'time'
[17:26:47.358] data/lib/034-exhaustion.lua:28: in function 'set'
[17:26:47.358] data/talkactions/scripts/pguild.lua:24: in function <data/talkactions/scripts/pguild.lua:22>

You know what is wrong? Tfs 0.4
 
big example add reward (crystal coins at lvl 100 and 150)

(getPlayerGuildId(cid) == 4 >> change for guilds id

Lua:
	function onLogin()
	if getPlayerStorageValue(cid, 511928) ~= 1 and (getPlayerGuildId(cid) == 4 or getPlayerGuildId(cid) == 6 or getPlayerGuildId(cid) == 9 or getPlayerGuildId(cid) == 10 or getPlayerGuildId(cid) == 13 or getPlayerGuildId(cid) == 19) then
		if getPlayerLevel(cid) >= 150 then
			doPlayerAddItem(cid, 2160, 70)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have received 700,000 gps for being on a huge and powerfull guild and because your level is over 150.")		
		elseif getPlayerLevel(cid) >= 100 then
			doPlayerAddItem(cid, 2160, 35)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have received 350,000 gps for being on a huge and powerfull guild and because your level is over 100.")
		
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have not received nothing from being on a huge and powerfull guild becasue your level is lower than 100.")
		End
		setPlayerStorageValue(cid, 511928, 1)
	
	end
 
it's bugged..
[20:8:51.527] [Error - TalkAction Interface]
[20:8:51.527] data/talkactions/scripts/guildpoints.luanSay
[20:8:51.528] Description:
[20:8:51.528] data/lib/004-database.lua:60: [Result:getDataInt] Result not set!
[20:8:51.528] stack traceback:
[20:8:51.528] [C]: in function 'error'
[20:8:51.528] data/lib/004-database.lua:60: in function 'getDataInt'
[20:8:51.528] data/talkactions/scripts/guildpoints.lua:25: in function <data/talkactions/scripts/guildpoints.lua:22>
 
Fajny skrypt. Działa.
Ale mógłbyś napisać funkcje jaką dodać do Lib?
___________________________
Nice script. It works.
You can specify a function what you added to the Lib?
 
big example add reward (crystal coins at lvl 100 and 150)

(getPlayerGuildId(cid) == 4 >> change for guilds id

Lua:
    function onLogin()
    if getPlayerStorageValue(cid, 511928) ~= 1 and  (getPlayerGuildId(cid) == 4 or getPlayerGuildId(cid) == 6 or  getPlayerGuildId(cid) == 9 or getPlayerGuildId(cid) == 10 or  getPlayerGuildId(cid) == 13 or getPlayerGuildId(cid) == 19) then
        if getPlayerLevel(cid) >= 150 then
            doPlayerAddItem(cid, 2160, 70)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,  "You have received 700,000 gps for being on a huge and powerfull guild  and because your level is over 150.")        
        elseif getPlayerLevel(cid) >= 100 then
            doPlayerAddItem(cid, 2160, 35)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,  "You have received 350,000 gps for being on a huge and powerfull guild  and because your level is over 100.")
        
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,  "You have not received nothing from being on a huge and powerfull guild  becasue your level is lower than 100.")
        End
        setPlayerStorageValue(cid, 511928, 1)
    
    end

Why would you hard code guildIds for a login script? Generally that would be considered bad design practice, the servers internal function should be independent of the content of the database. This is on par with a talkaction checking for hard coded player names.
 

Similar threads

Back
Top