dominic2708 寫:...不過我覺得這段寫在\r
function UpdateRPGProperties($uid)這個函數內比較方便
我的UpdateRPGProperties 長這樣\r
[php]<?php
function UpdateRPGProperties($uid)
{
global $db;
$attplus = 1.0;
$defplus = 1.0;
$magplus = 1.0;
$spdplus = 1.0;
$hp_plus = 0.0;
$mp_plus = 0.0;
$sql = 'SELECT MAX(position_order) as basetop FROM phpbb_rpg_position WHERE position_class = 0';
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得基礎職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$sql = 'SELECT * FROM phpbb_rpg_position WHERE position_class = 0 AND position_order = ' . $row['basetop'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得基礎職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
// 取得基礎職業的標準值\r
$base_att = $row['attack_property'];
$base_def = $row['defense_property'];
$base_mag = $row['magic_property'];
$base_spd = $row['speed_property'];
$base_hpp = $row['hp_property'];
$base_mpp = $row['magic_property'];
}
$sql = 'SELECT p.* FROM phpbb_rpg_position p, phpbb_rpg_medals m WHERE p.position_class = m.position_class
AND p.position_order = m.position_order AND m.last_class = 1 AND m.position_class <> 0 AND m.user_id = ' . $uid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得專業職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$i = 1;
$newposition = '';
do
{
if ($i == 1)
{
$attplus = $row['attack_property'];
$defplus = $row['defense_property'];
$magplus = $row['magic_property'];
$spdplus = $row['speed_property'];
$hp_plus = $row['hp_property'];
$mp_plus = $row['magic_property'];
$newposition = '<img alt=' . $row['position_name'] . ' src="images/position/' . $row['position_name'] . '.gif">';
}
else
{
$attplus += $row['attack_property'] - $base_att;
$defplus += $row['defense_property'] - $base_def;
$magplus += $row['magic_property'] - $base_mag;
$spdplus += $row['speed_property'] - $base_spd;
$hp_plus += $row['hp_property'] - $base_hpp;
$mp_plus += $row['magic_property'] - $base_mpp;
$newposition .= '<img alt=' . $row['position_name'] . ' src="images/position/' . $row['position_name'] . '.gif">';
}
$i++;
}
while ( $row = $db->sql_fetchrow($result) );
if(strlen($newposition) > 200)
{
$newposition = substr($newposition, 0, 200);
}
}
else
{
// 只有基礎職業
$sql = 'SELECT p.* FROM phpbb_rpg_position p, phpbb_rpg_medals m WHERE p.position_class = 0 AND m.last_class = 1
AND m.position_class = 0 AND p.position_order = m.position_order AND m.user_id = ' . $uid;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, '無法取得基礎職業屬性!!', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$attplus = $row['attack_property'];
$defplus = $row['defense_property'];
$magplus = $row['magic_property'];
$spdplus = $row['speed_property'];
$hp_plus = $row['hp_property'];
$mp_plus = $row['magic_property'];
$newposition = '<img alt=' . $row['position_name'] . ' src="images/position/' . $row['position_name'] . '.gif">';
}
}
}
?>[/php]
總之都可以既然你已經這樣寫....就先試試
還是卡在不能update user_nowjob