飞飞世界论坛

标题: 物品发送脚本 [打印本页]

作者: admin    时间: 2016-1-10 03:43
标题: 物品发送脚本
<?php& c% N  [- }, e0 N: J) A
function Connect () {  v# S, [( J( `! ~5 a) |3 e
mssql_connect('Server','UserName','Password') or die('Error: Connection to DB
# x0 I! h( B8 J' f  n' ]( h+ r% ^9 H, s2 n. T( U4 D3 V& r
Failed.');
, b; H  l  u1 v5 Z}
  @, F5 v9 U! n! VConnect();
2 E- R( `  F) c2 C( A
0 r  k; Y5 B- `8 m( }function InitForm(){
1 h# k1 H, N& V1 Z) ]$ g//layout for the form* f# ^  g! H2 y% Y* r
echo "<strong>Send Items.</strong>9 _; q& d& f5 j6 ]( W( M! o; q
<form name='select' method='post'>  y* l2 a3 \* ]5 x9 w
<lable>Character Name</lable><br/>
% X7 W1 j3 s  K# L6 h; ?2 A# D<input type='text' name='char'/><br/>; x' H- W- V& N: ?/ R
<lable>Item Name (Needs to be Exact or can use Item ID.)</lable><br/>4 _; V$ ^' z% f0 i) `
<input type='text' name='item_name'/><br/>
, q0 X# a5 t3 }1 O<lable>Item Amount</lable><br/>
' A$ y* V$ W+ ?* K# A<input type='text' name='item_amount'/><br/>/ i6 b, U8 E- |: I1 U
<lable>Item Upgrade Amount</lable><br/>
$ m  d, m) Y* T, d4 B2 o$ o<input type='text' name='item_upgrade'/><br/>
: t' b" u5 F. M0 C- e! O; r- n* v3 i<lable>Element Type.(0-None, 1-Fire, 2-Water, 3-Electricity, 4-Wind, 5-Earth.)5 k; ?: h0 G) j6 a0 d4 H

; a) S$ l3 h1 s" X/ m5 S</lable><br/>
0 U2 V! J' y3 M) H* Z: L<input type='text' name='item_element'/><br/>& S6 g; \% {, s8 Y# {
<lable>Element Upgrade Amount</lable><br/>" R  V( \  u6 Q& k0 W% M5 Z! N2 t
<input type='text' name='element_upgrade'/><br/>
3 W& q: C2 C6 T! H4 S<lable>Pierced Amount</lable><br/>
8 u! Z' F' k+ `* V' K0 i<input type='text' name='item_pierce'/><br/>
) J5 u* K* x9 b% \0 G0 |<input type='submit'/># S- d! \6 g6 W: L/ v0 D- m
</form>";* k( T" M3 G$ ?' A* u6 v
}+ o- y; D. l8 T$ w9 \

4 K5 M1 u; N6 efunction PostListener (){2 C2 T3 q# B1 v* n
//Add more post variables if needed and add them to initform() function aswell2 _- Y  ^' s9 f
- k6 r3 l& H' [& I
################################
9 p0 R) S" O2 y) U+ s% @4 g8 @6 j##### Connection and Post ######
- S6 g# M% J1 z' k9 h; C7 j/ w################################
  @) C! L. m& z  C$name = @$_POST['char'];4 @: A6 x7 E2 ~5 m1 y! f
$ItemName = @$_POST['item_name'];
% [3 F7 {0 v6 D$ l2 u4 z1 f$ItemAmount = @$_POST['item_amount'];
' q! F8 Q% R- R  l. [$ h% R$ItemId = @$_POST['item_id'];
: ^- r# Z* E1 Z" ~+ u$ItemUpgrade = @$_POST['item_upgrade'];
8 ], r7 r- j, W" S: {$ItemElement = @$_POST['item_element'];+ w* n8 D/ E" r
$ElementUpgrade = @$_POST['element_upgrade'];6 C1 p) n7 Y9 X. w/ B, j, Z" E, h
$ItemPierce = @$_POST['item_pierce'];& c- Z$ ]- q2 h7 P: n1 S( M9 z
################################
- R; j( D1 M/ A* h$ h* i* h4 D! L  ~; |; F" U$ z" m7 o" w+ A0 i
//Check both variables for empty value  V% D% h4 j5 g

- S2 Q1 @4 x+ o% a% C) Nif (!empty($_POST['char'])){
- D# h4 h& \4 G7 Z$ O: _5 A+ R3 a$ M& K$find = mssql_query("select * from [CHARACTER_01_DBF].[dbo].[CHARACTER_TBL] where $ g1 u( M6 o' r

% l$ {% f' U% ^! n+ mm_szName = '{$name}'");
9 H( c5 G) c! j8 O/ o* c) [/ x: w5 Uwhile ($row = mssql_fetch_object($find)){8 P# J1 c6 L# ~3 |
echo "You Just Sent {$ItemAmount} {$ItemName}(s) to {$name}<br>";
7 [& ]: }: l5 |3 S3 F, r$logs = mssql_query("INSERT INTO CHARACTER_01_DBF.dbo.ITEM_SEND_TBL([m_idPlayer],
4 H& R. k" j! g, F
. a6 p1 Q3 s0 x! N[serverindex], [Item_Name], [Item_count], [idSender], [m_nAbilityOption],
' z% n/ }. {2 P! v' q: {- @- z3 c0 V- n
[m_bItemResist], [m_nResistAbilityOption], [nPiercedSize]) VALUES(N'$row->m_idPlayer',
! L* D1 a; w6 n, {0 P; h: ]! y0 h2 [+ H2 [: O0 M
N'01', N'{$ItemName}', '{$ItemAmount}', N'0000001', '{$ItemUpgrade}', '{$ItemElement}',
. L7 C# c: D* m5 _& `" t' U* E2 }  b
& i% d" ^' g5 H1 U, \+ ]% j'{$ElementUpgrade}', '{$ItemPierce}');");) C) s: B. K4 j6 L! q0 L) t* k5 c# h
}. F7 a) ~: T( E& b
. W1 `0 A  e( G/ v
}1 K0 {( Y1 G. I5 z! c& V& \. v& X. V2 a
  `6 A; L% f  b& l2 _. p
}, Z3 f8 G3 _: {6 w+ I5 J3 M7 A
* A) M4 O4 L/ A0 u
$InitForm = InitForm();# p  O" f' b( n$ x8 _8 v8 w  S
$Listener = PostListener();/ f5 o. @$ p" w/ {+ X1 F

/ T6 B  ~" [  N& _?>
1 D5 h2 l/ k) ]( ?% y# r( d$ K0 A
) N2 }$ ]- s% u/ T
7 g) u4 Z( T: b# O$ z* C+ q5 i3 T" C7 i% y0 r! I- }
  k: ]0 j% d2 U' p9 \





欢迎光临 飞飞世界论坛 (http://www.ffwold.com/) Powered by Discuz! X3.2