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

Powerfull Guilds at Latest News (Must edit in config.php)

Andrespro

New Member
Joined
Mar 18, 2009
Messages
125
Reaction score
4
Location
Santa Cruz - Bolivia
2db2v0i.jpg


Recommend all of you to update to this brand new system

Added & Fixed:
- All code rewrite
- Now code reads all guilds
- New Vote Guild System!
- Points System
- 2 modes:
- - AccountMode = Vote registers on Account so 1 Account can vote each day
- - PlayerMode (Or AccountMode = FALSE) = Vote registers on Player so if you have more than 1 player on your account all account's players can vote once per day
- GlobalEvents to delete register
- TalkActions to vote for a guild
- SQL Queries to web

SQL part

Execute this queries:

Lua:
ALTER TABLE `guilds` ADD `points` INT NOT NULL DEFAULT '0'

Lua:
CREATE TABLE IF NOT EXISTS `z_guild_votes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `account_id` int(11) NOT NULL,
  `voted` int(11) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

Config.LUA part

Open your config.lua file and write:

Lua:
-- Guild Vote System
	-- Here you can see how to Vote a Guild
	-- You can enable Account Mode
	-- True - Will accept 1 vote per account each day
	-- False - Will accept 1 vote per player each day
	-- VoteStorage - StorageValue used to check if voted or not
	-- VoteStorage ONLY SUPPORTS AccountMode on FALSE MODE
	AccountMode = true
	VoteStorage = 123456

Explanation:

- AccountMode = Verfies if AccountMode is active or not (if not, will be PlayerMode)

- VoteStorage = Only works with PlayerMode!. PlayerMode is enabled with storage value, so the VoteStorage value will be the Storage Value used to vote on this PlayerMode

TalkAction Part

Open your talkactions.xml file and write:

Lua:
<!-- Guild Vote System -->
	<talkaction words="/vote-guild" event="script" value="voteguild.lua"/>

Now create a new file on scripts/ folder, name it voteguild.lua and write:

Lua:
-- Guild Vote System
-- By AndresPro
-- [url]Http://ots-help.0fees.net[/url]

function onSay(cid, words, param, channel)
-- Config
local AccountMode = getConfigValue('AccountMode')
local VoteStorage = getConfigValue('VoteStorage')
local guild = db.getResult("SELECT * FROM `guilds` WHERE `name` = " .. db.escapeString(param) .. ";")

if guild:getID() == -1 then
-- Guild doesn't exists
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Guild ".. param .." doesn't exists.")
	return true
	end
	
-- Guild does exists

if AccountMode == true then
-- AccountMode
local voted = db.getResult("SELECT * FROM `z_guild_votes` WHERE `account_id` = " .. getPlayerAccountId(cid) .. ";")

if voted:getID() ~= -1 then

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You already voted for ".. param .." today. Please wait for a day to vote again.")

else

db.executeQuery("UPDATE `guilds` SET `points`=".. guild:getDataInt("points") + 1 .." WHERE name = " .. db.escapeString(param) .. ";")
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Thank you for voting to ".. param ..". Now ".. param .." has ".. guild:getDataInt("points") + 1 .." points.")
db.executeQuery("INSERT INTO `z_guild_votes` (`id` ,`account_id` ,`voted`) VALUES (NULL , " .. getPlayerAccountId(cid) .. " , '1');")

return true
end

voted:free()
elseif AccountMode == false then
-- PlayerMode
if getPlayerStorageValue(cid, VoteStorage) ~= 1 then

db.executeQuery("UPDATE `guilds` SET `points`=".. guild:getDataInt("points") + 1 .." WHERE name = " .. db.escapeString(param) .. ";")
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Thank you for voting to ".. param ..". Now ".. param .." has ".. guild:getDataInt("points") + 1 .." points.")
doPlayerSetStorageValue(cid, VoteStorage, 1)

else

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You already voted for ".. param .." today. Please wait for a day to vote again.")

return true
end
end
guild:free()
	return true
end

GlobalEvent part

Open globalevents.xml and write:

Lua:
<globalevent name="votesclean" interval="86400" event="script" value="voteguild.lua"/>

Go to scripts/ folder and create a new file, name it voteguild.lua and write:

Lua:
-- Guild Vote System
-- By AndresPro
-- [url]Http://ots-help.0fees.net[/url]

function onThink(interval, lastExecution)
-- Config
local AccountMode = getConfigValue('AccountMode')
local VoteStorage = getConfigValue('VoteStorage')

if AccountMode == true then
-- AccountMode

db.executeQuery("TRUNCATE TABLE `z_guild_votes`;")

elseif AccountMode == false then
-- PlayerMode

	for _, name in ipairs(getOnlinePlayers()) do
		local player = getPlayerByName(name)
		if getPlayerStorageValue(player,VoteStorage) >= 1 then
			setPlayerStorageValue(player,VoteStorage,0)
end
end
end
doBroadcastMessage("Everyone can vote again now.")
return true
end

PHP Part


Open latestnews.php on htdocs/ folder and before:
PHP:
foreach($news_DB as $news) {

Write:

PHP:
// Powerfull Guilds at Latest News
// By AndresPro
// OTS-Help.0fees.net
$main_content .= '<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><div class=\'NewsHeadline\'>
     <div class=\'NewsHeadlineBackground\' style=\'background-image:url('.$layout_name.'/images/news/newsheadline_background.gif)\'>
     <table width="100%" border="0">
      <tr><td>
    <strong><center><font color="#ffffff">Most voted guilds in '.$GLOBALS['config']['server']["serverName"].'</font></center></strong></td>
    </tr></table></div></div></td>
  </tr>
  <tr>
    <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>';

$guildsa = $SQL->query("SELECT * FROM `guilds` ORDER BY `points` DESC LIMIT 4");
foreach($guildsa as $guilds)
{
$owner = $guilds['ownerid'];
$logo = $guilds['logo_gfx_name'];
if ($guilds['logo_gfx_name'] == ""){
$logo = "default_logo.gif";
}
$main_content .= '<td>
        <table width="100%" border="0" cellspacing="7" cellpadding="0">
      <tr>
        <td><div align="center"><img src="guilds/'.$logo.'" height="64" width="64"></div></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><div align="center"><strong><font size="1">Points:</font></strong></div></td>
            <td><div align="center"><font size="1">'.$guilds['points'].'</font></div></td>
          </tr>
          <tr>
            <td><div align="center"><strong><font size="1">Name:</font></strong></div></td>
            <td><div align="center"><a href="?subtopic=guilds&action=show&guild='.$guilds['id'].'"><font size="1">'.$guilds['name'].'</font></a></div></td>
          </tr>
          <tr>
            <td><div align="center"><strong><font size="1">Boss:</font></strong></div></td>';
                $query2 = $SQL->query("SELECT * FROM `players` WHERE `id` = $owner LIMIT 0 , 30");
$n2 = $query2->fetch();
               $main_content .= ' <td><div align="center"><a href="?subtopic=characters&name='.$n2['name'].'"><font size="1">'.$n2['name'].'</font></a></div></td>
              </tr>
        </table></td>
      </tr>
    </table></td>';
}

$main_content .= '</tr></table></td>
  </tr>
   
      <tr>
      <td align="right"><b><font size=1>Coded By <a target="_blank" href="http://ots-help.0fees.net">AndresPro</a></font></b></td>
  </tr>
</table>';
 
Last edited by a moderator:
hm so I have to choose the 4 best guilds manually instead of doing it automatically with sql queries?
seems tedious
 
but howyou want to select best guild automatic?

number of players, averge lvl, top lvl or anything like that doesnt mean that guild is good :D

but you can make special poll and 4 most frequently selected guilds goes here automatic
 
<.< i mean i have always to edit the best guilds manually? would be better with sql queries
 
Nice, but IMO it shouldn't be cleared from time to time, more like: if current date-your last vote date>=value in config you can vote again WITHOUT clearing table with data.
And talkactions are pure evil, could you make it in php? :D
 
In this new version, it's better checking the IP too, so dont create accounts ...

Also: <globalevent name="votesclean" interval="86400" event="script" value="voteguild.lua"/>
This will executes every 86 seconds in 0.4_DEV :)
 
In this new version, it's better checking the IP too, so dont create accounts ...

Also: <globalevent name="votesclean" interval="86400" event="script" value="voteguild.lua"/>
This will executes every 86 seconds in 0.4_DEV :)

Anyways, other people can restart their router to change ip (if has dynamic ip)

Talking about 86 seconds

Try with 86400000 instead of 86400
 
Back
Top