Jump to content
MakeWebGames

House list in admin panel--V2


cruz

Recommended Posts

I made this from the original V2 userlist. It will show you all of your data from the houses table in your staff panel.

Copy the code below and name it staff_houselist.php. I know I could ave done this in the staff houses php, but I didnt so...

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

Open smenu.php find

 

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

After add

You're unable to view this code.

Viewing code within this forum requires registration, you can register here for free.

 

This mod will allow you to see the houses you have already added so that you can add new ones with the right variables ie...min level and so forth.

Link to comment
Share on other sites

Re: House list in admin panel--V2

I know, for those of you who may use this if you figure out how to add the id to the name you dont even have to go to the edit houde list you can just click the name and it will take you strieght to edit the house.

Adding it to the staff_houses is for a future mod I only have so much time right now.

Link to comment
Share on other sites

  • 2 weeks later...

Re: House list in admin panel--V2

here i got bored wanted to try something....

as above mentions i created this file to say and works on v2 where when you make a house it shows you a list on the same page.

<?php

include "sglobals.php";

if($ir['user_level'] > 2)

{

die("403");

}

//This contains shop stuffs

switch($_GET['action'])

{

case "addhouse": addhouse(); break;

case "edithouse": edithouse(); break;

case "delhouse": delhouse(); break;

default: print "Error: This script requires an action."; break;

}

function addhouse()

{

global $db, $ir, $c, $h, $userid;

$price=abs((int) $_POST['price']);

$will=abs((int) $_POST['will']);

$name=$_POST['name'];

if($price and $will and $name)

{

$q=$db->query("SELECT * FROM houses WHERE hWILL={$will}");

if($db->num_rows($q))

{

print "Sorry, you cannot have two houses with the same maximum will.";

$h->endpage();

exit;

}

$db->query("INSERT INTO houses VALUES(NULL, '$name', '$price', '$will')");

print "House {$name} added to the game.";

stafflog_add("Created House $name");

}

else

{

print "<h3>Add House</h3><hr />

<form action='staff_houses.php?action=addhouse' method='post'>

Name: <input type='text' name='name' />

Price: <input type='text' name='price' />

Max Will: <input type='text' name='will' />

<input type='submit' value='Add House' /></form>";

}

}

function edithouse()

{

global $db, $ir, $c, $h, $userid;

switch($_POST['step'])

{

case "2":

$price=abs((int) $_POST['price']);

$will=abs((int) $_POST['will']);

$q=$db->query("SELECT * FROM houses WHERE hWILL={$will} AND hID!={$_POST['id']}");

if($db->num_rows($q))

{

print "Sorry, you cannot have two houses with the same maximum will.";

$h->endpage();

exit;

}

$name=$_POST['name'];

$q=$db->query("SELECT * FROM houses WHERE hID={$_POST['id']}");

$old=$db->fetch_row($q);

if($old['hWILL'] == 100 && $old['hWILL'] != $will)

{

die("Sorry, this house's will bar cannot be edited.");

}

$db->query("UPDATE houses SET hWILL=$will, hPRICE=$price, hNAME='$name' WHERE hID={$_POST['id']}");

$db->query("UPDATE users SET maxwill=$will WHERE maxwill={$old['hWILL']}");

$db->query("UPDATE users SET will=maxwill WHERE will > maxwill");

print "House $name was edited successfully.";

stafflog_add("Edited house $name");

break;

case "1":

$q=$db->query("SELECT * FROM houses WHERE hID={$_POST['house']}");

$old=$db->fetch_row($q);

print "<h3>Editing a House</h3><hr />

<form action='staff_houses.php?action=edithouse' method='post'>

<input type='hidden' name='step' value='2' />

<input type='hidden' name='id' value='{$_POST['house']}' />

Name: <input type='text' name='name' value='{$old['hNAME']}' />

Price: <input type='text' name='price' value='{$old['hPRICE']}' />

Max Will: <input type='text' name='will' value='{$old['hWILL']}' />

<input type='submit' value='Edit House' /></form>";

break;

default:

print "<h3>Editing a House</h3><hr />

<form action='staff_houses.php?action=edithouse' method='post'>

<input type='hidden' name='step' value='1' />

House: ".house_dropdown($c, "house")."

<input type='submit' value='Edit House' /></form>";

break;

}

}

function delhouse()

{

global $db,$ir,$c,$h,$userid;

if($_POST['house'])

{

$q=$db->query("SELECT * FROM houses WHERE hID={$_POST['house']}");

$old=$db->fetch_row($q);

if($old['hWILL']==100)

{

die("This house cannot be deleted.");

}

$q2=$db->query("SELECT * FROM users WHERE maxwill={$old['hWILL']}");

$ids=array();

while($r=$db->fetch_row($q2))

{

$ids[]=$r['userid'];

}

if(count($ids))

{

$db->query("UPDATE users SET money=money+{$old['hPRICE']}, maxwill=100 WHERE userid IN(".implode(', ', $ids).")");

}

$db->query("UPDATE users SET will=maxwill WHERE will > maxwill");

$db->query("DELETE FROM houses WHERE hID={$old['hID']}");

print "House {$old['hNAME']} deleted.";

stafflog_add("Deleted house {$old['hNAME']}");

}

else

{

print "<h3>Delete House</h3><hr />

Deleting a house is permanent - be sure. Any users that are currently on the house you delete will be returned to the first house, and their money will be refunded.<form action='staff_houses.php?action=delhouse' method='post'>

House: ".house_dropdown($c, "house")."

<input type='submit' value='Delete House' /></form>";

}

}

function report_clear()

{

global $db,$ir,$c,$h,$userid;

if($ir['user_level'] > 3)

{

die("403");

}

$_GET['ID'] = abs((int) $_GET['ID']);

stafflog_add("Cleared player report ID {$_GET['ID']}");

$db->query("DELETE FROM preports WHERE prID={$_GET['ID']}");

print "Report cleared and deleted!

> Back";

}

if($ir['user_level'] > 2)

{

die("403");

}

$_GET['st'] = abs((int) $_GET['st']);

$st=($_GET['st']) ? $_GET['st'] : 0;

$by=($_GET['by']) ? $_GET['by'] : 'hID';

$ord=($_GET['ord']) ? $_GET['ord'] : 'ASC';

print "<h3>houselist</h3>";

$cnt=mysql_query("SELECT hID FROM houses",$c);

$membs=mysql_num_rows($cnt);

$pages=(int) ($house/100)+1;

if($house % 100 == 0)

{

$pages--;

}

print "Pages: ";

for($i=1;$i <= $pages;$i++)

{

$stl=($i-1)*100;

print "$i ";

}

print "

Order By: hID | hNAME | hPRICE | hWILL or max will

Ascending | Descending

";

$q=$db->query("SELECT * FROM houses ORDER BY $by $ord LIMIT $st,100");

$no1=$st+1;

$no2=$st+100;

print "Showing houses $no1 to $no2 by order of $by $ord.

<table width=75% cellspacing=1 class='table'><tr style='background:gray'><th>ID</th><th>Name</th><th>Price</th><th>Max Will</th></tr>";

while($r=$db->fetch_row($q))

{

print "<tr><td>{$r['hID']}</td><td>{$r['hNAME']}</td><td>\${$r['hPRICE']}</td><td>{$r['hWILL']}</td>";

if($r['status'] == 0)

print "</td></tr>";

}

print "</table>";

$h->endpage();

?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...