TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,250
  • Total Topics: 21,354
  • Online today: 626
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

SMF Shoutbox help

Started by penny, June 19, 2006, 09:08:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

penny

Hi all   :D

I'm looking for a code to make a new highscore shout in the SMF Shoutbox like the invision board's shoutbox also have. If a member scores a new highscore in the Arcade the shoutbox will give a message.

For example:

[ Sunday | 22:34 ] <Penny> I am the new Champ of 1i Champi with a score of 19000!

Can someone help me? I cannot make it happen  :( Would be great to have this in the Shoutbox! 

Hope someone can help me to make this!   ;) :D

G6Cad

There is a champion Block code snippet that does show when a user scores a highscore in the arcade.
Look eather here in Block code snippets board, or on the smfarcade.net site in the hacks board.

penny

Ok thanks for your help will look into it!  :up:

penny

#3
I put this in the Arcade.php:

{
// new higscore!!!
// add new highscore message in shoutbox!
$sql = "insert into ".$db_prefix."sbox_content (name,content,time) values ('".$user_info['username']."','".$content."I am the new Champ of game with a score of 00000!','$date')";
db_query($sql,__FILE__,__LINE__);

}


Under this code in the Arcade.php:

Function Arcade_submit_torney($warning,$hop)
{
        global $boardurl, $txt, $scripturl, $db_prefix, $boarddir;
        global $ID_MEMBER, $sourcedir,$language,$user_profile;
        global $context, $user_info, $db_prefix, $modSettings;

        $temp = $_SESSION['arcade']['game'];

        $time = time();
        $q = "SELECT * FROM {$db_prefix}games_tournament WHERE tid='{$temp['tourney']}'";
        $res = db_query($q,__FILE__,__LINE__);
        $x = mysql_fetch_array($res);
        $round = unserialize($x['rounddata']);
if(isset($round[$temp['round']]))
{
  $cr = $round[$temp['round']];
}
else $cr = $temp['round'];
        $q2 = "INSERT INTO {$db_prefix}games_tournament_results SET tid='{$x['tid']}', round='{$temp['round']}', member='{$ID_MEMBER}', score='{$_POST['score']}'";
        db_query($q2,__FILE__,__LINE__);

        redirectexit("action=arcade;sa=tournament;update;id={$x['tid']}");
}

Function Arcade_submit_normal($warning,$hop)
{
global $boardurl, $txt, $scripturl, $db_prefix, $boarddir;
global $ID_MEMBER, $sourcedir,$language,$user_profile;
global $context, $user_info, $db_prefix, $modSettings;

$days = array($txt['sbox_Sunday'],$txt['sbox_Monday'],$txt['sbox_Tuesday'],$txt['sbox_Wednesday'],$txt['sbox_Thursday'],$txt['sbox_Friday'],$txt['sbox_Saturday']);
$day=$days[date("w")]; // weekday
$date=$day." | ". date("G:i"); // time
$time = time();

$duration = $time - $_SESSION['arcade']['start_time'];

if(!isset($_SESSION['arcade']['submit']) || $_SESSION['arcade']['submit']['score'] != $_POST['score'])
{

$query = "INSERT INTO `{$db_prefix}games_high` (`game`, `member`, `score`, `stime`,`warning`,`duration`,`ip`) VALUES ('{$_REQUEST['game']}', '{$ID_MEMBER}', '{$_POST['score']}', '{$time}','{$warning}','{$duration}','-')";
$results = db_query($query, __FILE__, __LINE__);

$per_sivu = $modSettings['arcade_highscores_per_page'];

$game = Get_Game_Info($_POST['game']);

$b = (get_position($_REQUEST['game'],$_REQUEST['score'],$game['type'],0));

$_GET['start'] = $b;

$_SESSION['arcade']['submit'] = array
(
'game' => $_POST['game'],
'score' => $_POST['score'],
'time' => $time,
'duration' => $duration,
'start' => $b,
'warning' => $warning,
'comment' => 0,
);

update_champ($_POST['game']);


/*
* scores inserted
* now if this player subbmit a number one score
* give him credits for the shop :)
*/
$query = "SELECT `member`, `score`, `stime` FROM `{$db_prefix}games_high` WHERE `game` = '{$_REQUEST['game']}' ORDER BY `score` DESC";
$result = db_query($query, __FILE__, __LINE__);
$content = mysql_fetch_array($result);
if( $content['stime'] == $time &&
$content['member'] == $ID_MEMBER &&
$content['score'] == $_POST['score']
  ){
// first score!!!
// give player 10 points in his bank ;)
$query = "UPDATE `{$db_prefix}members` SET `moneyBank` = `moneyBank` + '10.00' WHERE `ID_MEMBER` ='{$ID_MEMBER}'";
$results = db_query($query, __FILE__, __LINE__);
}


I get this in the Shoutbox when i submit a score:

[ Monday | 23:25 ] <Penny> ArrayI am the new Champ of game with a score of 00000!

Now the problem is: it will shout with every score that is submitted, which should be only with new highscores and i cannot get the Array away from the Shout Message.

So i am almost there, hope someone can help me out!   ;)

G6Cad

eeek ? Where are you when you are needed  :D

I'm sure that some one of the code masters here can give you a hand with this when they see this thread :)

penny

Found it!!!!!  :D :D :D :D :D :D

Where i put the code:

/*
* scores inserted
* now if this player subbmit a number one score
* give him credits for the shop :)
*/
$query = "SELECT `member`, `score`, `stime` FROM `{$db_prefix}games_high` WHERE `game` = '{$_REQUEST['game']}' ORDER BY `score` DESC";
$result = db_query($query, __FILE__, __LINE__);
$content = mysql_fetch_array($result);
if( $content['stime'] == $time &&
$content['member'] == $ID_MEMBER &&
$content['score'] == $_POST['score']
  ){
// first score!!!
// give player 10 points in his bank ;)
$query = "UPDATE `{$db_prefix}members` SET `moneyBank` = `moneyBank` + '10.00' WHERE `ID_MEMBER` ='{$ID_MEMBER}'";
$results = db_query($query, __FILE__, __LINE__);



// new higscore!!!
// add new highscore message in shoutbox!
$sql = "insert into ".$db_prefix."sbox_content (name,content,time) values ('".$user_info['username']."','".$content."I am the new Champ of game with a score of 00000!','$date')";
db_query($sql,__FILE__,__LINE__);

}


I made from the last { } 1 box and it worked!  :D :D :D :D :D

Now only the game link/name and score to put in. Hope i can find it out!

G6Cad

Great :) Very impressive work penny  :o

penny

#7
 :D Thanks!

I finished the code! My first own script! lol :D

Complete code for those who are interrested:

in Arcade.php find:


Function Arcade_submit_normal($warning,$hop)

and
Function Arcade_comment()



And copy & paste this between the 2 lines: ( Overwrite what is between it now  :) )


{
global $boardurl, $txt, $scripturl, $db_prefix, $boarddir;
global $ID_MEMBER, $sourcedir,$language,$user_profile;
global $context, $user_info, $db_prefix, $modSettings;

$days = array($txt['sbox_Sunday'],$txt['sbox_Monday'],$txt['sbox_Tuesday'],$txt['sbox_Wednesday'],$txt['sbox_Thursday'],$txt['sbox_Friday'],$txt['sbox_Saturday']);
$day=$days[date("w")]; // weekday
$date=$day." | ". date("G:i"); // time
$time = time();

$duration = $time - $_SESSION['arcade']['start_time'];

if(!isset($_SESSION['arcade']['submit']) || $_SESSION['arcade']['submit']['score'] != $_POST['score'])
{

$query = "INSERT INTO `{$db_prefix}games_high` (`game`, `member`, `score`, `stime`,`warning`,`duration`,`ip`) VALUES ('{$_REQUEST['game']}', '{$ID_MEMBER}', '{$_POST['score']}', '{$time}','{$warning}','{$duration}','-')";
$results = db_query($query, __FILE__, __LINE__);

$per_sivu = $modSettings['arcade_highscores_per_page'];

$game = Get_Game_Info($_POST['game']);

$b = (get_position($_REQUEST['game'],$_REQUEST['score'],$game['type'],0));

$_GET['start'] = $b;

$_SESSION['arcade']['submit'] = array
(
'game' => $_POST['game'],
'score' => $_POST['score'],
'time' => $time,
'duration' => $duration,
'start' => $b,
'warning' => $warning,
'comment' => 0,
);

update_champ($_POST['game']);


/*
* scores inserted
* now if this player subbmit a number one score
* give him credits for the shop :)
*/
$query = "SELECT `member`, `score`, `stime` FROM `{$db_prefix}games_high` WHERE `game` = '{$_REQUEST['game']}' ORDER BY `score` DESC";
$result = db_query($query, __FILE__, __LINE__);
$content = mysql_fetch_array($result);
if( $content['stime'] == $time &&
$content['member'] == $ID_MEMBER &&
$content['score'] == $_POST['score']
  ){
// first score!!!
// give player 10 points in his bank ;)
$query = "UPDATE `{$db_prefix}members` SET `moneyBank` = `moneyBank` + '10.00' WHERE `ID_MEMBER` ='{$ID_MEMBER}'";
$results = db_query($query, __FILE__, __LINE__);
}

/*
* scores inserted
* now if this player subbmit a number one score
* give him credits for the shop :)
*/
$query = "SELECT `member`, `score`, `stime` FROM `{$db_prefix}games_high` WHERE `game` = '{$_REQUEST['game']}' ORDER BY `score` DESC";
$result = db_query($query, __FILE__, __LINE__);
$content = mysql_fetch_array($result);
if( $content['stime'] == $time &&
$content['member'] == $ID_MEMBER &&
$content['score'] == $_POST['score']
  ){
// first score!!!
// give player 10 points in his bank ;)
$query = "UPDATE `{$db_prefix}members` SET `moneyBank` = `moneyBank` + '10.00' WHERE `ID_MEMBER` ='{$ID_MEMBER}'";
$results = db_query($query, __FILE__, __LINE__);

// -- SETUP EDITS ---

$db_prefix = 'smf_'; //edit this to your your database prefix - usually smf_
$no = 10; //number of top players to show

// --LANGUAGE EDITS --
$txtplay = "The Top Players"; // change "The Top Players" to your language
$txtwin = "Number Of Wins :";// change "Number Of Wins :" to your language
$txtlate = "Latest High Score by ";// change "Latest High Score set by" to your language
$txtwit = "with ";// change "with" to your language
$txton = "on ";// change "on" to your language

require('./Settings.php');


$link = mysql_connect($db_server, $db_user, $db_passwd);
mysql_select_db($db_name, $link);

// --START BLOCK CODE --
$content = "";  //set blank for a start

//Get newest champ or die
$sql = "SELECT m.ID_MEMBER,m.realName,g.id, g.game, g.name,g.champion_score "
. "FROM {$db_prefix}members m , {$db_prefix}games g "
. "WHERE g.champion_score > 0 AND m.ID_MEMBER=g.champion_member "
. "ORDER BY g.champion_time DESC LIMIT 0,1";

if(!($result = mysql_query($sql,$link)))
{
die("Could not get the newest champ");
}
$row = mysql_fetch_assoc($result);
mysql_free_result($result);

//newest champ details
$playerid = $row['ID_MEMBER'];
$player = $row['realName'];
$game_id = $row['id'];
$game_name = $row['name'];
$score = $row['champion_score'];

//now get the pic for the game
$ext = array('gif','GIF','png','PNG','jpg','JPG',);
$game_pic = ""; // No thumbnail for default
foreach($ext as $ex)
{
if(file_exists($boarddir. "/Games/".$row['game'].".".$ex))
{
$game_pic = $boardurl."/Games/".$row['game'].".".$ex;
}
}


//Get the 10 best players or die
/*$sql = "SELECT m.ID_MEMBER, m.realName, count(g.id) As cnt"
. " FROM {$db_prefix}games g, {$db_prefix}members m"
. " WHERE m.ID_MEMBER=g.champion_member"
. " GROUP BY realName "
. " ORDER BY cnt DESC LIMIT 0,{$no}";
if(!($result = db_query($sql,__FILE__,__LINE__)))
{
die("Could not get the best players");
}

$row = mysql_fetch_assoc($result);*/

$score_poss=0; //players position


// new higscore!!!
// add new highscore message in shoutbox!
$sql = "insert into ".$db_prefix."sbox_content (name,content,time) values ('".$user_info['username']."','".$content."<b>I am the new Champ of <a href=\"{$scripturl}?action=arcade;sa=play;game={$game_id}\" target=\"_blank\">{$game_name}</a> {$txtwit} a score of {$score}!</b>','$date')";
db_query($sql,__FILE__,__LINE__);

}
}
}


That's the way i have it ;) :)


In this code is also a Shop code which gives every member which scores a new highscore in the Arcade shop points which goes into his/her's bank!


anunlike

Would you like to submit that code to TP's Block code snippets, if you haven't yet?


akulion

wow extremely useful code! I have both the shop and arcade - so it will be awesome to have - thanks :D

This website is proudly hosted on Crocweb Cloud Website Hosting.