FlyFF Web Shop! v2.1 Released!

Oks, since Im nice today, I will post here my script to put item in the first empty slot of the char, just credit me <3
little explanation:
it selects from inventory table, using charid = to the id of the char and backpack_number = -1(no backpack, the inventory itself), it orders by inventory slot, so, it will be on a sequence ascending, meaning that the first number from 0 to 41 that is free is an empty place to put the item.
the for makes that check, it keep adding 1 to the count variable and takes each line of the reg, from the begining to the end. When the numbers arent the same, that means that the COUNT number is the empty slot. Then it inserts or shows a warning of full inventory.
I hope you understand, also, you can modify it to a backpack or even bank so it goes into a logical order(inventory, backpack, bank).
Here it goes:
Code:
$select = mysql_query("select inventoryslot from inventory where charid = $id and backpack_number = -1 order by inventoryslot asc");
                    $found = 'false';
                    for ($cont = 0; $cont <= 41; $cont++)
                    {
                        $reg = mysql_fetch_row($select);
                        if ($reg[0] != $cont)
                        {
                            $found = 'true';
                            break;
                        }
                    }
                    if ($found == 'true')
                    {
                        $insere = mysql_query("insert into inventory(itemid, charid, inventoryslot, count, addedByQuestID, backpack_number) values($itemId, $charId, $cont, $quantity, -1, -1)");
                        $update = mysql_query("update characters set penya = $penya where id = $charid");
                        if (mysql_affected_rows() != 0)
                        {
                            echo "<h3>Successfull bought the item.</h3>";
                        }
                        else
                        {
                            echo "<h3><font color='#FF0000'>Error</font>: Error trying to buy.</h3>";
                        }
                    }
                    else
                    {
                        echo "<h3><font color='#FF0000'>Warning</font>: Your inventory is full.</h3>";
                    }
also, please check if the '<= 41' in the for is right or if is just '< 41'.
I will implement that code in the next release and then change it to work good with it. Will add credits aswell. Keep it up!:thumbup1:
 
:scared: O_O very bad coding sorry but is very very bad coding you need to learn more php and html :wink:
Go away, this isnt a place for criticizing his coding, and besides, i'd love to see you make a better webshop...

its bugged... every time i try to buy something this script change SOMETHING in my shop db :/ idk why

Theres something up with your conifg, or ur buy.php, post em up here
 
hey spikensbor, i messed up my shop when i was turning it into a donation system (lol i suck), as much as i hate to beg, could u make a buy.php that works with... nuaz .... instead of penya (just nuaz, without all the other crap i typed) thanks
 
its buy.php:
Code:
<?php

/**
 * @author JuZTiFY
 * @copyright 2008
 */
include "config.php";
$charid = $_POST['character'];
$iid = $_POST['itemid'];
if($charid == ""){
	$e2 = "Nie pruboj niczego glupiego...";
	header("Location: index.php?error=$e2");
}
$con = mysql_connect($sqlserv, $sqluser, $sqlpass);
mysql_select_db($shopdb);
$query = mysql_query("SELECT * FROM items WHERE itemid='$iid'");
$row = mysql_fetch_array($query);
$price = $row['itemprice'];
mysql_close($con);
$con = mysql_connect($sqlserv, $sqluser, $sqlpass);
mysql_select_db($flyffdb);
$query = mysql_query("SELECT * FROM characters WHERE id='$charid'");
$row = mysql_fetch_array($query);
$penya = $row['penya'];
$total = $penya - $price;
if($total <= 0){
	$e1 = "Nie masz wystarczajacej ilosci penya aby kupic ten item!";
	header("location: index.php?error=$e1");
}
$query = mysql_query("INSERT INTO mails VALUES ('$total', '0', '$charid', '0', '0', 'Twoje zamowienie!', 'Tu masz swoje zamowienie!', '0', '$iid', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '-1');");
$q = "UPDATE characters SET penya='$total'".
     "WHERE id='$charid'";
mysql_query($q);
if($total > "1"){
	$error = "Item ktory zamowiles zostal wyslany poprzez mail w grze!";
	header("location: index.php?error=$error");
}
?>


and thats my config:
Code:
<?php
/**
 * @author JuZTiFY
 * @copyright 2008
 */

$sqlserv = "localhost"; # Your SQL Server IP(Usually localhost).
$sqluser = "root"; # Your SQL Server Username(Usually root).
$sqlpass = "PASSWORD"; # Your SQL Server Password.
$flyffdb = "flyff"; # Your FlyFF Server DB
$shopdb = "shopdb"; # The DB where you executed the shopdb.sql file.

?>
 
Oks, since Im nice today, I will post here my script to put item in the first empty slot of the char, just credit me <3
little explanation:
it selects from inventory table, using charid = to the id of the char and backpack_number = -1(no backpack, the inventory itself), it orders by inventory slot, so, it will be on a sequence ascending, meaning that the first number from 0 to 41 that is free is an empty place to put the item.
the for makes that check, it keep adding 1 to the count variable and takes each line of the reg, from the begining to the end. When the numbers arent the same, that means that the COUNT number is the empty slot. Then it inserts or shows a warning of full inventory.
I hope you understand, also, you can modify it to a backpack or even bank so it goes into a logical order(inventory, backpack, bank).
Here it goes:
Code:
$select = mysql_query("select inventoryslot from inventory where charid = $id and backpack_number = -1 order by inventoryslot asc");
                    $found = 'false';
                    for ($cont = 0; $cont <= 41; $cont++)
                    {
                        $reg = mysql_fetch_row($select);
                        if ($reg[0] != $cont)
                        {
                            $found = 'true';
                            break;
                        }
                    }
                    if ($found == 'true')
                    {
                        $insere = mysql_query("insert into inventory(itemid, charid, inventoryslot, count, addedByQuestID, backpack_number) values($itemId, $charId, $cont, $quantity, -1, -1)");
                        $update = mysql_query("update characters set penya = $penya where id = $charid");
                        if (mysql_affected_rows() != 0)
                        {
                            echo "<h3>Successfull bought the item.</h3>";
                        }
                        else
                        {
                            echo "<h3><font color='#FF0000'>Error</font>: Error trying to buy.</h3>";
                        }
                    }
                    else
                    {
                        echo "<h3><font color='#FF0000'>Warning</font>: Your inventory is full.</h3>";
                    }
also, please check if the '<= 41' in the for is right or if is just '< 41'.

This code won't detect if the inventory is full because when you sort in the query, it will become 1 and then 10 and then 2, 3, 4 etc. So it would turn out that it found it all the time.
 
This code won't detect if the inventory is full because when you sort in the query, it will become 1 and then 10 and then 2, 3, 4 etc. So it would turn out that it found it all the time.

Are you sure? I tested it for an entire hour, it always worked great, telling when it was out of penya, space in inventory, and putting item on first free slot.
Also, the only reason I see for something to goes in the order you said instead of correctly numerical order is because datatype is char/text instead of integer, check it.
 
Nice work guys continue with it.I barely know few language from curiosity and I understand the structure of the codes you post. :D: It`s not very complicated, if i know a little more PHP i can do it myself.The secret of all computer languages is really simple.1st Remember what command is doing what.2nd imagine your goal with precise :cool: You are cool guys.I think you can do hell of a CS system here.I test v2.1 and i think is much better than v1.It`s simple compared with v1.
 
Very nice , i saw in a private server with a buffer that works like this Login choose char and char is buffed :o
some1 know how to do this? ^^
sorry for my bad english :O
 
how do i change the mail thing so the items will be sent in the first slot in my inventory?
because my mail is not working, everytime someone press it he crashes
 
wow seriously, spikensbror, you should start this codes again from 0, they got some vulnerabilitys :)


before learn php, you must learn html <--- that's for everyone <3
 
I can't get it to work :S

I get the following msg: There was an error while buying the item!.

I've looked through your code, looks like that it wont add the line into the inventory table :S

Not sure why...
 
I can't get it to work :S

I get the following msg: There was an error while buying the item!.

I've looked through your code, looks like that it wont add the line into the inventory table :S

Not sure why...

I 2nd quote this :x

I looked around also on the file to see if theres any think i might of mucked up on but me didnt :x
 
I founf out why it doesn't work. Try to change the line:
Code:
$q = "UPDATE characters SET penya='$total'".
	"WHERE charid='$charid'";
In the buy.php to:
Code:
$q = "UPDATE characters SET penya='$total'".
	"WHERE id='$charid'";
I made a small typo. The charid does nor work so you need to change charid to id.
Look at the code boxes.
 
I founf out why it doesn't work. Try to change the line:
Code:
$q = "UPDATE characters SET penya='$total'".
	"WHERE charid='$charid'";
In the buy.php to:
Code:
$q = "UPDATE characters SET penya='$total'".
	"WHERE id='$charid'";
I made a small typo. The charid does nor work so you need to change charid to id.
Look at the code boxes.

I do not have that on my buy.php... I'm guessing this is for the other guy who was using an older version. I'm using 2.1 by the way. I might try and use the other buy.php and see if I have any luck.

Thanks.

EDIT

I might as well add my buy.php because either I'm really blind or extremely dumb most probably both, but I can't spot any reason for why I'd get an error.

Code:
<?php

/**
 * @author JuZTiFY
 * @copyright 2008
 */
include "config.php";
$charid = $_POST['character'];
$iid = $_POST['itemid'];
if($charid == ""){
	$e2 = "Don't try anything stupid.";
	header("Location: index.php?error=$e2");
}
$con = mysql_connect($sqlserv, $sqluser, $sqlpass);
mysql_select_db($shopdb);
$query = mysql_query("SELECT * FROM items WHERE itemid='$iid'");
$row = mysql_fetch_array($query);
$price = $row['itemprice'];
mysql_close($con);
$con = mysql_connect($sqlserv, $sqluser, $sqlpass);
mysql_select_db($flyffdb);
$query = mysql_query("SELECT * FROM characters WHERE id='$charid'");
$row = mysql_fetch_array($query);
$penya = $row['penya'];
$total = $penya - $price;
if($total <= 0){
	$e1 = "You dont have enough penya!";
	header("location: index.php?error=$e1");
}
$select = mysql_query("select inventoryslot from inventory where charid = $charid and backpack_number = -1 order by inventoryslot asc");
$found = 'false';
for ($cont = 0; $cont <= 41; $cont++) 
{
	$reg = mysql_fetch_row($select);
	if ($reg[0] != $cont)
	{
		$found = 'true';
		break;
	}
}
if ($found == 'true')
{
	$insere = mysql_query("insert into inventory(itemid, charid, inventoryslot, count, addedByQuestID, backpack_number) values($itemId, $charId, $cont, $quantity, -1, -1)");
	$update = mysql_query("update characters set penya = $penya where id = $charid");
	if (mysql_affected_rows() != 0)
	{
	$e3 = "Item bought Successfully!";
	header("Location: index.php?error=$e3");
	}
	else
	{
		$e4 = "There was an error while buying the item!";
		header("Location: index.php?error=$e4");
	}
}
else
{
	$e3 = "Your inventory is full!";
	header("Location: index.php?error=$e3");
}
?>

EDIT 2

OMG, I am blind and stupid. I finally found
Code:
where charid = $charid
and replaced it with
Code:
where id = $charid

... but it still doesn't work! I still get There was an error while buying the item! :(
 
Back