Post Pacific  

Go Back   Post Pacific > Восстановленный архив > Темы без сохранившегося раздела

Notices

 
 
Thread Tools Search this Thread Display Modes
Old 29.01.2007, 13:45   #1
yokohiro
Архивный участник
 
Join Date: Jan 2007
Posts: 18
Default question EXE lin...

Hi to all! I found an article here in the explained forum as add adena in char. I tried to make with another one procedure that I found. more it is generating an error…. could speak to me where is the error? I go to post scripts to facilitate.

precedure: lin_BetaAddItem

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

/****** Object: Stored Procedure dbo.lin_BetaAddItem Script Date: 2003-09-20 ?? 11:51:56 ******/
ALTER PROCEDURE [dbo].[lin_BetaAddItem]
(
@char_id int,
@Item_type int,
@amount int
)
AS

SET NOCOUNT ON

DECLARE @tempRowCount INT
DECLARE @bIsStackable TINYINT
SELECT @bIsStackable = IsStackable FROM ITEMNAME WHERE id = @Item_type

If @bIsStackable Is NULL
Begin
RAISERROR ('Not exist Item Type', 16, 1)
End
Else
Begin
If @bIsStackable = 1
Begin
Update user_item set amount = amount + @amount where item_type = @Item_type and char_id = @char_id
Set @tempRowCount = @@ROWCOUNT
If @tempRowCount = 0
INSERT INTO user_item (char_id, item_type, amount, enchant, eroded, bless, ident, wished, warehouse) VALUES (@char_id, @Item_type, @amount, 0,0,0,0,0,0)
End
Else If @amount = 1
Begin
INSERT INTO user_item (char_id, item_type, amount, enchant, eroded, bless, ident, wished, warehouse) VALUES (@char_id, @Item_type, @amount, 0,0,0,0,0,0)
Set @tempRowCount = @@ROWCOUNT
End
Else
Begin
RAISERROR ('Amount is invalid', 16, 1)
End
End

If @tempRowCount Is NOT NULL
Select @tempRowCount



==================
script PHP by: DiAvOl
Code:
<?
/* PHP script with HTML code
   for adding adena to a character 
   2005 - DiAvOl
*/

session_start();

/* Replace xxx.xxx.xxx.xxx with your mssql host
   Replace sql_user with your mysql username and
   password with your mssql password
*/

$mssql_host = 'xx.x.0.1';
$mssql_user = 'sa';
$mssql_pass = '';

/* Add here a description and an IP of a host which you allow 
   to use this page and add adena to a character
   Example: 'home'=>"1xx.xx.2.143", 'work'=>"2xx.xx1.xx.xx" etc
*/ 

$store_cashier = array('local'=>"127.0.0.1", 'pc2'=>"1xx.xx8.0.1");

$store = "";

foreach ($store_cashier as $key=>$value) {
	$rip = $_SERVER['REMOTE_ADDR'];
	if ($rip == $value) { $store = $key; } 
}

if ($store != "") {
	$_SESSION['store'] = $store;
} else {
	die("You are not permitted to view this page, actually who gave you this url?");
}

function antiinjection($str) {
	$banwords = array ("'", ",", ";", "--");
	if ( eregi ( "[a-zA-Z0-9]+", $str ) ) {
		$str = str_replace ( $banwords, '', strtolower ( $str ) );
	} else {
		$str = NULL;
	}
	return $str;
}
?>
<html>
<head>
<title>Lineage II Adena Managment</title>
<style>
.style1 {
	font-family:Verdana, Arial, Helvetica, sans-serif;
	font-size:14px;
}
.formPaneGeneral {
	font: normal 12pt/10px Verdana, sans-serif;
	background:#F2FDFF;
	border: 1px groove #6600FF;
	vertical-align: middle;
}
.formButtonGeneral {

	font: 9pt/10pt Verdana, sans-serif;
	color:#333333;
	background:#F2FDFF;
	border: 1px solid #666666;
}

.border {
	border: 1px groove #000000;
}
</style>
</head>
<body topmargin="150" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#CCCCCC">
<div align="center">
<table cellpadding="0" cellspacing="0" border="1" bgcolor="#FFCC33">
	<tr>
		<td align="center" bgcolor="#000000">
		<font face="Geneva, Arial, Helvetica, sans-serif" size="+1" color="#FFFFFF">ADENA MANAGMENT</font>		
		</td>
	</tr>
	<tr>
		<td>
<form name="addadena" method="post" action="addadena.php">
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td align="center" colspan="2" bgcolor="#FFCC99" class="border">
<?
	$error = 0;
	$noname = FALSE;
	$noamount = FALSE;
	
	if ($_POST['action']) {
	
	if ($_POST['charname']) { $character_name = antiinjection($_POST['charname']); }
	else { echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">- Please insert a character name</font>
"; $error=1; $noname = TRUE; }

if ($_POST['item_type']) { $item_type = antiinjection($_POST['item_type']); }
	else { echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">- Please insert a item id</font>
"; $error=1; $noitem = TRUE; }


	if ($_POST['amount']) { $amount = antiinjection($_POST['amount']); }
	else { echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">- Please insert adena amount</font>
"; $error=2; $noamount = TRUE; }
	}
	
	if (($error == 0) && $_POST['action']) {
	
	$connection = mssql_connect($mssql_host,$mssql_user,$mssql_pass);
	if ($connection) {
		mssql_select_db('lin2world',$connection); 
		$query = mssql_query("EXEC lin_BetaAddItem '$character_name', $item_type, $amount");
		$arr = mssql_fetch_array($query);
		$last_msg = mssql_get_last_message();
		if (empty($last_msg) && empty($arr['amount'])) {
			echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">Account does not exists</font>";
			mssql_close($connection);
		} else if(empty($arr['amount'])) {
			echo "<font face=\"Times New Roman, Times, serif\" color=\"#FF0000\">-$last_msg</font>";
			mssql_close($connection);
		} else {
		echo "<font face=\"Times New Roman, Times, serif\" color=\"#0000FF\">{$amount} adena added to $character_name
Total: {$arr['amount']} adena</font>"; }
		mssql_close($connection);
	} else { 
		echo "Can't connect to the database"; }
	}

?>
		</td>
	</tr>
	<tr>
		<td align="right" height="30">
		<span class="style1"> <? echo ($noname?"<font color=\"#FF0000\">Character Name</font>" : "Character Name"); ?></span>
		</td>
		<td align="left" width="150">
		<input type="text" name="charname" size="15" maxlength="15" class="formPaneGeneral" value=<? echo ($_POST['charname'] ? $_POST['charname'] : "" ); ?> >
		</td>
	</tr>
	<tr>
		<td height="5">
		</td>
	</tr>
	
	<tr>
		<td align="right" height="30">
		<span class="style1"> <? echo ($noitem?"<font color=\"#FF0000\">Id Item</font>" : "Item Type"); ?></span>
		</td>
		
	<td align="left" width="150">
		<input type="text" name="item_type" size="15" maxlength="15" class="formPaneGeneral" value=<? echo ($_POST['item_type'] ? $_POST['item_type'] : "" ); ?> >
		</td>
	</tr>
	<tr>
		<td height="5">
		</td>
	</tr>
	
	<tr>
		<td align="right">
		<span class="style1"><? echo ($noamount?"<font color=\"#FF0000\">Adena amount</font>" : "Adena amount"); ?></span>
		</td>
		<td align="left">
		<input type="text" name="amount" size="15" maxlength="15" class="formPaneGeneral" value=<? echo ($_POST['amount'] ? $_POST['amount'] : "" ); ?>>
		</td>
	</tr>
	<tr>
		<td>
		
		</td>
		<td align="left" height="30">
		<input type="submit" name="submit" value="Add Item" class="formButtonGeneral">
		<input type="hidden" name="action" value="action">
		</td>
	</tr>
</table>
		</td>
	</tr>
	<tr>
		<td height="15" bgcolor="#000000">
		</td>
	</tr>
</table>
</form>
</div>
</body>
</html>

font: https://postpacific.loc-online.com/f...nsert+item+php

thanks a lot to all
yokohiro is offline  
Old 29.01.2007, 14:36   #2
FidoW
Архивный участник
 
Join Date: Sep 2005
Posts: 1,014
Default

maybe itemname table ?... and you can add an item using database but if the character has logged since the last restart have no effect until the next restart.
The best way is using interactive cached port, is instant (but char need to be logout), look for info about cached ... even.. someone create a script to make it... good for leechers :P
FidoW is offline  
Old 29.01.2007, 14:53   #3
yokohiro
Архивный участник
 
Join Date: Jan 2007
Posts: 18
Default

Quote:
Originally Posted by FidoW View Post
maybe itemname table ?... and you can add an item using database but if the character has logged since the last restart have no effect until the next restart.
The best way is using interactive cached port, is instant (but char need to be logout), look for info about cached ... even.. someone create a script to make it... good for leechers :P

… and as it would be this well? it could help me in this subject?
yokohiro is offline  
Old 29.01.2007, 15:30   #4
yokohiro
Архивный участник
 
Join Date: Jan 2007
Posts: 18
Default

I developed one script where it inserts the item in warehouse of char. however it is not functioning correctly, pos the item cannot be removed of warehouse. I go post code to facilitate


Code:
<meta http-equiv="refresh" content="3;URL=index.php">
<? 
//include "session.php";
$ip="127.0.0.1"; 
$user="sa";
$pass="";
$db="lin2world";

$conn=mssql_connect($ip,$user,$pass); 
mssql_select_db($db, $conn); 

$idchar = $_POST["idchar"];
$nqtd = $_POST["nqtd"];
$item_id = $_POST['item_id'];
//$local = $_POST['local'];

$query1 = mssql_query("select warehouse from user_item where char_id='$idchar' and item_type='$item_id'");
$result1 = mssql_num_rows($query1);
//$result2 = mssql_fetch_array($query1);

$qtd = mssql_result($query1,0,"warehouse");
		$nqtd = $nqtd+$qtd;
	if ($result1 !=0)
		{
			$rsalterar = mssql_query("update user_item set char_id='$idchar', item_type='$item_id',amount='0',enchant='0', eroded='0', bless='0', ident='0', wished='0', warehouse='$nqtd' where item_type='$item_id' and char_id='$idchar'");
			echo "<center><font face=verdana size=2 color=green>Tickets Entregues com sucesso!</font></center>";
		}
	else
		{
		$query = mssql_query("insert into  user_item (char_id, item_type, amount, enchant, eroded, bless, ident, wished, warehouse) values ('$idchar','$item_id','0','0','0','0','0','0','$nqtd')"); 
			echo "<center><font face=verdana size=2 color=green>Tickets Entregues com sucesso!</font></center>";
	
		}
$conn=mssql_close(); 
?>


what he will be that this making a mistake?
yokohiro is offline  
Old 29.01.2007, 15:59   #5
FidoW
Архивный участник
 
Join Date: Sep 2005
Posts: 1,014
Default

I cant understand why you do this --> $qtd = mssql_result($query1,0,"warehouse");

And later... that query... LOL...

update user_item
set char_id='$idchar', item_type='$item_id',amount='0',enchant='0', eroded='0', bless='0', ident='0', wished='0', warehouse='$nqtd'
where item_type='$item_id' and char_id='$idchar'

you are updating all the fields, but not only that... warehouse field... must be 0 or 1... 0 for inventary, 1 for warehouse..

umm.. now i took a look again i think your mistake is you think warehouse field is amount of the item in warehouse...


Try with this (im not try to test the code, i only fast rewrite all the issues i see)

Code:
<? 

$ip="127.0.0.1"; 
$user="sa";
$pass="";
$db="lin2world";

$conn=mssql_connect($ip,$user,$pass); 
mssql_select_db($db, $conn); 

$idchar = $_POST["idchar"];
$nqtd = $_POST["nqtd"];
$item_id = $_POST['item_id'];

$result = mssql_query("SELECT amount,item_id FROM user_item WHERE char_id = $idchar AND item_type = $item_id AND warehouse = 1);

$rows = mssql_num_rows($result);
$dbamount = mssql_result($result, 0, 0);
$dbitemid = mssql_result($result, 0, 1);

$nqtd = $nqtd+$dbamount;

if ($dbamount > 0) {
  mssql_query("UPDATE user_item SET amount = $nqtd WHERE item_id = $dbitemid");
  echo "<center><font face=verdana size=2 color=green>Tickets Entregues com sucesso!</font></center>";
}
else {
  mssql_query("INSERT INTO user_item (char_id, item_type, amount, enchant, eroded, bless, ident, wished, warehouse) values ($idchar,$item_id,$nqtd,0,0,0,0,0,1)"); 
  echo "<center><font face=verdana size=2 color=green>Tickets Entregues com sucesso!</font></center>";
}

$conn=mssql_close(); 

?>
FidoW is offline  
Old 31.01.2007, 10:52   #6
horokussaky
Архивный участник
 
Join Date: Jan 2007
Posts: 1
Default

thx brother...
horokussaky is offline  
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 19:22.