|
Posté par Darkmore*, le 15/04/2006 à 11:01:58 Ce mod n'a pas été fait par moi mais par Aweb.
J l'ai justeu n peu modifier c'est a direl e coriger car il n'y avait pu les sql et les image plus une fonction admin.
Tout d'abord tchang ma aidé pour faire le sac a dos et noia pour le menu de l'admin alors commencons :
Dans index.php :
Code :
//Fonction marché :
elseif ($do[0] == "sacados") { sacados(); }
elseif ($do[0] == "marche") { include('towns.php'); marche($do[1]); }
elseif ($do[0] == "marche2") { include('towns.php'); marche2($do[1]); }
elseif ($do[0] == "marche3") { include('towns.php'); marche3($do[1]); }
elseif ($do[0] == "cherche") { include('explore.php'); cherche(); }
elseif ($do[0] == "potionsoins") { include('explore.php'); potionsoins(); }
elseif ($do[0] == "nourriture") { include('explore.php'); nourriture(); }
elseif ($do[0] == "potiontp") { include('explore.php'); potiontp(); }
Toujours dans towns.php :
Code :
function sacados() {
global $userrow, $page, $title;
$page ='<center><img src="images/sac.gif"></center>
<center>Voici le contenu de votre sac à dos pour utiliser ces objet alez en exploration et regarder au dessus de la carte :</center>
<center></center>
<center><table>
<tr><td width="180px"><b>Objets:</b></td></tr>
<tr><td><img src="images/pic.gif" alt="Nouriture" title="Nouriture" />Nouriture :</td><td >x'.$userrow["itemsac6qt"].'</a></td>
<tr><td><img src="images/pic.gif" alt="Potion Soin" title="Potion Soin" />Potion de Soin :</td><td >x'.$userrow["itemsac1qt"].'</a></td>
<tr><td><img src="images/pic.gif" alt="Potion Mana" title="Potion Mana" />Restauration de Mana :</td><td >x'.$userrow["itemsac2qt"].'</a></td>
<tr><td><img src="images/pic.gif" alt="Antidote" title="Antidode" />Antidote :</td><td >x'.$userrow["itemsac4qt"].'</a></td></tr>
<tr><td><img src="images/pic.gif" alt="Potion de Vigueur" title="Potion de Vigueur" />Potion de Tp :</td><td >x'.$userrow["itemsac5qt"].'</a></td></tr>
<tr><td><img src="images/pic.gif" alt="item6" title="objet6" />Pioche</td><td >'.$userrow["itemsac3qt"].'</td></tr>
</table>
<table>
<tr><td width="180px"><b>Ressources:</b></td></tr>
<tr><td><img src="images/pic.gif" alt="cuivre" title="cuivre" />Cuivre :</td><td >'.$userrow["cuivre"].'</td></tr>
<tr><td><img src="images/pic.gif" alt="fer" title="cuivre" />Fer :</td><td >'.$userrow["fer"].'</td></tr>
<tr><td><img src="images/pic.gif" alt="argent" title="argent" />Argent :</td><td >'.$userrow["argent"].'</td></tr>
<tr><td><img src="images/pic.gif" alt="fer" title="platine" />Platine :</td><td >'.$userrow["platine"].'</td></tr>
</table></center>
';
$title = 'Votre sac à dos';
display($page, $title);
}
function marche() { // affiche la liste des différents objets disponibles.
global $userrow, $numqueries;
$townquery = doquery("SELECT name,itemslistb FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) != 1) { display("Tentative de triche detectée.<br /><br />attention le bannissement n'est pas loin.", "Error"); }
$townrow = mysql_fetch_array($townquery);
$itemslistb = explode(",",$townrow["itemslistb"]);
$querystring = "";
foreach($itemslistb as $a=>$b) {
$querystring .= "id='$b' OR ";
}
$querystring = rtrim($querystring, " OR ");
$itemsquery = doquery("SELECT * FROM {{table}} WHERE $querystring ORDER BY id", "items2");
$page = "<bgsound src="music/030-Town08.mid" loop=2>";
$page .= "<center><img src="images/marche.gif" alt="marché" /></center><center><img src="images/personnages/marche.gif" alt="Vendeuse" /></center>Bienvenu sur le marché, ici vous trouverez toutes sortes de produits. De la nourriture en passant par des objets magiques.<br /><br />Cliquez sur le nom d'un objet pour l'acheter.<br /><br />Les objets suivants sont disponibles ici:<br /><br />
";
$page .= "<table width="80%">
";
while ($itemsrow = mysql_fetch_array($itemsquery)) {
if ($itemsrow["type"] == 1) { $attrib = "Type:"; } else { $attrib = "Type:"; }
$page .= "<tr><td width="4%">";
if ($itemsrow["type"] == 7) { $page .= "<img src="images/icon_potion.gif" alt="Potion" /></td>"; }
if ($itemsrow["type"] == <img src='images/smileys/lunettes.gif' alt=''> { $page .= "<img src="images/icon_parchment.gif" alt="Parchemin" /></td>"; }
if ($itemsrow["type"] == 9) { $page .= "<img src="images/icon_paxe.gif" alt="Outil" /></td>"; }
if ($itemsrow["type"] == 10) { $page .= "<img src="images/icon_ring.gif" alt="Anneau" /></td>"; }
if ($itemsrow["type"] == 11) { $page .= "<img src="images/icon_amulet.gif" alt="Amulettes" /></td>"; }
if ($itemsrow["type"] == 12) { $page .= "<img src="images/icon_drink.gif" alt="Nourriture" /></td>"; }
if ($itemsrow["special"] != "X") { $specialdot = "<span class="highlight">*</span>"; } else { $specialdot = ""; }
$page .= "<td width="32%"><b><a href="index.php?do=marche2:".$itemsrow["id"]."">".$itemsrow["name"]."</a>$specialdot</b></td><td width="32%">$attrib <b>".$itemsrow["genre"]."</b></td><td width="32%">Prix: <b>".$itemsrow["buycost"]." Pièces d'Or</b></td></tr>
";
}
$page .= "</table><br />
";
$page .= "Si vous changez d'avis, vous pouvez retourner en <a href="index.php">Ville</a>.
";
$title = "Buy Items";
display($page, $title);
}
function marche2($id) { // Confirme le choix de l'achat.
global $userrow, $numqueries;
$townquery = doquery("SELECT name,itemslistb FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "towns");
if (mysql_num_rows($townquery) != 1) { display("Tentative de Triche.<br /><br />Bannissement imminent.", "Error"); }
$townrow = mysql_fetch_array($townquery);
$townitems = explode(",",$townrow["itemslistb"]);
if (! in_array($id, $townitems)) { display("Tentative de Triche.<br /><br />Bannissement imminent.", "Error"); }
$itemsquery = doquery("SELECT * FROM {{table}} WHERE id='$id' LIMIT 1", "items2");
$itemsrow = mysql_fetch_array($itemsquery);
if ($userrow["gold"] < $itemsrow["buycost"]) { display("<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche1.gif" alt="Vendeuse" /></center><br /><br /><center>Vous pouvez retourner en <a href="index.php">Ville</a>, <a href="index.php?do=marche">Au magasin</a>, Ou utiliser le menu de gauche pour repartir en exploration.</center>", "Buy Items"); die(); }
if ($itemsrow["type"] == 7) {
$page = "<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche2.gif" alt="Vendeuse" /></center><center>Vous voulez acheter un ".$itemsrow["name"].", C'est cela ?<br /><br /><form action="index.php?do=marche3:$id" method="post"><input type="submit" name="submit" value="Oui" /> <input type="submit" name="cancel" value="Non" /></center></form>";
} elseif ($itemsrow["type"] == <img src='images/smileys/lunettes.gif' alt=''> {
$page = "<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche2.gif" alt="Vendeuse" /></center><center>Vous voulez acheter un ".$itemsrow["name"].", C'est cela?<br /><br /><form action="index.php?do=marche3:$id" method="post"><input type="submit" name="submit" value="Oui" /> <input type="submit" name="cancel" value="Non" /></center></form>";
} elseif ($itemsrow["type"] == 9) {
$page = "<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche2.gif" alt="Vendeuse" /></center><center>Vous voulez acheter un ".$itemsrow["name"].", C'est cela?<br /><br /><form action="index.php?do=marche3:$id" method="post"><input type="submit" name="submit" value="Oui" /> <input type="submit" name="cancel" value="Non " /></center></form>";
} elseif ($itemsrow["type"] == 10) {
$page = "<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche2.gif" alt="Vendeuse" /></center><center>Vous voulez acheter un ".$itemsrow["name"].", C'est cela?<br /><br /><form action="index.php?do=marche3:$id" method="post"><input type="submit" name="submit" value="Oui" /> <input type="submit" name="cancel" value="Non " /></center></form>";
} elseif ($itemsrow["type"] == 11) {
$page = "<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche2.gif" alt="Vendeuse" /></center><center>Vous voulez acheter un ".$itemsrow["name"].", C'est cela ?<br /><br /><form action="index.php?do=marche3:$id" method="post"><input type="submit" name="submit" value="Oui" /> <input type="submit" name="cancel" value="Non " /></center></form>";
} elseif ($itemsrow["type"] == 12) {
$page = "<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche2.gif" alt="Vendeuse" /></center><center>Vous voulez acheter un ".$itemsrow["name"].", C'est cela ?<br /><br /><form action="index.php?do=marche3:$id" method="post"><input type="submit" name="submit" value="Oui" /> <input type="submit" name="cancel" value="Non " /></center></form>";
}
$title = "Buy Items";
display($page, $title);
}
function marche3($id) { // Ajoute l'objet a votre sac.
if (isset($_POST["cancel"])) { header("Location: index.php"); die(); }
global $userrow, $numqueries;
$itemquery = doquery("SELECT name,buycost,type FROM {{table}} WHERE id='$id' LIMIT 1", "items2");
$itemsrow = mysql_fetch_array($itemquery);
if ($userrow["gold"] < $itemrow["buycost"]) { display("<img src="././images/marche.gif"/><br /><center><img src="images/personnages/marche.gif" alt="Vendeuse" /></center><br /><br />Vous pouvez retourner en <a href="index.php">Ville</a>, <a href="index.php?do=marche">Au marche</a>, ou partir en exploration grace au menu de gauche.", "Acheter cartes"); die(); }
$newgold = $userrow["gold"] - $itemsrow["buycost"];
if ($itemsrow["type"] == 7) { $userrow["itemsac1qt"] = $userrow["itemsac1qt"] + 1;
} elseif ($itemsrow["type"] == <img src='images/smileys/lunettes.gif' alt=''> { $userrow["itemsac2qt"] = $userrow["itemsac2qt"] + 1;
} elseif ($itemsrow["type"] == 9) { $userrow["itemsac3qt"] = $userrow["itemsac3qt"] + 1;
} elseif ($itemsrow["type"] == 10) { $userrow["itemsac4qt"] = $userrow["itemsac4qt"] + 1;
} elseif ($itemsrow["type"] == 11) { $userrow["itemsac5qt"] = $userrow["itemsac5qt"] + 1;
} elseif ($itemsrow["type"] == 12) { $userrow["itemsac6qt"] = $userrow["itemsac6qt"] + 1;
}
$item1 = $userrow["itemsac1qt"];
$item2 = $userrow["itemsac2qt"];
$item3 = $userrow["itemsac3qt"];
$item4 = $userrow["itemsac4qt"];
$item5 = $userrow["itemsac5qt"];
$item6 = $userrow["itemsac6qt"];
$updatequery = doquery("UPDATE {{table}} SET itemsac1qt='$item1',itemsac2qt='$item2',itemsac3qt='$item3',
itemsac4qt='$item4',itemsac5qt='$item5',
itemsac6qt='$item6',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
display("<center><img src="images/marche.gif" alt="Marché" /></center><center><img src="images/personnages/marche3.gif" alt="Vendeuse" /></center><center><br /><br /><center>Vous pouvez retourner en <a href="index.php">Ville</a>, <a href="index.php?do=marche">Au marche</a>, ou partir en exploration grace au menu de gauche.</center>", "Acheter items");
}
Maintenant dans rightnav (templates)
trouver ca :
Code :
<tr><td><img src="images/icon_weapon.gif" alt="Arme" title="Weapon" /></td><td width="205px">Arme: {{weaponname}}</td></tr>
<tr><td><img src="images/icon_armor.gif" alt="Armure" title="Armor" /></td><td width="205px">Armure: {{armorname}}</td></tr>
<tr><td><img src="images/icon_shield.gif" alt="Protection" title="Shield" /></td><td width="205px">Protection: {{shieldname}}</td></tr></table>
Juste au dessus mettez :
Code :
<tr><td><img src="images/icon_sac.gif" alt="Sac" title="Sac" /></td><td width="205px"><a href=index?do=sacados>Sac a Dos</a></td></tr>
Maintenant encore dans index trouver la fonction doexplore etm ettez en dessous de ca :
Code :
<tr><td class="title"><img src="images/title_exploring.gif" alt="En exploration" /></td></tr>
Cela :
Code :
<tr><td><center><a href="index.php?do=cherche">Chercher des ressources</a> - <a href="index.php?do=potionsoins">Prendre une Potion de soins</a> - <a href="index.php?do=nourriture">Manger</a> - <a href="index.php?do=potiontp">Recuperer les TP</a></center></td></tr>
Bon maintenant les sql :
Code :
--
-- Structure de la table `rpg_items2`
--
CREATE TABLE `rpg_items2` (
`id` smallint(5) unsigned NOT NULL auto_increment,
`type` tinyint(3) unsigned NOT NULL default '0',
`name` varchar(30) NOT NULL default '',
`buycost` smallint(5) unsigned NOT NULL default '0',
`attribute` smallint(5) unsigned NOT NULL default '0',
`special` varchar(50) NOT NULL default '',
`image` tinyint(3) unsigned NOT NULL default '0',
`description` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=37 ;
--
-- Contenu de la table `rpg_items2`
--
INSERT INTO `rpg_items2` VALUES (1, 7, 'potion', 5, 5, '', 0, '');
INSERT INTO `rpg_items2` VALUES (3, 8, 'potion de soins', 5, 0, '', 0, '');
INSERT INTO `rpg_items2` VALUES (4, 11, 'potion de vigeur', 2, 0, '', 0, '');
INSERT INTO `rpg_items2` VALUES (5, 12, 'pomme', 2, 0, '', 0, '');
INSERT INTO `rpg_items2` VALUES (6, 9, 'pioche', 5, 5, '', 0, '');
-- --------------------------------------------------------
Et enfin les image :
édité par sff le 24/10/2006 à 18:47:32
|
|
Posté par *Darkmore, le 15/04/2006 à 11:11:16 Maintenant la fonction admin :
Au debut :
Code :
elseif ($do[0] == "items2") { items2(); }
elseif ($do[0] == "edititem2") { edititem2($do[1]); }
Maintenant la function :
Code :
function items2() {
$query = doquery("SELECT id,name FROM {{table}} ORDER BY id", "items2");
$page = "<b><u>Editer les objets</u></b><br />Cliquez sur le nom d'un objet pour le modifier.<br /><br /><table width="50%">
";
$count = 1;
while ($row = mysql_fetch_array($query)) {
if ($count == 1) { $page .= "<tr><td width="8%" style="background-color: #eeeeee;">".$row["id"]."</td><td style="background-color: #eeeeee;"><a href="admin.php?do=edititem2:".$row["id"]."">".$row["name"]."</a></td></tr>
"; $count = 2; }
else { $page .= "<tr><td width="8%" style="background-color: #ffffff;">".$row["id"]."</td><td style="background-color: #ffffff;"><a href="admin.php?do=edititem2:".$row["id"]."">".$row["name"]."</a></td></tr>
"; $count = 1; }
}
if (mysql_num_rows($query) == 0) { $page .= "<tr><td width="8%" style="background-color: #eeeeee;">Pas d'objets trouvés.</td></tr>
"; }
$page .= "</table>";
admindisplay($page, "Editer objets");
}
function edititem2($id) {
if (isset($_POST["submit"])) {
extract($_POST);
$errors = 0;
$errorlist = "";
if ($name == "") { $errors++; $errorlist .= "Le nom est exigé.<br />"; }
if ($buycost == "") { $errors++; $errorlist .= "Le prix est exigé.<br />"; }
if (!is_numeric($buycost)) { $errors++; $errorlist .= "Le prix doit être un nombre!.<br />"; }
if ($attribute == "") { $errors++; $errorlist .= "L'attribut est exigé.<br />"; }
if (!is_numeric($attribute)) { $errors++; $errorlist .= "L'attribut doit être un nombre.<br />"; }
if ($special == "" || $special == " ") { $special = "X"; }
$name = addslashes($name);
$description = addslashes($description);
if ($errors == 0) {
$query = doquery("UPDATE {{table}} SET name='$name',type='$type',buycost='$buycost',description='$description',
attribute='$attribute',special='$special' WHERE id='$id' LIMIT 1", "items2");
admindisplay("Objet mis à jour.","Editer objets");
} else {
admindisplay("<b>Erreur:</b><br /><div style="color:red;">$errorlist</div><br />Veuillez retourner et essayer encore.", "Edit Items2");
}
}
$query = doquery("SELECT * FROM {{table}} WHERE id='$id LIMIT 1", "items2");
$row = mysql_fetch_array($query);
$page = <<<END
<b><u>Editer Items</u></b><br /><br />
<form action="admin.php?do=edititem2:$id" method="post">
<table width="90%">
<tr><td width="20%">ID:</td><td>{{id}}</td></tr>
<br /><br />
<tr><td width="20%">Nom:</td><td><input type="text" name="name" size="30" maxlength="30" value="{{name}}" /></td></tr>
<tr><td width="20%">Type:</td><td><select name="type"><option value="1" {{type1select}}>Arme</option><option value="2" {{type2select}}>Armure</option><option value="3" {{type3select}}>Protection</option></select></td></tr>
<tr><td width="20%">Prix:</td><td><input type="text" name="buycost" size="5" maxlength="10" value="{{buycost}}" /> rubis</td></tr>
<tr><td width="20%">Description:</td><td><textarea name="description" type="text" rows="5" cols="50">{{description}}</textarea></td></tr>
</table>
<input type="submit" name="submit" value="Valider" /> <input type="reset" name="reset" value="Annuler" />
</form>
END;
if ($row["type"] == 1) { $row["type1select"] = "selected="selected" "; } else { $row["type1select"] = ""; }
if ($row["type"] == 2) { $row["type2select"] = "selected="selected" "; } else { $row["type2select"] = ""; }
if ($row["type"] == 3) { $row["type3select"] = "selected="selected" "; } else { $row["type3select"] = ""; }
$page = parsetemplate($page, $row);
admindisplay($page, "Editer objets");
}
Et enfin admin template :
Code :
<a href="admin.php?do=items2">Editer objets marché</a><br />
Voila le supprot ce fait a la suite.
édité par sff le 24/10/2006 à 18:48:01
|
|
Posté par Darkmore*, le 15/04/2006 à 11:52:45 Oui merci alors dans explore.php
Code :
Function cherche() {
global $userrow;
if ($userrow["itemsac3qt"] < 1 ) { display("<img src="/images/title_exploring.gif"/><center>Vous n'avez plus de Pioches, retournez en acheter en Ville pour pouvoir creuser.</center>
<center>Retournez sur la <a href="index.php">Carte</a>, Ou utiliser le menu de gauche pour repartir en exploration.</center>", "Chercher"); die(); }
if ($userrow["currenttp"] < 10 ) { display("<img src="/images/title_exploring.gif"/><center>Vous etez trop fatigués pour continuer, rentrez vous reposer.....</center>
<center>Retournez sur la <a href="index.php">Carte</a>, Ou utiliser le menu de gauche pour repartir en exploration.</center>", "Chercher"); die(); }
$latitude = $userrow["latitude"];
$longitude = $userrow["longitude"];
$action = "currentaction='En exploration',";
$pioche = $userrow["itemsac3qt"] - 1;
$chancetrouve = rand(1,25);
$nbrobj = rand(1,2);
if ($chancetrouve == 1 || $chancetrouve == 2 || $chancetrouve == 3 || $chancetrouve == 4 || $chancetrouve == 5) {
doquery("UPDATE {{table}} SET itemsac3qt=itemsac3qt-1, currenttp=currenttp-10, cuivre=cuivre+$nbrobj WHERE id=".$userrow["id"], "users"); // Mise a jour de la variable cuivre.
doquery("UPDATE {{table}} SET $action latitude='$latitude', longitude='$longitude', dropcode='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users"); // Update position.
$page = "<img src="././images/title_exploring.gif"/> Vos efforts sont récompensés. En creusant vous venez de trouvez $nbrobj Minerais de Cuivre!<center>Retournez sur la <a href="index.php">Carte</a>, Ou utiliser le menu de gauche pour repartir en exploration.</center>"; // Output
display($page, "Vous venez de trouver du cuivre!");
die();
} else if ($chancetrouve == 6 || $chancetrouve == 7 || $chancetrouve == 8 || $chancetrouve == 9 ) {
doquery("UPDATE {{table}} SET itemsac3qt=itemsac3qt-1, currenttp=currenttp-10, fer=fer+$nbrobj WHERE id=".$userrow["id"], "users"); // Mise a jour de la variable fer.
doquery("UPDATE {{table}} SET $action latitude='$latitude', longitude='$longitude', dropcode='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users"); // Update position.
$page = "<img src="././images/title_exploring.gif"/> Vos efforts sont récompensés. En creusant vous venez de trouvez $nbrobj Minerais de Fer!<center>Retournez sur la <a href="index.php">Carte</a>, Ou utiliser le menu de gauche pour repartir en exploration.</center>"; // Output
display($page, "Vous venez de trouver du fer!");
die();
} else if ($chancetrouve == 10 || $chancetrouve == 11 || $chancetrouve == 12 ) {
doquery("UPDATE {{table}} SET itemsac3qt=itemsac3qt-1, currenttp=currenttp-10, argent=argent+$nbrobj WHERE id=".$userrow["id"], "users"); // Mise a jour de la variable argent.
doquery("UPDATE {{table}} SET $action latitude='$latitude', longitude='$longitude', dropcode='0' WHERE id='".$userrow["id"]."' LIMIT 1", "users"); // Update position.
$page = "<img src="././images/title_exploring.gif"/> Vos efforts sont récompensés. En creusant vous venez de trouvez $nbrobj Minerais d'argent!<center>Retournez sur la <a href="index.php">Carte</a>, Ou utiliser le menu de gauche pour repartir en exploration.</center>"
|