Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Monster Generator
Forum PHP.pl > Forum > Gotowe rozwiązania
Zonni
Proszę oto mój formularz :

Kod
<form action="configmonstergen.php" method="get">
Monster Name <br>
<input type="text" name="monster_name"><br>
Description <br>
<input type="text" name="description"><br>
Race <br>
<input type="text" name="race"><br>
experience <br>
<input type="text" name="experience"><br>
speed <br>
<input type="text" name="speed"><br>
manacost <br>
<input type="text" name="manacost"><br>
health <br>
<input type="text" name="health"><br>
look <br>
<input type="text" name="look"><br>
corpse <br>
<input type="text" name="corpse"><br>
attack <br>
<input type="text" name="attack"><br>
defense <br>
<input type="text" name="defense"><br>
summonable <br>
<input type="text" name="summonable"><br>
attackable <br>
<input type="text" name="attackable"><br>
hostile <br>
<input type="text" name="hostile"><br>
illusionable <br>
<input type="text" name="illusionable"><br>
convinceable <br>
<input type="text" name="convinceable"><br>
canpushitems <br>
<input type="text" name="canpushitems"><br>
canpushcreatures <br>
<input type="text" name="canpushcreatures"><br>
targetdistance <br>
<input type="text" name="targetdistance"><br>
pushable <br>
<input type="text" name="pushable"><br>
runonhealth <br>
<input type="text" name="runonhealth"><br>
attack_name <br>
<input type="text" name="attack_name"><br>
interval <br>
<input type="text" name="interval"><br>
skill <br>
<input type="text" name="skill"><br>
attack_value <br>
<input type="text" name="attack_value"><br>
attack_value2 <br>
<input type="text" name="attack_value2"><br>
interval2 <br>
<input type="text" name="interval2"><br>
chance <br>
<input type="text" name="chance"><br>
range <br>
<input type="text" name="range"><br>
min <br>
<input type="text" name="min"><br>
max <br>
<input type="text" name="max"><br>
attribute_key <br>
<input type="text" name="attribute_key"><br>
defenses_armor <br>
<input type="text" name="defenses_armor"><br>
defense2 <br>
<input type="text" name="defense2"><br>
defense_name <br>
<input type="text" name="defense_name"><br>
interval3 <br>
<input type="text" name="interval3"><br>
chance3 <br>
<input type="text" name="chance3"><br>
speedchange <br>
<input type="text" name="speedchange"><br>
duration <br>
<input type="text" name="duration"><br>
attribute_key2 <br>
<input type="text" name="attribute_key2"><br>
value <br>
<input type="text" name="value"><br>
value2 <br>
<input type="text" name="value2"><br>
immunity_physical <br>
<input type="text" name="immunity_physical"><br>
immunity_energy <br>
<input type="text" name="immunity_energy"><br>
immunity_fire <br>
<input type="text" name="immunity_fire"><br>
immunity_poison <br>
<input type="text" name="immunity_poison"><br>
immunity_lifedrain <br>
<input type="text" name="immunity_lifedrain"><br>
immunity_paralyze <br>
<input type="text" name="immunity_paralyze"><br>
immunity_outfit <br>
<input type="text" name="immunity_outfit"><br>
immunity_drunk <br>
<input type="text" name="immunity_drunk"><br>
immunity_invisible <br>
<input type="text" name="immunity_invisible"><br>
<button type="submit"> wyslij </BUTTON>
</form>




i config

Kod
<?
$monster_name = $_GET['monster_name'];
$description = $_GET['description'];
$race = $_GET['race'];
$experience = $_GET['experience'];
$speed = $_GET['speed'];
$manacost = $_GET['manacost'];
$health = $_GET['health'];
$look = $_GET['look'];
$corpse = $_GET['corpse'];
$attack = $_GET['attack'];
$defense = $_GET['defense'];
$summonable = $_GET['summonable'];
$attackable = $_GET['attackable'];
$hostile = $_GET['hostile'];
$illusionable = $_GET['illusionable'];
$convinceable = $_GET['convinceable'];
$canpushitems = $_GET['canpushitems'];
$canpushcreatures = $_GET['canpushcreatures'];
$targetdistance = $_GET['targetdistance'];
$pushable = $_GET['pushable'];
$runonhealth = $_GET['runonhealth'];
$attack_name = $_GET['attack_name'];
$interval = $_GET['interval'];
$skill = $_GET['skill'];
$attack_value = $_GET['attack_value'];
$attack_value2 = $_GET['attack_value2'];
$interval2 = $_GET['interval2'];
$chance = $_GET['chance'];
$range = $_GET['range'];
$min = $_GET['min'];
$max = $_GET['max'];
$attribute_key = $_GET['attribute_key'];
$defenses_armor = $_GET['defenses_armor'];
$defense2 = $_GET['defense2'];
$defense_name = $_GET['defense_name'];
$interval3 = $_GET['interval3'];
$chance3 = $_GET['chance3'];
$speedchange = $_GET['speedchange'];
$duration = $_GET['duration'];
$attribute_key2 = $_GET['attribute_key2'];
$value = $_GET['value'];
$value2 = $_GET['value2'];
$immunity_physical = $_GET['immunity_physical'];
$immunity_energy = $_GET['immunity_energy'];
$immunity_fire = $_GET['immunity_fire'];
$immunity_poison = $_GET['immunity_poison'];
$immunity_lifedrain = $_GET['immunity_lifedrain'];
$immunity_paralyze = $_GET['immunity_paralyze'];
$immunity_outfit = $_GET['immunity_outfit'];
$immunity_drunk = $_GET['immunity_drunk'];
$immunity_invisible = $_GET['immunity_invisible'];

?>



I chodzi mi tutaj o umieszczenie danych z formularza w takim czymś :
Kod
[size="2"]

<?xml version="1.0" encoding="UTF-8"?>

<monster name="$monster_name" nameDescription="$description" race="$race" experience="experience" speed="$speed" manacost="$manacost">

<health now="$health" max="$health"/>

<look type="$look" head="0" body="0" legs="0" feet="0" corpse="$corpse"/>

<targetchange interval="2000" chance="5"/>

<strategy attack="$attack" defense="$defense"/>

<flags>

<flag summonable="$summonable"/>

<flag attackable="$attackable"/>

<flag hostile="$hostile"/>

<flag illusionable="$illusionable"/>

<flag convinceable="$convinceable"/>

<flag pushable="$pushable"/>

<flag canpushitems="$canpushitems"/>

<flag canpushcreatures="$canpushcreatures"/>

<flag targetdistance="$targetdistance"/>

<flag runonhealth="$runonhealth"/>

</flags>

<attacks>

<attack name="$attack_name" interval="$interval" skill="$skill" attack="$attack_value"/>

<attack name="$attack_name2" interval="$interval2" chance="$chance" range="$range" min="-$min" max="-max">

<attribute key="$attribute_key" value="$value2"/>

</attack>

</attacks>

<defenses armor="50" defense="65">

<defense name="speed" interval="1000" chance="7" speedchange="900" duration="8000">

<attribute key="areaEffect" value="$value"/>

</defense>

</defenses>

<immunities>

<immunity physical="$immunity_physical"/>

<immunity energy="$immunity_energy"/>

<immunity fire="$immunity_fire"/>

<immunity poison="$immunity_poison"/>

<immunity lifedrain="$immunity_lifedrain"/>

<immunity paralyze="$immunity_paralyze"/>

<immunity outfit="$immunity_outfit"/>

<immunity drunk="$immunity_drunk"/>

<immunity invisible="$immunity_invisible"/>

</immunities>

</monster>

[/size]









Proszę o poważne potraktowanie tematu oraz odpowiedź z skryptem/skryptem + poprawione błędy winksmiley.jpg

Z góry dziękuję exclamation.gif
nexis
A ja poproszę przelew na konto + skrzynkę piwa z dostawą kurierem.

A poważnie: albo składasz ofertę z wynagrodzeniem w odpowiednim dziale, albo daruj sobie kolejne posty.
michalkjp
Najprostsze rozwiązanie, to zapisanie tego bezpośrednio do pliku – zapoznaj się z operacjami odczyt/zapis plików w PHP. Kolejnym rozwiązaniem (bardziej przyszłościowym – ułatwia dalszą modyfikacje projektu) jest użycie jakiegoś parsera XML – budujesz sobie drzewko XML a później za pomocą jakiejś magicznej funkcji (każdy parser ma coś takiego) zapisujesz drzewo do pliku.
Zonni
Michal,

Mógłbyś podać link do czegoś takiego bo po raz pierwszy koduje w xml...




nexis,
to ma być żart ?
czy to że robie coś do tibii questionmark.gif


Ja w tibie nie gram, tibia to SZAJS.
Czasem zrobie komuś acc makera ale to jest żadkość.
To robie bo kolega mnie poprosił...


Ale mi chodzi tylko o wyświetlenie wpisanych danych formularza do tego szablonu.... byłoby wszystko OK, ale serwer czyta mi te <monster></monster> a chciałbym to ominąć. Naprawde proszę o pomoc... myślałem że jednak tutaj się czegoś dowiem/naucze
Vielta
http://pl2.php.net/manual/pl/ref.xml.php" title="Zobacz w manualu PHP" target="_manual
uh?

+ Wyluzuj, ktoś tutaj cię oskarża, że to źle że robisz coś do Tibii?
Zonni
Dziękuję smile.gif


Po wypowiedzi nexisa myślałem że oto chodzi... ale chyba wyprubuje tutaj zrobić z funkcją print''....
Zobacze tym wymyślonym przezemnie sposobem...

Aha dzięki za pomoc Vielta...
Pomógł poleciał smile.gif


Uwaga błąd już nie wyskakuje ale nie wyświetla smile.gif
  1. <form action="configmonstergen.php" method="get">
  2. Monster Name <br>
  3. <input type="text" name="monster_name"><br>
  4. Description <br>
  5. <input type="text" name="description"><br>
  6. Race <br>
  7. <input type="text" name="race"><br>
  8. experience <br>
  9. <input type="text" name="experience"><br>
  10. speed <br>
  11. <input type="text" name="speed"><br>
  12. manacost <br>
  13. <input type="text" name="manacost"><br>
  14. health <br>
  15. <input type="text" name="health"><br>
  16. look <br>
  17. <input type="text" name="look"><br>
  18. corpse <br>
  19. <input type="text" name="corpse"><br>
  20. attack <br>
  21. <input type="text" name="attack"><br>
  22. defense <br>
  23. <input type="text" name="defense"><br>
  24. summonable <br>
  25. <input type="text" name="summonable"><br>
  26. attackable <br>
  27. <input type="text" name="attackable"><br>
  28. hostile <br>
  29. <input type="text" name="hostile"><br>
  30. illusionable <br>
  31. <input type="text" name="illusionable"><br>
  32. convinceable <br>
  33. <input type="text" name="convinceable"><br>
  34. canpushitems <br>
  35. <input type="text" name="canpushitems"><br>
  36. canpushcreatures <br>
  37. <input type="text" name="canpushcreatures"><br>
  38. targetdistance <br>
  39. <input type="text" name="targetdistance"><br>
  40. pushable <br>
  41. <input type="text" name="pushable"><br>
  42. runonhealth <br>
  43. <input type="text" name="runonhealth"><br>
  44. attack_name <br>
  45. <input type="text" name="attack_name"><br>
  46. interval <br>
  47. <input type="text" name="interval"><br>
  48. skill <br>
  49. <input type="text" name="skill"><br>
  50. attack_value <br>
  51. <input type="text" name="attack_value"><br>
  52. attack_value2 <br>
  53. <input type="text" name="attack_value2"><br>
  54. interval2 <br>
  55. <input type="text" name="interval2"><br>
  56. chance <br>
  57. <input type="text" name="chance"><br>
  58. range <br>
  59. <input type="text" name="range"><br>
  60. min <br>
  61. <input type="text" name="min"><br>
  62. max <br>
  63. <input type="text" name="max"><br>
  64. attribute_key <br>
  65. <input type="text" name="attribute_key"><br>
  66. defenses_armor <br>
  67. <input type="text" name="defenses_armor"><br>
  68. defense2 <br>
  69. <input type="text" name="defense2"><br>
  70. defense_name <br>
  71. <input type="text" name="defense_name"><br>
  72. interval3 <br>
  73. <input type="text" name="interval3"><br>
  74. chance3 <br>
  75. <input type="text" name="chance3"><br>
  76. speedchange <br>
  77. <input type="text" name="speedchange"><br>
  78. duration <br>
  79. <input type="text" name="duration"><br>
  80. attribute_key2 <br>
  81. <input type="text" name="attribute_key2"><br>
  82. value <br>
  83. <input type="text" name="value"><br>
  84. value2 <br>
  85. <input type="text" name="value2"><br>
  86. immunity_physical <br>
  87. <input type="text" name="immunity_physical"><br>
  88. immunity_energy <br>
  89. <input type="text" name="immunity_energy"><br>
  90. immunity_fire <br>
  91. <input type="text" name="immunity_fire"><br>
  92. immunity_poison <br>
  93. <input type="text" name="immunity_poison"><br>
  94. immunity_lifedrain <br>
  95. <input type="text" name="immunity_lifedrain"><br>
  96. immunity_paralyze <br>
  97. <input type="text" name="immunity_paralyze"><br>
  98. immunity_outfit <br>
  99. <input type="text" name="immunity_outfit"><br>
  100. immunity_drunk <br>
  101. <input type="text" name="immunity_drunk"><br>
  102. immunity_invisible <br>
  103. <input type="text" name="immunity_invisible"><br>
  104. <button type="submit"> wyslij </BUTTON>
  105. </form>
  106.  
  107. <?
  108. $monster_name = $_GET['monster_name'];
  109. $description = $_GET['description'];
  110. $race = $_GET['race'];
  111. $experience = $_GET['experience'];
  112. $speed = $_GET['speed'];
  113. $manacost = $_GET['manacost'];
  114. $health = $_GET['health'];
  115. $look = $_GET['look'];
  116. $corpse = $_GET['corpse'];
  117. $attack = $_GET['attack'];
  118. $defense = $_GET['defense'];
  119. $summonable = $_GET['summonable'];
  120. $attackable = $_GET['attackable'];
  121. $hostile = $_GET['hostile'];
  122. $illusionable = $_GET['illusionable'];
  123. $convinceable = $_GET['convinceable'];
  124. $canpushitems = $_GET['canpushitems'];
  125. $canpushcreatures = $_GET['canpushcreatures'];
  126. $targetdistance = $_GET['targetdistance'];
  127. $pushable = $_GET['pushable'];
  128. $runonhealth = $_GET['runonhealth'];
  129. $attack_name = $_GET['attack_name'];
  130. $interval = $_GET['interval'];
  131. $skill = $_GET['skill'];
  132. $attack_value = $_GET['attack_value'];
  133. $attack_name2 = $_GET['attack_value2'];
  134. $interval2 = $_GET['interval2'];
  135. $chance = $_GET['chance'];
  136. $range = $_GET['range'];
  137. $min = $_GET['min'];
  138. $max = $_GET['max'];
  139. $attribute_key = $_GET['attribute_key'];
  140. $defenses_armor = $_GET['defenses_armor'];
  141. $defense2 = $_GET['defense2'];
  142. $defense_name = $_GET['defense_name'];
  143. $interval3 = $_GET['interval3'];
  144. $chance3 = $_GET['chance3'];
  145. $speedchange = $_GET['speedchange'];
  146. $duration = $_GET['duration'];
  147. $attribute_key2 = $_GET['attribute_key2'];
  148. $value = $_GET['value'];
  149. $value2 = $_GET['value2'];
  150. $immunity_physical = $_GET['immunity_physical'];
  151. $immunity_energy = $_GET['immunity_energy'];
  152. $immunity_fire = $_GET['immunity_fire'];
  153. $immunity_poison = $_GET['immunity_poison'];
  154. $immunity_lifedrain = $_GET['immunity_lifedrain'];
  155. $immunity_paralyze = $_GET['immunity_paralyze'];
  156. $immunity_outfit = $_GET['immunity_outfit'];
  157. $immunity_drunk = $_GET['immunity_drunk'];
  158. $immunity_invisible = $_GET['immunity_invisible'];
  159.  
  160.  
  161. $info = chr(6).chr(0).chr(255).chr(255).'info';
  162. $sock = @fsockopen($monster_name, $description, $race, $experience, $speed, $manacost, $health, $look, $corpse, $attack, $defense, $summonable, $attackable, $hostile, $illusionable, $convinceable, $canpushitems, $canpushcreatures, $targetdistance, $pushable, $runonhealth, $attack_name, $interval, $skill, $attack_value, $attack_name2, $interval2, $chance, $range, $min, $max, $attribute_key, $defenses_armor, $defense2, $defense_name, $interval3, $chance3, $speedchange, $duration, $attribute_key2, $value, $value2, $immunity_physical, $immunity_energy, $immunity_fire, $immunity_poison, $immunity_lifedrain, $immunity_paralyze, $immunity_outfit, $immunity_drunk, $immunity_invisible);
  163.  
  164. if ($sock)
  165. {
  166.    fwrite($sock, $info);
  167.    $data='';
  168.  
  169.    while (!feof($sock))
  170.        $data .= fgets($sock, 1024);
  171.    fclose($sock);
  172.  
  173.    print '<?xml version="1.0" encoding="UTF-8"?>';
  174.    print '<monster name="<?=$monster_name ?>" nameDescription="<?=$description ?>" race="<?=$race ?>" experience="<?=$experience ?>" speed="<?=$speed ?>" manacost="<?=$manacost ?>">';
  175.    print '<health now="<?=$health ?>" max="<?=$health ?>"/>';
  176.    print '<look type="<?=$look ?>" head="0" body="0" legs="0" feet="0" corpse="<?=$corpse ?>"/>';
  177.    print '<targetchange interval="2000" chance="5"/>';
  178.    print '<strategy attack="<?=$attack ?>" defense="<?=$defense ?>"/>';
  179.    print '<flags>';
  180.    print '<flag summonable="<?=$summonable ?>"/>';
  181.    print '<flag attackable="<?=$attackable ?>"/>';
  182.    print '<flag hostile="<?=$hostile ?>"/>';
  183.    print '<flag illusionable="<?=$illusionable ?>"/>';
  184.    print '<flag convinceable="<?=$convinceable ?>"/>';
  185.    print '<flag pushable="<?=$pushable ?>"/>';
  186.    print '<flag canpushitems="<?=$canpushitems ?>"/>';
  187.    print '<flag canpushcreatures="<?=$canpushcreatures ?>"/>';
  188.    print '<flag targetdistance="<?=$targetdistance ?>"/>';
  189.    print '<flag runonhealth="<?=$runonhealth ?>"/>';
  190.    print '</flags>';
  191.    print '<attacks>';
  192.    print '<attack name="<?=$attack_name ?>" interval="<?=$interval ?>" skill="<?=$skill ?>" attack="<?=$attack_value ?>"/>';
  193.    print '<attack name="<?=$attack_name2 ?>" interval="<?=$interval2 ?>" chance="<?=$chance ?>" range="<?=$range" min="-<?=$min ?>" max="-<?=$max ?>">';
  194.    print '<attribute key="<?=$attribute_key ?>" value="<?=$value2 ?>"/>';
  195.    print '</attack>';
  196.    print '</attacks>';
  197.    print '<defenses armor="50" defense="65">';
  198.    print '<defense name="speed" interval="1000" chance="7" speedchange="900" duration="8000">';
  199.    print '<attribute key="areaEffect" value="<?=$value ?>"/>';
  200.    print '</defense>';
  201.    print '</defenses>';
  202.    print '<immunities>';
  203.    print '<immunity physical="<?=$immunity_physical ?>"/>';
  204.    print '<immunity energy="<?=$immunity_energy ?>"/>';
  205.    print '<immunity fire="<?=$immunity_fire ?>"/>';
  206.    print '<immunity poison="<?=$immunity_poison ?>"/>';
  207.    print '<immunity lifedrain="<?=$immunity_lifedrain ?>"/>';
  208.    print '<immunity paralyze="<?=$immunity_paralyze ?>"/>';
  209.    print '<immunity outfit="<?=$immunity_outfit ?>"/>';
  210.    print '<immunity invisible="<?=$immunity_invisible ?>"/>';
  211.    print '</immunities>';
  212.    print '</monster>';
  213. }
  214. ?>
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2024 Invision Power Services, Inc.