0) ? ", " : "") . "$key='$val'"; $keys .= (($i > 0) ? ", " : "") . "$key"; $vals .= (($i > 0) ? ", " : "") . "'$val'"; $i++; } if ($id>""){ $sql="UPDATE " . db_prefix("companions") . " SET $sql WHERE companionid='$id'"; }else{ $sql="INSERT INTO " . db_prefix("companions") . " ($keys) VALUES ($vals)"; } db_query($sql); invalidatedatacache("companiondata-$id"); if (db_affected_rows()>0){ output("`^Companion saved!`0`n`n"); }else{ // if (strlen($sql) > 400) $sql = substr($sql,0,200)." ... ".substr($sql,strlen($sql)-200); output("`^Companion `\$not`^ saved: `\$%s`0`n`n", $sql); } } } elseif ($subop=="module") { // Save modules settings $module = httpget("module"); $post = httpallpost(); reset($post); while(list($key, $val) = each($post)) { set_module_objpref("companions", $id, $key, $val, $module); } output("`^Saved!`0`n"); } if ($id) { $op="edit"; } else { $op = ""; } httpset("op", $op); } if ($op==""){ $sql = "SELECT * FROM " . db_prefix("companions") . " ORDER BY category, name"; $result = db_query($sql); $ops = translate_inline("Ops"); $name = translate_inline("Name"); $cost = translate_inline("Cost"); $edit = translate_inline("Edit"); $del = translate_inline("Del"); $take = translate_inline("Take"); $deac = translate_inline("Deactivate"); $act = translate_inline("Activate"); rawoutput(""); rawoutput(""); $cat = ""; $count=0; while ($row=db_fetch_assoc($result)) { if ($cat!=$row['category']){ rawoutput(""); $cat = $row['category']; $count=0; } if (isset($companions[$row['companionid']])) { $companions[$row['companionid']] = (int)$companions[$row['companionid']]; } else { $companions[$row['companionid']] = 0; } rawoutput(""); rawoutput(""); addnav("", "companions.php?op=take&id={$row['companionid']}"); rawoutput(""); $count++; } rawoutput("
$ops$name$cost
"); output("Category: %s", $row['category']); rawoutput("
[ $edit |"); addnav("","companions.php?op=edit&id={$row['companionid']}"); if ($row['companionactive']){ rawoutput("$del |"); }else{ $mconf = sprintf($conf, $companions[$row['companionid']]); rawoutput("$del |"); addnav("","companions.php?op=del&id={$row['companionid']}"); } if ($row['companionactive']) { rawoutput("$deac | "); addnav("","companions.php?op=deactivate&id={$row['companionid']}"); }else{ rawoutput("$act | "); addnav("","companions.php?op=activate&id={$row['companionid']}"); } rawoutput("$take ]"); output_notl("`&%s`0", $row['name']); rawoutput(""); output("`%%s gems`0, `^%s gold`0",$row['companioncostgems'], $row['companioncostgold']); rawoutput("
"); output("`nIf you wish to delete a companion, you have to deactivate it first."); }elseif ($op=="add"){ output("Add a companion:`n"); addnav("Companion Editor Home","companions.php"); companionform(array()); }elseif ($op=="edit"){ addnav("Companion Editor Home","companions.php"); $sql = "SELECT * FROM " . db_prefix("companions") . " WHERE companionid='$id'"; $result = db_query_cached($sql, "companiondata-$id", 3600); if (db_num_rows($result)<=0){ output("`iThis companion was not found.`i"); }else{ addnav("Companion properties", "companions.php?op=edit&id=$id"); module_editor_navs("prefs-companions", "companions.php?op=edit&subop=module&id=$id&module="); $subop=httpget("subop"); if ($subop=="module") { $module = httpget("module"); rawoutput("
"); module_objpref_edit("companions", $module, $id); rawoutput("
"); addnav("", "companions.php?op=save&subop=module&id=$id&module=$module"); } else { output("Companion Editor:`n"); $row = db_fetch_assoc($result); $row['abilities'] = @unserialize($row['abilities']); companionform($row); } } } function companionform($companion){ // Let's sanitize the data if (!isset($companion['companionactive'])) $companion['companionactive'] = ""; if (!isset($companion['name'])) $companion['name'] = ""; if (!isset($companion['companionid'])) $companion['companionid'] = ""; if (!isset($companion['description'])) $companion['description'] = ""; if (!isset($companion['dyingtext'])) $companion['dyingtext'] = ""; if (!isset($companion['jointext'])) $companion['jointext'] = ""; if (!isset($companion['category'])) $companion['category'] = ""; if (!isset($companion['companionlocation'])) $companion['companionlocation'] = 'all'; if (!isset($companion['companioncostdks'])) $companion['companioncostdks'] = 0; if (!isset($companion['companioncostgems'])) $companion['companioncostgems'] = 0; if (!isset($companion['companioncostgold'])) $companion['companioncostgold'] = 0; if (!isset($companion['attack'])) $companion['attack'] = ""; if (!isset($companion['attackperlevel'])) $companion['attackperlevel'] = ""; if (!isset($companion['defense'])) $companion['defense'] = ""; if (!isset($companion['defenseperlevel'])) $companion['defenseperlevel'] = ""; if (!isset($companion['hitpoints'])) $companion['hitpoints'] = ""; if (!isset($companion['maxhitpoints'])) $companion['maxhitpoints'] = ""; if (!isset($companion['maxhitpointsperlevel'])) $companion['maxhitpointsperlevel'] = ""; if (!isset($companion['abilities']['fight'])) $companion['abilities']['fight'] = 0; if (!isset($companion['abilities']['defend'])) $companion['abilities']['defend'] = 0; if (!isset($companion['abilities']['heal'])) $companion['abilities']['heal'] = 0; if (!isset($companion['abilities']['magic'])) $companion['abilities']['magic'] = 0; if (!isset($companion['cannotdie'])) $companion['cannotdie'] = 0; if (!isset($companion['cannotbehealed'])) $companion['cannotbehealed'] = 1; if (!isset($companion['allowinshades'])) $companion['allowinshades'] = 0; if (!isset($companion['allowinpvp'])) $companion['allowinpvp'] = 0; if (!isset($companion['allowintrain'])) $companion['allowintrain'] = 0; rawoutput("
"); rawoutput(""); addnav("","companions.php?op=save&id={$companion['companionid']}"); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput("
"); output("Companion Name:"); rawoutput("
"); output("Companion Dyingtext:"); rawoutput("
"); output("Companion Description:"); rawoutput("
"); output("Companion join text:"); rawoutput("
"); output("Companion Category:"); rawoutput("
"); output("Companion Availability:"); rawoutput(""); // Run a modulehook to find out where camps are located. By default // they are located in 'Degolburg' (ie, getgamesetting('villagename')); // Some later module can remove them however. $vname = getsetting('villagename', LOCATION_FIELDS); $locs = array($vname => sprintf_translate("The Village of %s", $vname)); $locs = modulehook("camplocs", $locs); $locs['all'] = translate_inline("Everywhere"); ksort($locs); reset($locs); rawoutput("
"); output("Maxhitpoints / Bonus per level:"); rawoutput(" /
"); output("Attack / Bonus per level:"); rawoutput(" /
"); output("Defense / Bonus per level:"); rawoutput(" /
"); output("Fighter?:"); rawoutput("
"); output("Defender?:"); rawoutput("
"); output("Healer level:"); rawoutput("
"); output("`iThis value determines the maximum amount of HP healed per round`i"); rawoutput("
"); output("Magician?:"); rawoutput("
"); output("`iThis value determines the maximum amount of damage caused per round`i"); rawoutput("
"); output("Companion cannot die:"); rawoutput("
"); output("Companion cannot be healed:"); rawoutput("
"); output("Companion Cost (DKs):"); rawoutput("
"); output("Companion Cost (Gems):"); rawoutput("
"); output("Companion Cost (Gold):"); rawoutput("
"); output("Allow in shades:"); rawoutput("
"); output("Allow in PvP:"); rawoutput("
"); output("Allow in train:"); rawoutput("
"); $save = translate_inline("Save"); rawoutput("
"); } page_footer(); ?>