PDA

View Full Version : PHP add adena to a character


diavolos
22.04.2005, 12:04
Guys is there any way of adding adena to a character via php ?
I know it will need restart server to take effect but this is no prob.
Any help appreciated

Thanks

Michelle
22.04.2005, 13:00
Of course it s possible man, and the fact is it s really easy :) Go to google and search some php course, check out some code with JOIN command and some basic code, and u done. Believe me, anyone can make it :D . Good luck dude!

Sakumi
22.04.2005, 15:31
When im working on my php page today ill see if i can make u a quick input page based off chracter ID

Enishi
22.04.2005, 15:48
I'd like to get my hands on this as well :D

diavolos
22.04.2005, 17:52
I know php, and I know sql the problem is that I don't know l2 databases schema that's why I'm asking

Riane
22.04.2005, 23:17
i dont know the schema either, but its something like this:
(i'd add it to warehouse, dont think server will need to reboot then)
query=select from warehouse where itemname = adena && user = $user
if(query)
update warehouse set amount = amount + $newamount where ''
else
insert into warehouse (user, item, amount) values ($user, adena, $newamount)

something like this should be working i guess, but i'd have to look at sql tables to check it

RmzVoid
23.04.2005, 00:21
then server running adding exp and items to character not work, caching works, and changes in db dont affect on character until you dont stop server -> make changes -> start server

Michelle
24.04.2005, 18:20
SQL-lin2world-...
User_data : check out the character ID
User_item : in this table, there is a field of character ID, and a field of item ID ( Adena' ID is 57 ).
Join these two tables, and put some query and blah, blah, blah :) Hope it will help...
And 2 Riane , data og item in warehouse also in user_item ( in that table there is a field name warehouse , and his value is the number of the item in warehouse )
P/s : Sometimes i can add item and modify my data without restart my server. Dun know why :D

vaskes
24.04.2005, 23:12
if info cached - your changes to mssql database will be reverted

query must be something like this

if exists (select * from user_item where char_id = @char_id and item_type = 57 and warehouse = 1)
update user_item set amount = amount+1000000 where char_id = @char_id and item_type = 57 and warehouse = 1)
else
insert into user_item (char_id, item_type, amount, enchant, eroded, bless, ident, wished, warehouse) values (@char_id, 57, 1000000, 0, 0, 0, 0, 0, 1)

diavolos
25.04.2005, 18:29
so there isn't a way to enforce sql changes at all ?

Riane
25.04.2005, 21:09
the player gotta be logged off the server, then it should work too, shouldnt it?
(you could just kick the player out before the query ;P )

astranger
25.04.2005, 22:10
the player gotta be logged off the server, then it should work too, shouldnt it?
(you could just kick the player out before the query ;P )

No even if the player is offline (or kicked :P) the change will not take effect (some ppl reported this to work sometimes) but as many times as I've tried changes won't take effect. There should be a way to enforce re-read of sql changes (the way l2admin works)

astranger
25.04.2005, 22:46
Here is the php script for adding adena to a character


<?
/* 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 = 'xxx.xxx.xxx.xx';
$mssql_user = 'sql_user';
$mssql_pass = 'password';

/* 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'=>"xxx.xxx.xxx.xxx");

$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['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_GetIdSetAmmount '$character_name', $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">
<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 Adena" 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>

astranger
25.04.2005, 22:49
and here is the stored procedure which you should add in lin2_world

/********************************************
lin_GetIdSetAmount
Set the adena amount for a user
INPUT
@char_name nvarchar(50)
@amount INT
OUTPUT
return
made by
DiAvOl
date
2005-04-25

DETAILS
Checks if the user provided is online, if not changes
will take effect, else an error message will be returned
********************************************/

CREATE PROCEDURE [DBO].[lin_GetIdSetAmmount] ( @char_name nvarchar(50), @amount INT)
AS
SET NOCOUNT ON

DECLARE @char_id INT
DECLARE @isonline INT

SET @isonline = (SELECT char_id FROM user_data WHERE login > logout AND char_name = @char_name)

IF @isonline IS NULL
BEGIN
SET @char_id = (SELECT TOP 1 char_id FROM user_data WHERE char_name = @char_name)
exec lin_AdenaChange @char_id, @amount
END
ELSE
BEGIN
print 'Character is Online, Cannot add adena right now'
END
GO

astranger
25.04.2005, 22:54
it would be great if anyone can find a way to enforce sql changes

Livid
26.04.2005, 08:38
U can use L2atl.

Mr.Ravya
26.04.2005, 11:00
Can anyone post manual how can i use l2atl and for what this? Sorry for my dumb question. But in my server i write my own admin panel in PHP and all changes have effect if i reboot server... it is really not comfortable

Livid
26.04.2005, 11:44
https://postpacific.mmorpg-game.online/forum/viewtopic.php?p=3520
Here's some info...