From: Anders R. <ma...@us...> - 2004-01-03 12:39:58
|
Update of /cvsroot/planeshift/planeshift/www/serverconsole In directory sc8-pr-cvs1:/tmp/cvs-serv31289/www/serverconsole Modified Files: npc_actions.php viewnpcLeftFrame.php Log Message: - Added edit of training areas to the npc edit in the admin tool. Index: npc_actions.php =================================================================== RCS file: /cvsroot/planeshift/planeshift/www/serverconsole/npc_actions.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** npc_actions.php 2 Dec 2003 16:15:01 -0000 1.14 --- npc_actions.php 3 Jan 2004 12:39:55 -0000 1.15 *************** *** 112,120 **** echo "<TR><TD><INPUT type=submit name=save value=save></TD><TD></TD></TR>"; echo "</TABLE></FORM>"; ! ! echo "<br><br><A HREF=\"viewnpc.php?id=$id\" target=_top>Reload the tree</A>"; ! ! echo "<br><br><A HREF=\"listnpcs.php\" target=_top>Go back to list of available NPCs</A>"; ! /** * edit main info of an NPC --- 112,116 ---- echo "<TR><TD><INPUT type=submit name=save value=save></TD><TD></TD></TR>"; echo "</TABLE></FORM>"; ! /** * edit main info of an NPC *************** *** 574,578 **** $id = $_GET['responseid']; ! $query = "select response1, response2, response3, response4, response5 from npc_responses where id=$id"; $result = mysql_query( $query ); --- 570,574 ---- $id = $_GET['responseid']; ! $query = "select response1, response2, response3, response4, response5, script from npc_responses where id=$id"; $result = mysql_query( $query ); *************** *** 588,591 **** --- 584,588 ---- echo "<TR><TD><b>Response 4:</b></TD><TD><textarea name=response4 rows=3 cols=50>$line[3]</textarea></TD></TR>"; echo "<TR><TD><b>Response 5:</b></TD><TD><textarea name=response5 rows=3 cols=50>$line[4]</textarea></TD></TR>"; + echo "<TR><TD><b>Script :</b></TD><TD><textarea name=script rows=3 cols=50>$line[5]</textarea></TD></TR>"; echo "<TR><TD><input TYPE=SUBMIT NAME=submit VALUE=edit></TD><TD></TD></TR>"; } *************** *** 603,608 **** $response4 = $_POST['response4']; $response5 = $_POST['response5']; ! $query = "update npc_responses set response1='$response1', response2='$response2', response3='$response3', response4='$response4', response5='$response5' where id=$id"; $result = mysql_query( $query ); echo "$query"; --- 600,606 ---- $response4 = $_POST['response4']; $response5 = $_POST['response5']; + $script = $_POST['script']; ! $query = "update npc_responses set response1='$response1', response2='$response2', response3='$response3', response4='$response4', response5='$response5', script='$script' where id=$id"; $result = mysql_query( $query ); echo "$query"; *************** *** 1081,1085 **** --- 1079,1179 ---- <?PHP + /** + * view trainer skills of an NPC + */ + } else if ($operation=="viewtrainer") { + + $id = $_GET['npcid']; + + $query = "select t.skill_id, s.name, t.min_rank, t.max_rank, t.min_faction from skills s, trainer_skills t where t.skill_id=s.skill_id and player_id=" . $id; + $result = mysql_query( $query ); + $found = 0; + + echo "<b>Training Skills present in this NPC: </b>"; + echo "<p>A NPC will only train a player in the given skills, "; + echo "within the given rank range and if the faction between "; + echo "trainer and player is bether than Min faction.</p>"; + + echo "<table border=1><th>Skill</th><th>Min Rank</th><th>Max Rank</th><th>Min Faction</th><th></th>"; + while ($line = mysql_fetch_array($result, MYSQL_NUM)) + { + echo "<TR><TD><b>$line[1]</b>: </TD><TD>$line[2]</TD>"; + echo "<TD>$line[3]</TD><TD>$line[4]</TD>"; + echo "<TD><FORM action=npc_actions.php?operation=edittrainer&npcid=$id&subop=del&itemid=$line[2] METHOD=POST><INPUT type=submit name=submit value=Delete></FORM></TD></TR>"; + $found = 1; + } + echo "</TABLE><br><br>"; + + if ($found==0) { + echo "No training skills present in this NPC.<br><br>"; + } + + echo "<b>Add/Replace a Training Skill to this NPC: </b><br><br>"; + + echo "<FORM action=npc_actions.php?operation=edittrainer&npcid=$id&subop=add METHOD=POST>"; + $query = "select skill_id,name from skills "; + $result = mysql_query( $query ); + + echo "<table><th>Skill</th><th>Min Rank</th><th>Max Rank</th><th>Min Faction</th><th></th>"; + echo "<tr><td><SELECT name=itemid>"; + while ($line = mysql_fetch_array($result, MYSQL_NUM)) + { + echo "<OPTION value=$line[0]>$line[1]</OPTION>"; + $found = 1; + } + echo "</SELECT></td>"; + echo "<TD><INPUT type=text name=min_rank></td>"; + echo "<TD><INPUT type=text name=max_rank></td>"; + echo "<TD><INPUT type=text name=min_faction></td>"; + echo "<td><INPUT type=submit name=submit value=Add></td></tr></table></FORM>"; + + /** + * edit trainer skills of an NPC + */ + } else if ($operation=="edittrainer") { + + $id = $_GET['npcid']; + + $subop = $_GET['subop']; + + if ($subop=="del") { + + $skillid = $_GET['itemid']; + + $query = "delete from trainer_skills where skill_id=$skillid and player_id=$id"; + $result = mysql_query( $query ); + + // redirect + ?><SCRIPT language="javascript"> + document.location = "npc_actions.php?operation=viewtrainer&npcid=<?=$id?>"; + </script> + <?PHP + + } else if ($subop=="add") { + + $skillid = $_POST['itemid']; + $min_rank = $_POST['min_rank']; + $max_rank = $_POST['max_rank']; + $min_faction = $_POST['min_faction']; + + // First delete trainer skill + + $query = "delete from trainer_skills where skill_id=$skillid and player_id=$id"; + $result = mysql_query( $query ); + + // Update with new + $query = "insert into trainer_skills values($id, $skillid, $min_rank, $max_rank, $min_faction)"; + $result = mysql_query( $query ); + + // redirect + ?><SCRIPT language="javascript"> + document.location = "npc_actions.php?operation=viewtrainer&npcid=<?=$id?>"; + </script> + <?PHP + } else { + echo "Operation $operation supported, suboperation $subop not supported."; + } + } else { *************** *** 1087,1090 **** --- 1181,1188 ---- echo "Operation $operation not supported."; } + + echo "<br><br><A HREF=\"viewnpc.php?id=$id\" target=_top>Reload the tree</A>"; + + echo "<br><br><A HREF=\"listnpcs.php\" target=_top>Go back to list of available NPCs</A>"; ?> Index: viewnpcLeftFrame.php =================================================================== RCS file: /cvsroot/planeshift/planeshift/www/serverconsole/viewnpcLeftFrame.php,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** viewnpcLeftFrame.php 28 Nov 2003 23:00:48 -0000 1.9 --- viewnpcLeftFrame.php 3 Jan 2004 12:39:55 -0000 1.10 *************** *** 81,84 **** --- 81,87 ---- echo "temp5 = insDoc(foldersTree, gLnk(\"R\", \"items\", \"npc_actions.php?operation=viewitems&npcid=$id\"));\n"; + // output training node + echo "temp6 = insDoc(foldersTree, gLnk(\"R\", \"trainer\", \"npc_actions.php?operation=viewtrainer&npcid=$id\"));\n"; + // output knowledge folder echo "aux1 = insFld(foldersTree, gFld(\"specific knowledge\", \"npc_actions.php?operation=viewka&type=npc&area=$area\"));\n"; |