Ir para conteúdo

Featured Replies

Postado

Olá, peguei um sistema de venda e compra de personagens via website, contudo, gostaria de fazer algumas adaptações.

 

Nesse aqui, eu gostaria que o personagem que ele gostaria de vender teria que estar offline para aparecer na lista.

Sellchar.php

Spoiler

<?PHP
    if($logged) {
        $main_content .= '<center><b>Here you can put your character on sale!</center></b><br>';
        $main_content .= 'If you put your character on sale anyone can buy it, you will lose acces to that character and you wont be able to log in with that character until someone buys it, you can also delete your offer by talking to an admin!<br><b>when someone buys your character you will get the price in points!</b>';
        $main_content .= '<br>';
        $main_content .= '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white width="64px"><CENTER><B>Sell your characters</B></CENTER></TD></TR>';
        $main_content .= '<TR BGCOLOR='.$config['site']['darkborder'].'><TD CLASS=black width="64px"><B></B>';
        
        $players_from_logged_acc = $account_logged->getPlayersList();
                            
                                $players_from_logged_acc->orderBy('name');
                                $main_content .= '<form action="" method="post"><select name="char">';
                                foreach($players_from_logged_acc as $player)
                                {
                                    $main_content .= '<option>'.$player->getName().'</option>';
                                }
        
        $main_content .= '</select>Select a character to sell<br>';
        $main_content .= '<input type="text" name="price" maxlength="10" size="4" >Select the price of the character<br>';
        $main_content .= '<input type="submit" name="submit" value="Sell character"></TD></TR>';
                            $main_content .= '</form></table>';
                            
                            if (isset($_POST['submit'])) {
                                
                            $char = stripslashes($_POST['char']);
                            $price = stripslashes($_POST['price']);
                            
                            if ($char && $price) {
 
                                if(is_numeric(trim($_POST['price']))) {
                                
                                        $check2 = $SQL->query("SELECT * FROM `players` WHERE `name` = '$char'") or die(mysql_error());
                                foreach ($check2 as $re) {
                                    $voc = $re['vocation'];
                                    $oid = $re['account_id'];
                                }
                                $check1 = $SQL->query("UPDATE `players` SET `account_id` = 1 WHERE `name` = '$char'") or die(mysql_error());
                                $check4 = $SQL->query("UPDATE `players` SET `deleted` = 1 WHERE `name` = '$char'") or die(mysql_error());
                                $check3 = $SQL->query("INSERT INTO `sellchar` VALUES ('','$char','$voc','$price','1','$oid')");
                                $main_content .= '<b><center>You added your character correctly, thanks!</b></center>';
                                header("Location: index.php?subtopic=buychar");
                                
                                } else {
                            
                                $main_content .= '<b><center>Set a numeric price!!</b></center>';
                                }
                                
                            } else {
                                    $main_content .= '<b><center>Fill out all fields!</b></center>';
                            }
                            
    }
    } else {
        $main_content .= '<b><center>Please log in first!</b></center>';
    }
?>

 

 

Nesse eu gostaria que fizesse um UPDATE do campo deleted para o valor 0. Tentei de todas as formas porém não consegui :/

Spoiler

<?PHP
    if($logged) {
        
        if ($action == '') {
        
        $main_content .= '<center>Here is the list of the current characters that are in the shop!</center>';
        $main_content .= '<BR>';
        $main_content .= '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD CLASS=white width="64px"><CENTER><B>Name</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Vocation</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Level</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Price</B></CENTER></TD><TD CLASS=white width="64px"><CENTER><B>Buy it</B></CENTER></TD></TR>';
        $getall = $SQL->query('SELECT `id`, `name`, `price`, `status` FROM `sellchar` ORDER BY `id`')or die(mysql_error());
        foreach ($getall as $tt) {
            $namer = $tt['name'];
            $queryt = $SQL->query("SELECT `name`, `vocation`, `level` FROM `players` WHERE `name` = '$namer'");
            foreach ($queryt as $ty) {
            if ($ty['vocation'] == 1) {
            $tu = 'Sorcerer';
        } else if ($ty['vocation'] == 2) {
            $tu = 'Druid';    
        } else if ($ty['vocation'] == 3) {
            $tu = 'Paladin';    
        } else if ($ty['vocation'] == 4) {
            $tu = 'Knight';
        } else if ($ty['vocation'] == 5) {
            $tu = 'Sorcerer';
        }  else if ($ty['vocation'] == 6) {
            $tu = 'Druid';    
        } else if ($ty['vocation'] == 7) {
            $tu = 'Paladin';    
        } else if ($ty['vocation'] == ? {
            $tu = 'Knight';
        }
        $ee = $tt['name'];
        $ii = $tt['price'];
        $main_content .= '<TR BGCOLOR='.$config['site']['darkborder'].'><TD CLASS=black width="64px"><CENTER><B><a href="index.php?subtopic=characters&name='.$tt['name'].'">'.$tt['name'].'</a></B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>'.$tu.'</B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>'.$ty['level'].'</B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>'.$tt['price'].'</B></CENTER></TD><TD CLASS=black width="64px"><CENTER><B>
        <form action="?subtopic=buychar&action=buy" method="POST">
        <input type="hidden" name="char" value="'.$ee.'">
        <input type="hidden" name="price" value="'.$ii.'">
        <input type="submit" name="submit" value="Buy it"></B></CENTER></TD></TR></form>';
        }
        }
        $main_content .= '</TABLE>';
        
        }
        
        if ($action == 'buy') {
        
            $name = $_POST['char'];    
            $price = $_POST['price'];    
            $ceh = $SQL->query("SELECT `name` FROM `sellchar` WHERE `name` = '$name'");
            
            if ($ceh) {
            
            if ($name == '') {
            
            $main_content .= '<b><center>Select a character to buy first/b>';
            
            } else {
            
            $user_premium_points = $account_logged->getCustomField('premium_points');
            $user_id = $account_logged->getCustomField('id');
            
            if ($user_premium_points >= $price) {
                
            $check = $SQL->query("SELECT * FROM `sellchar` WHERE `name` = '$name'") or die(mysql_error());
            $check1 = $SQL->query("SELECT * FROM `players` WHERE `name` = '$name'") or die(mysql_error());
            $check2 = $SQL->query("SELECT `oldid` FROM `sellchar` WHERE `name` = '$name'");
            foreach ($check as $result) {
            foreach($check1 as $res) {
            foreach($check2 as $ress) {
            
            $oid = $ress['oldid'];    
            $main_content .= '<center>You bought<b> '.$name.' ('.$res['level'].') </b>for  <b>'.$result['price'].' points.</b><br>Don\'t forget to undelete the character in your account.</center>';
            $main_content .= '<br>';
            $main_content .= '<center><b>The character is in your account, have fun!</b></center>';
            $execute1 = $SQL->query("UPDATE `accounts` SET `premium_points` = `premium_points` - '$price' WHERE `id` = '$user_id'");
            $execute2 = $SQL->query("UPDATE `players` SET `account_id` = '$user_id' WHERE `name` = '$name'");
            $execute2 = $SQL->query("UPDATE `accounts` SET `premium_points` = `premium_points` + '$price' WHERE `id` = '$oid'");
            $execute3 = $SQL->query("DELETE FROM `sellchar` WHERE `name` = '$name'");
            
            
            }
                }
            }
                
            } else {
                
                $main_content .= '<center><b>You dont have enought premium points</b></center>';
                
                    }
            
                }    
                
            } else {
                $main_content .= '<center><b>Character cannot be buyed</b></center>';
            }
        }
        
    } else {
        
        $main_content .= '<center>Please log in first!</center>';
    }
?>

 

Agradeço desde já.

Postado

Utilize a função $player->isOnline(). A função é essa aqui. A função retornar um booleano verdadeiro caso o jogador esteja online, e caso não, um booleano falso.

discord.pngDiscord: vankk #7765

Precisando de ajuda? Entre em contato comigo via Discord.

 

Muitos vêm seus muitos dias de glória, mas poucos vêm seus muitos dias de luta.

Postado
  • Autor
14 horas atrás, vankk disse:

Utilize a função $player->isOnline(). A função é essa aqui. A função retornar um booleano verdadeiro caso o jogador esteja online, e caso não, um booleano falso.

 

Obrigado, mas segundo o site que você me passou, essa função é para TFS 1.0 e o meu é 0.4. A minha dúvida é se funcionaria do mesmo jeito..

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 520.3k

Informação Importante

Confirmação de Termo