TFS 1.X Bounty Hunter System

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by imkingran, Apr 14, 2014.

  1. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    imkingran likes this.
  2. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    You can add it if you want, it looks a little ugly in my opinion haha :D

    I'lll leave it up on the same page for tonight so you can see how it looks.

    PHP:
    <?php
    $main_content 
    .= '
        <TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>
            <TR>
                <TD style="text-align:center;"><H2>Bounty Hunters</H2></TD>
            </TR>
            <TR BGCOLOR="'
    .$config['site']['vdarkborder'].'">
                <TD><CENTER><FONT COLOR=WHITE SIZE=2><b>How to use...</b></FONT></CENTER></TD>
            </TR>        
            <TR BGCOLOR="'
    .$config['site']['darkborder'].'">
                <TD style="text-align:center;"><b>!hunt prize,nick</b>
            <br><font color="red">It is important to right exactly like this <b>prize,nick</b> with no spaces after the comma.</font>
                <br><i>Example: !hunt 1000000,Player_name
                <br> Will Pay 1KK(1,000,000 gold Pieces) for the Player who Kills Player_name.</i>
    <br><b>1kk = 1,000,000 gold</b>
    <br><b><font color="green">Money is added to your bank account automatically if you get a Bounty Kill.</font></b></TD>
            </TR>        
    </TABLE><br><br><table>        
    '
    ;
    $main_content .= '
            <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
                <TR BGCOLOR="#505050">
                    <TD CLASS=white width=28%>
                        <center><B>Hunted by</B></center>
                    </TD>
                    <TD CLASS=white width=14%>
                        <center><B>Reward</B></center>
                    </TD>
                    <TD CLASS=white width=28%>
                        <center><B>Player hunted</B></center>
                    </TD>
            <TD CLASS=white><b>Outfit</b></TD>
                    <TD CLASS=white width=28%>
                        <center><B>Killed by</B></center>
                    </TD>
                </TR>'
    ;
    foreach(
    $SQL->query('SELECT A.* , B.name AS hunted_by, C.name AS player_hunted, D.name AS killed_by
                            FROM bounty_hunters AS A
                            LEFT JOIN players AS B ON A.fp_id = B.id
                            LEFT JOIN players AS C ON A.sp_id = C.id
                            LEFT JOIN players AS D ON A.k_id = D.id 
                            ORDER BY A.killed,A.prize DESC'
    ) as $bounty) {
            if(
    $num%== 0){$color=$config['site']['darkborder'];}else{$color=$config['site']['lightborder'];}
            if (
    $bounty['killed_by']){
                    
    $killed_by '<a href="?subtopic=characters&name='.$bounty['killed_by'].'">'.$bounty['killed_by'].'</a>';
            } else {
                    
    $killed_by 'still alive';
            }
        
    $b round($bounty[prize] / 1000000,2);
        
    $skill $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$bounty['sp_id'].'')->fetch();
    if(
    $skill['online'] == 1)
                    
    $main_content .= '
                    <TR BGCOLOR="'
    .$color.'">
                        <TD><center><b><a href="?subtopic=characters&name='
    .$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
                        <TD><center><b>'
    .$b.'  kk</b></center></TD>
                        <TD><center><b><a href="?subtopic=characters&name='
    .urlencode($bounty['player_hunted']).'"><b><font color="green">'.htmlspecialchars($bounty['player_hunted']).'</font></b></a></b></center></TD>
                <TD><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\'http://outfit-images.ots.me/outfit.php?id='
    .$skill['looktype'].'&addons='.$skill['lookaddons'].'&head='.$skill['lookhead'].'&body='.$skill['lookbody'].'&legs='.$skill['looklegs'].'&feet='.$skill['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></TD>
                        <TD><center><b>'
    .$killed_by.'</b></center></TD>
                    </TR>'
    ;
        else
                            
    $main_content .= '
                    <TR BGCOLOR="'
    .$color.'">
                        <TD><center><b><a href="?subtopic=characters&name='
    .$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
                        <TD><center><b>'
    .$b.'  kk</b></center></TD>
                        <TD><center><b><a href="?subtopic=characters&name='
    .urlencode($bounty['player_hunted']).'"><b><font color="red">'.htmlspecialchars($bounty['player_hunted']).'</font></b></a></b></center></TD>
                <TD><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\'http://outfit-images.ots.me/outfit.php?id='
    .$skill['looktype'].'&addons='.$skill['lookaddons'].'&head='.$skill['lookhead'].'&body='.$skill['lookbody'].'&legs='.$skill['looklegs'].'&feet='.$skill['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></TD>
                        <TD><center><b>'
    .$killed_by.'</b></center></TD>
                    </TR>'
    ;
            
    $num++;
    }
    if(
    $num == 0){
            
    $main_content.='<TR BGCOLOR="'.$color.'"><TD colspan=4><center>Currently there are not any bounty hunter offer.</center></TD></TR>';
    }
        
    $main_content .='</TABLE></table>';
    ?> 
     
    Cotizado likes this.
  3. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    yea i will leave it like before
     
  4. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    this is what i mean
    http://acaxia.net/index.php?subtopic=bountyhunters
     
    imkingran likes this.
  5. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    Cotizado likes this.
  6. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    well i prefere the way my look but it didnt work since there isnt an online column on my players in databace
     
  7. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    Here this one will work without Online column (you can re-add your edits):
    PHP:
    <?php
    $main_content 
    .= '
        <TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>
            <TR>
                <TD style="text-align:center;"><H2>Bounty Hunters</H2></TD>
            </TR>
            <TR BGCOLOR="'
    .$config['site']['vdarkborder'].'">
                <TD><CENTER><FONT COLOR=WHITE SIZE=2><b>How to use...</b></FONT></CENTER></TD>
            </TR>        
            <TR BGCOLOR="'
    .$config['site']['darkborder'].'">
                <TD style="text-align:center;"><b>!hunt prize,nick</b>
            <br><font color="red">It is important to right exactly like this <b>prize,nick</b> with no spaces after the comma.</font>
                <br><i>Example: !hunt 1000000,Player_name
                <br> Will Pay 1KK(1,000,000 gold Pieces) for the Player who Kills Player_name.</i>
    <br><b>1kk = 1,000,000 gold</b>
    <br><b><font color="green">Money is added to your bank account automatically if you get a Bounty Kill.</font></b></TD>
            </TR>        
    </TABLE><br><br><table>        
    '
    ;
    $main_content .= '
            <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
                <TR BGCOLOR="#505050">
                    <TD CLASS=white width=28%>
                        <center><B>Hunted by</B></center>
                    </TD>
                    <TD CLASS=white width=14%>
                        <center><B>Reward</B></center>
                    </TD>
                    <TD CLASS=white width=28%>
                        <center><B>Player hunted</B></center>
                    </TD>
            <TD CLASS=white><b>Outfit</b></TD>
                    <TD CLASS=white width=28%>
                        <center><B>Killed by</B></center>
                    </TD>
                </TR>'
    ;
    foreach(
    $SQL->query('SELECT A.* , B.name AS hunted_by, C.name AS player_hunted, D.name AS killed_by
                            FROM bounty_hunters AS A
                            LEFT JOIN players AS B ON A.fp_id = B.id
                            LEFT JOIN players AS C ON A.sp_id = C.id
                            LEFT JOIN players AS D ON A.k_id = D.id 
                            ORDER BY A.killed,A.prize DESC'
    ) as $bounty) {
            if(
    $num%== 0){$color=$config['site']['darkborder'];}else{$color=$config['site']['lightborder'];}
            if (
    $bounty['killed_by']){
                    
    $killed_by '<a href="?subtopic=characters&name='.$bounty['killed_by'].'">'.$bounty['killed_by'].'</a>';
            } else {
                    
    $killed_by 'still alive';
            }
        
    $b round($bounty[prize] / 1000000,2);
        
    $skill $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$bounty['sp_id'].'')->fetch();
    if(
    Player::isPlayerOnline($skill['id']))
                    
    $main_content .= '
                    <TR BGCOLOR="'
    .$color.'">
                        <TD><center><b><a href="?subtopic=characters&name='
    .$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
                        <TD><center><b>'
    .$b.'  kk</b></center></TD>
                        <TD><center><b><a href="?subtopic=characters&name='
    .urlencode($bounty['player_hunted']).'"><b><font color="green">'.htmlspecialchars($bounty['player_hunted']).'</font></b></a></b></center></TD>
                <TD><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\'http://outfit-images.ots.me/outfit.php?id='
    .$skill['looktype'].'&addons='.$skill['lookaddons'].'&head='.$skill['lookhead'].'&body='.$skill['lookbody'].'&legs='.$skill['looklegs'].'&feet='.$skill['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></TD>
                        <TD><center><b>'
    .$killed_by.'</b></center></TD>
                    </TR>'
    ;
        else
                            
    $main_content .= '
                    <TR BGCOLOR="'
    .$color.'">
                        <TD><center><b><a href="?subtopic=characters&name='
    .$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
                        <TD><center><b>'
    .$b.'  kk</b></center></TD>
                        <TD><center><b><a href="?subtopic=characters&name='
    .urlencode($bounty['player_hunted']).'"><b><font color="red">'.htmlspecialchars($bounty['player_hunted']).'</font></b></a></b></center></TD>
                <TD><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\'http://outfit-images.ots.me/outfit.php?id='
    .$skill['looktype'].'&addons='.$skill['lookaddons'].'&head='.$skill['lookhead'].'&body='.$skill['lookbody'].'&legs='.$skill['looklegs'].'&feet='.$skill['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></TD>
                        <TD><center><b>'
    .$killed_by.'</b></center></TD>
                    </TR>'
    ;
            
    $num++;
    }
    if(
    $num == 0){
            
    $main_content.='<TR BGCOLOR="'.$color.'"><TD colspan=4><center>Currently there are not any bounty hunter offer.</center></TD></TR>';
    }
        
    $main_content .='</TABLE></table>';
    ?> 
     
    Cotizado likes this.
  8. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    PHP:
    <?php
    $main_content 
    .= '
        <TABLE BORDER=0 CELLPADDING=4 CELLSPACING=1 WIDTH=100%>
            <TR>
                <TD style="text-align:center;"><H2>Bounty Hunters</H2></TD>
            </TR>
            <TR BGCOLOR="'
    .$config['site']['vdarkborder'].'">
                <TD><CENTER><FONT COLOR=WHITE SIZE=2><b>How to use...</b></FONT></CENTER></TD>
            </TR>        
            <TR BGCOLOR="'
    .$config['site']['darkborder'].'">
                <TD style="text-align:center;"><b>!hunt prize,nick</b>
            <br><font color="red">It is important to right exactly like this <b>prize,nick</b> with no spaces after the comma.</font>
                <br><i>Example: !hunt 1000000,Player_name
                <br> Will Pay 1KK(1,000,000 gold Pieces) for the Player who Kills Player_name.</i>
    <br><b>1kk = 1,000,000 gold</b>
    <br><b><font color="green">Money is added to your bank account automatically if you get a Bounty Kill.</font></b></TD>
            </TR>        
    </TABLE><br><br><table>        
    '
    ;
    $main_content .= '
            <TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%>
                <TR BGCOLOR="#505050">
                    <TD CLASS=white width=28%>
                        <center><B>Hunted by</B></center>
                    </TD>
                    <TD CLASS=white width=14%>
                        <center><B>Reward</B></center>
                    </TD>
                    <TD CLASS=white width=28%>
                        <center><B>Player hunted</B></center>
                    </TD>
            <TD CLASS=white><b>Outfit</b></TD>
                    <TD CLASS=white width=28%>
                        <center><B>Killed by</B></center>
                    </TD>
                </TR>'
    ;
    foreach(
    $SQL->query('SELECT A.* , B.name AS hunted_by, C.name AS player_hunted, D.name AS killed_by
                            FROM bounty_hunters AS A
                            LEFT JOIN players AS B ON A.fp_id = B.id
                            LEFT JOIN players AS C ON A.sp_id = C.id
                            LEFT JOIN players AS D ON A.k_id = D.id 
                            ORDER BY A.killed,A.prize DESC'
    ) as $bounty) {
            if(
    $num%== 0){$color=$config['site']['darkborder'];}else{$color=$config['site']['lightborder'];}
            if (
    $bounty['killed_by']){
                    
    $killed_by '<a href="?subtopic=characters&name='.$bounty['killed_by'].'">'.$bounty['killed_by'].'</a>';
            } else {
                    
    $killed_by 'still alive';
            }
        
    $b round($bounty[prize] / 1000000,2);
        
    $skill $SQL->query('SELECT * FROM '.$SQL->tableName('players').' WHERE '.$SQL->fieldName('id').' = '.$bounty['sp_id'].'')->fetch();
    if(
    Player::isPlayerOnline($skill['id']))
                    
    $main_content .= '
                    <TR BGCOLOR="'
    .$color.'">
                        <TD><center><b><a href="?subtopic=characters&name='
    .$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
                        <TD><center><b>'
    .$b.'  kk</b></center></TD>
                        <TD><center><b><a href="?subtopic=characters&name='
    .urlencode($bounty['player_hunted']).'"><b><font>'.htmlspecialchars($bounty['player_hunted']).'</font></b></a></b><span style="color:green">[On]</span></center></TD>
                <TD><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\'http://outfit-images.ots.me/outfit.php?id='
    .$skill['looktype'].'&addons='.$skill['lookaddons'].'&head='.$skill['lookhead'].'&body='.$skill['lookbody'].'&legs='.$skill['looklegs'].'&feet='.$skill['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></TD>
                        <TD><center><b>'
    .$killed_by.'</b></center></TD>
                    </TR>'
    ;
        else
                            
    $main_content .= '
                    <TR BGCOLOR="'
    .$color.'">
                        <TD><center><b><a href="?subtopic=characters&name='
    .$bounty['hunted_by'].'">'.$bounty['hunted_by'].'</a></b></center></TD>
                        <TD><center><b>'
    .$b.'  kk</b></center></TD>
                        <TD><center><b><a href="?subtopic=characters&name='
    .urlencode($bounty['player_hunted']).'"><b><font>'.htmlspecialchars($bounty['player_hunted']).'</font></b></a></b><span style="color:red">[Off]</span></center></TD>
                <TD><div style="position: relative; width: 32px; height: 32px;"><div style="background-image: url(\'http://outfit-images.ots.me/outfit.php?id='
    .$skill['looktype'].'&addons='.$skill['lookaddons'].'&head='.$skill['lookhead'].'&body='.$skill['lookbody'].'&legs='.$skill['looklegs'].'&feet='.$skill['lookfeet'].'\'); position: absolute; width: 64px; height: 80px; background-position: bottom right; background-repeat: no-repeat; right: 0px; bottom: 0px;"></div></div></TD>
                        <TD><center><b>'
    .$killed_by.'</b></center></TD>
                    </TR>'
    ;
            
    $num++;
    }
    if(
    $num == 0){
            
    $main_content.='<TR BGCOLOR="'.$color.'"><TD colspan=4><center>Currently there are not any bounty hunter offer.</center></TD></TR>';
    }
        
    $main_content .='</TABLE></table>';
    ?> 
     
    imkingran likes this.
  9. EwR

    EwR Member

    Joined:
    Aug 28, 2013
    Messages:
    95
    Console error!
    data/talkactions/scripts/bh-add.lua:eek:nsay
    data/talkactions/scripts/bh-add.lua:12: attempt to call global 'getPlayerGUIDByName' <a nil value>
    stack traceback:
    [C]: in function 'getPlayerGUIDByName'
    data/talkactions/scripts/bh-add.lua:12: in function <data/talkactions/scripts/bh-add.lua:1

    Im usinf TFS 1,0 any help please?
     
  10. EwR

    EwR Member

    Joined:
    Aug 28, 2013
    Messages:
    95
    HALP XD
     
  11. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    Code:
    function getPlayerGUIDByName(name)
         local player = Player(name)
         if player ~= nil then
             return player:getGuid()
         end
         local resultId = db.storeQuery("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(name))
         if resultId ~= false then
             local guid = result.getDataInt(resultId, "id")
             result.free(resultId)
             return guid
         end
         return 0
    end
    
    https://github.com/otland/forgottenserver/blob/master/data/compat.lua
     
  12. EwR

    EwR Member

    Joined:
    Aug 28, 2013
    Messages:
    95
    i replace all bh-add for this?
     
    Last edited: Sep 26, 2014
  13. EwR

    EwR Member

    Joined:
    Aug 28, 2013
    Messages:
    95
    BUMP
    ok i put that on globla.lua and now say this:

    attempt to call global doPlayerSendTextMessage
     
    Last edited: Sep 26, 2014
  14. Limos

    Limos Premium User

    Joined:
    Jun 7, 2010
    Messages:
    10,017
    You can choose to add compat.lua to your datapack, then also add this at the top of global.lua.
    Code:
    dofile('data/compat.lua')
    Or you can also change the TFS 0.2 functions to TFS 1.0 metatable functions by using the compat.lua as example to see how to do that.
     
  15. EwR

    EwR Member

    Joined:
    Aug 28, 2013
    Messages:
    95
    I have on top of my global.lua this

    Code:
    dofile('data/libs.lua')
    and this on libs.lua
    Code:
    -- load storages first
    dofile('data/lib/051-storages.lua')
    
    dofile('data/lib/001-string.lua')
    dofile('data/lib/002-tables.lua')
    
    dofile('data/lib/050-functions.lua')
    
    dofile('data/lib/demonOakQuest.lua')
    dofile('data/lib/killingInTheNameOfQuest.lua')
    dofile('data/lib/missionSelect.lua')
    dofile('data/lib/svargrondArenaQuest.lua')
    dofile('data/lib/achievements_lib.lua')
    
    So i change that to have the "normal" functions to bounty hunter system and others can work?

    Edit: ok i make it and alot of errors in distro :( i put back libs.lua on global
     
    Last edited: Sep 26, 2014
  16. EwR

    EwR Member

    Joined:
    Aug 28, 2013
    Messages:
    95
    OK i solve it, all work, but now in web BountyHunter doesnt disappear, and the player is killed already
     
  17. fagotti

    fagotti New Member

    Joined:
    Nov 6, 2014
    Messages:
    12
    You can edit to work on ZNOTE website ??
     
  18. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    Sorry I'm not familiar with Znote. If someone can make it then I can add it to the main post.


    p.s.
    I updated the scripts to meta-tables but I haven't tested them.
    If you get any errors just post here.
     
  19. Cotizado

    Cotizado Member

    Joined:
    May 12, 2008
    Messages:
    321
    Can You make an event that broadcast the hunted players?
     
  20. imkingran

    imkingran Learning everyday. Premium User

    Joined:
    Jan 15, 2014
    Messages:
    1,151
    Explain a little more what you mean exactly.

    It already broadcast when you place the bounty and when you kill the player. Do you want it to broadcast on a time interval throughout the day as well?
     
    Cotizado likes this.

Share This Page