From b49c6a6a49ef992198302033b1f176a72c1299d6 Mon Sep 17 00:00:00 2001 From: radiskull Date: Thu, 1 Dec 2011 19:21:36 +0000 Subject: [PATCH] =?UTF-8?q?#21=20fertig=20gestellt.=20Drops=20k=C3=B6nnen?= =?UTF-8?q?=20nun=20auch=20eingestellt=20werden!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ag/gm/include/npc.inc.php | 104 +++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 12 deletions(-) diff --git a/ag/gm/include/npc.inc.php b/ag/gm/include/npc.inc.php index 2ed0396..e1b690f 100644 --- a/ag/gm/include/npc.inc.php +++ b/ag/gm/include/npc.inc.php @@ -19,6 +19,41 @@ defineIfNotDefined('TASK_EDIT', 'dochange'); defineIfNotDefined('TASK_CREATE', 'docreate'); defineIfNotDefined('NPC_USER_NAME', 'animegame-npc'); +function getDropItemsAsOptions(){ + $result = NULL; + $index = 0; + // Die etwas abgewandelten SQL-Querys aus dem auktion_functions.php + $query = 'SELECT id, name, \'ware\' as tablename FROM item i WHERE s_type = \'Trank\' + union + SELECT id, name, \'sp_ware\' as tablename FROM sp_item i + union + SELECT id, item AS name, \'wochen_ware\' as tablename FROM wochen_markt w;'; + + $qry = mysql_query($query); + // Damit waeren alle noetigen Datenbankaufrufe erledigt! + while($row = mysql_fetch_assoc($qry)){ + $result[$index++] = ''; + } + + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + $result[$index++] = ''; + + return $result; +} + +function istrinstr($source, $insert, $search) { + $pos = strpos($source, $search); + $newstr = substr($source, 0, $pos).$insert.substr($source, $pos); + return $newstr; +} + function getNPCUser() { $qry = mysql_query('SELECT * FROM user WHERE nickname = "'.NPC_USER_NAME.'";'); return mysql_fetch_assoc($qry); @@ -105,13 +140,15 @@ function displayNPCInfo($action, $task, $charid) { 'Ausdauer', 'Glück', 'Kampfdauer in Sekunden', 'Level', 'Min-Level', 'Max-Level', 'Bild'); $attset = array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1); $attset_names = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); + $drop_items = getDropItemsAsOptions(); + //initialisieren falls editiert wird (dort existieren schon Inhalte) if($task == TASK_EDIT) { $attset = getCharAttackSet($charid, NORMALKAMPF); $attset_names = getAttackNamesFromAttackSet($attset); - //$sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid; - $sql = 'SELECT * FROM chars c inner join kampf_list kl on c.id = kl.charakter WHERE c.id ='.$charid; + $sql = 'SELECT * FROM chars c inner join npc_item ni on ni.charakter = c.id inner join kampf_list kl on ni.charakter = kl.charakter WHERE c.id ='.$charid; + //$sql = 'SELECT * FROM chars c inner join kampf_list kl on c.id = kl.charakter WHERE c.id ='.$charid; $qry = mysql_query($sql); $row = mysql_fetch_assoc($qry); } @@ -145,6 +182,27 @@ function displayNPCInfo($action, $task, $charid) { } } + //dropitems + echo "\t".'Drop'."\n"; + echo "\t\t".'Item'."\n"; + echo "\t\t".'Anzahl'."\n"; + echo "\t\t".'maximale Wiederholungen'."\n"; + echo "\t\t".'Preis'."\n"; + //attacken informationen echo "\t".'Attacken bearbeiten'."\n"; for($i = 1;$i<11;$i++){ @@ -155,6 +213,7 @@ function displayNPCInfo($action, $task, $charid) { } echo ''."\n"; } + //menü echo "\t".''."\n"; echo "\t".'NPC Übersicht'."\n"; @@ -167,7 +226,7 @@ function editNPC($charid, $data, $att_ids) { $d_array = array('name', 'type', 'hp', 'mp', 'starke', 'verteidigung', 'speed', 'ausdauer', 'glueck', 'level', 'bild'); - $sql = 'UPDATE chars c INNER JOIN kampf_list kl ON c.id=kl.charakter SET c.'; + $sql = 'UPDATE chars c INNER JOIN kampf_list kl ON c.id=kl.charakter INNER JOIN npc_item n ON c.id=n.charakter SET c.'; $sql .= $d_array[0].' = \''.encodeNoHTMLWithBB($data[$d_array[0]]).'\''; for($i=1;$i $value) { + if($value == NULL) { + echo 'fehler dude! bei '.$key; } else { - $info = encodeNoHTMLWithBB($info); + $value = encodeNoHTMLWithBB($value); } } @@ -235,6 +303,18 @@ function createNPC($data, $att_ids) { $data['zeit_rec'].','.$data['lvlmax'].',0,'.$data['lvlmin'].');'; mysql_query($sql); + //drops hinzufügen :D + $sql = 'INSERT INTO npc_item(charakter,item,feld,mal,datensatz,wieviel,preis) VALUES('.$char_id; + $info = explode(',', $data['drop']); + if($info[1] == 'chars') { + $sql .= ',0,\''.$info[0].'\''; + } else { + $sql .= ','.$info[0].',\'\''; + } + $sql .= ','.$data['drop_max'].',\''.$info[1].'\','.$data['drop_anzahl'].','.$data['preis'].');'; + echo $sql; + mysql_query($sql); + //Attacksets soweit einbinden $attset = buildAttackSet($char_id, $att_ids); $error = validateAttackSetTypes($attset); @@ -315,7 +395,7 @@ function displayNPCOverview($page) { $total = mysql_num_rows(mysql_query('SELECT '.join($d_array,',').' from chars where rasse = \'NPC\'')); $url = '###LABEL###'; echo "\t".''.displayPagelinksNew(20, $total, $page, $url).''."\n"; - + echo "\t".'Create a new NPC'."\n"; echo "\t".'
'."\n"; }