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

RevScripts Error Website buy/sell chara

Joker Man

Active Member
Joined
Nov 7, 2021
Messages
106
Reaction score
27
When i sell character in website,
auto add in account 1/1, in Account Manager and All chara add in game
can all use it.
how i can fixit
Like ThatV is chara seller
 

Attachments

When i sell character in website,
auto add in account 1/1, in Account Manager and All chara add in game
can all use it.
how i can fixit
Like ThatV is chara seller
First, what web are you using?

if is znoteacc, if I can remember, you need to set an account id to hold characters that are in auction, look at the config.php from your web and change the account id to an account that nobody's gonna use
 
i`m use myacc
Sellchara
you can give me script? to can add in config?
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?PHP
if($logged) {
$main_content .= '<center><b>Aqui voce pode vender seu personagem, NAO EH EM DINHEIRO PELO JOGO E SIM EM " POINTS "</center></b><br>';
$main_content .= 'Se voce colocar o seu personagem a venda qualquer pessoa pode compra-lo, voce vai perder acesso desse personagem e voce nao sera capaz de entrar com esse personagem, ate alguem compra-lo, voce tambem pode excluir a sua oferta falando com um administrador. <br> <b> quando alguem compra o seu personagem, voce vai ter o valor em pontos na sua account!</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>Escolha o character a ser vendido<br>';
$main_content .= '<input type="text" name="price" maxlength="10" size="4" >Escolha quanto voce quer pelo character ( POINTS )<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());
$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>';
}
?>
 
i`m use myacc
Sellchara
you can give me script? to can add in config?
here:
PHP:
$check1 = $SQL->query("UPDATE players SET account_id = 1 WHERE name = '$char'") or die(mysql_error());

change where is 1 to the account id that is gonna hold the character while they are in auction.
Just create an account that you and nobody is gonna use, with a harder password that you don't even need to know, only for secure and use that account to hold.

account id is diferent from account name/password
 
Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\config\config.php on line 17
i dont get whats happening! I only told you to change the account id to another account id, what have you done?
 
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (otserv.players, CONSTRAINT players_ibfk_1 FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE)' in C:\xampp\htdocs\sellchar.php:38 Stack trace: #0 C:\xampp\htdocs\sellchar.php(38): PDO->query('UPDATE `players...') #1 C:\xampp\htdocs\index.php(150): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\sellchar.php on line 38
Post automatically merged:

i dont get whats happening! I only told you to change the account id to another account id, what have you done?
$check1 = $SQL->query("UPDATE players SET account_id = 333 WHERE name = '$char'") or die(mysql_error());

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (otserv.players, CONSTRAINT players_ibfk_1 FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE)' in C:\xampp\htdocs\sellchar.php:38 Stack trace: #0 C:\xampp\htdocs\sellchar.php(38): PDO->query('UPDATE `players...') #1 C:\xampp\htdocs\index.php(150): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\sellchar.php on line 38
 
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (otserv.players, CONSTRAINT players_ibfk_1 FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE)' in C:\xampp\htdocs\sellchar.php:38 Stack trace: #0 C:\xampp\htdocs\sellchar.php(38): PDO->query('UPDATE `players...') #1 C:\xampp\htdocs\index.php(150): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\sellchar.php on line 38
Post automatically merged:


$check1 = $SQL->query("UPDATE players SET account_id = 333 WHERE name = '$char'") or die(mysql_error());

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1452 Cannot add or update a child row: a foreign key constraint fails (otserv.players, CONSTRAINT players_ibfk_1 FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE)' in C:\xampp\htdocs\sellchar.php:38 Stack trace: #0 C:\xampp\htdocs\sellchar.php(38): PDO->query('UPDATE `players...') #1 C:\xampp\htdocs\index.php(150): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\sellchar.php on line 38
and that account id 333 exist?
 
i`m create account 333/pass 333
just for test
and add
$check1 = $SQL->query("UPDATE players SET account_id = 333 WHERE name = '$char'") or die(mysql_error());
 
i`m create account 333/pass 333
just for test
and add
$check1 = $SQL->query("UPDATE players SET account_id = 333 WHERE name = '$char'") or die(mysql_error());
As I told you before:
account id is diferent from account name/password

account_id is the ID from accounts in your database

if you want some help, pay atention
 
i change script Like Gosier But
Fatal error: Call to undefined method OTS_Player::getAccountId() in C:\xampp\htdocs\sellchar.php on line 39
every time add account id > ^ Get that in

$player->setAccountId(2); < i change it but still no work
<?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="player_id">';
// w option w 'value' ustawiam ID gracza, rozwiazuje to wiele problemow z nickiami gracza i ich szukaniem w bazie
foreach ($players_from_logged_acc as $player) {
$main_content .= '<option value="' . $player->getId() . '">' . $player->getName() . '</option>';
}

$main_content .= '</select>Select a character to sell<br>';
$main_content .= '<input type="text" name="price" maxlength="5" 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'])) {
// zmieniam zmienne w int, jesli ktos wpisal jakis tekst, to zamieni sie w liczbe 0
$player_id = (int)$_POST['player_id'];
$price = (int)$_POST['price'];

// to znaczy, ze $player_id i $price nie są zerami
if ($player_id && $price) {
// cena musi byc dodatnia, inaczej ktos moze wystawic za -50 pkt, ktos to kupi i system da komus pkt. za darmo
if ($price > 0) {
$player = new OTS_Player();
$player->load($player_id);

// sprawdzamy czy gracz sie zaladowal = czy istnieje w bazie danych
if ($player->isLoaded()) {
// sprawdzamy czy id konta gracza jest takie samo jak id konta zalogowanego
if ($player->getAccountId() == $account_logged->getId()) {
// sprawdzamy czy gracz nie jest online
if (!$player->isOnline()) {
$offer_info = $SQL->query("SELECT price, oldid FROM sellchar WHERE name = " . $player_id)->fetch();
if (!$offer_info) {
$vocation = $player->getVocation();
$old_id = $player->getAccountId();

$player->setAccountId(1);
$player->save();

// wszystkie zmienne sa 'int', wiec na pewno sa bezpieczne dla MySQL,
// nie trzeba uzywac $SQL->quote, zeby zabezpieczyc sie przez SQL Injection
$SQL->query(
"INSERT INTO sellchar VALUES (NULL,'$player_id','$vocation','$price','1','$old_id')"
);

$main_content .= '<b><center>You added your character correctly, thanks!</b></center>';
header("Location: index.php?subtopic=buychar");
} else {
$main_content .= '<b><center>There is already sell offer for this character.</b></center>';
}
} else {
$main_content .= '<b><center>This character online! Logout first.</b></center>';
}
} else {
$main_content .= '<b><center>This character is not on your account!</b></center>';
}
} else {
$main_content .= '<b><center>Character does not exist!</b></center>';
}
} else {
$main_content .= '<b><center>Price must be higher than 0!</b></center>';
}
} else {
$main_content .= '<b><center>Fill out all fields!</b></center>';
}
}
} else {
$main_content .= '<b><center>Please log in first!</b></center>';
}
 
Back
Top