Jump to content

grlayouts

Members
  • Posts

    342
  • Joined

  • Last visited

Posts posted by grlayouts

  1. Hey,

     

    i have a script in my game that picks up the output rate of a unit which if there is more than one unit it devides, i have 3 teams and the script picks up team 1 and 2, but any units in team 3 the rate shows 0?  :confused:

     

    IE

     

    HEAVY SOLDIER 100%

     

    but with the 3rd team its always showing 0%

     

    <font face="Verdana" color="#000000" size="2"><b>Output Rate</b></font></td></tr>';
          $sql = "SELECT id,name FROM units WHERE class={$row[0]} AND visible=1";
          $r2 = mysql_query($sql);
          while ($row2 = mysql_fetch_row($r2))
          {
             echo '<tr><td align="center">'.$row2[1].'</td><td align="center"><input text="text" size="5" style="'.$boxStyle.'" name="a'.$row2[0].'" value='.getRate($userid,$row2[0]).'>%</td></tr>';
          }
          echo '<tr><td colspan="2" align="center"><input type="submit" value="Set Rates for '.$row[1].'"></td></tr>';
          echo '</table></form>';
       }
       echo '</center>';
    

     

    DB's

     

    
    FOR UNITS.
    
    id 	name 	toground 	toair 	hp 	class 	evolvesto 	style 	cost 	visible
    6 	Mulanix 	10 	10 	200 	3 	0 	1 	20 	1
    5 	Numani 	5 	5 	100 	3 	6 	1 	10 	1
    
    

     

    any help would be great it's annoying me and i can't solve it.

  2. hey Guys I have a table in a db that stores attack details for my game below

     

    id 	attacker 	win 	defender 	time 	deleted
    1 	17 	          1 	84 	1288576720 	0
    2 	22 	          1     84 	1288576989 	0
    
    

     

    i want to give a stat like,

     

    total attacks made : 20 (times there id is attacker)

    percent successful = 20% (if win =1 its a win =0 its a loss)

     

    and the same with times attacked.

     

    I was thinking along the lines of getting the info using

    $stat = mysql_fetch_array(mysql_query("select * from attacklog where attacker='$userid' AND win='1'"));
    

     

    would i just do that for every option in the database?

  3. The code below works and it serves its prupose but i was wondering if there is an easier way to get the info as making it look nice in html seems very challenging??

     

    echo '<table border="0" width="400" bordercolorlight="#808080" bordercolordark="#808080" style="border-collapse: collapse; font-family: Verdana; font-size: 12px" cellspacing="2" cellpadding="2">';
    
    echo '<tr><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>Unit</b></font></td><td bgcolor="#C0C0C0" align="center"><font face="Verdana" color="#000000" size="2"><b>You Have</b></font></td></tr>';
    
    $sql = "SELECT unit,amount FROM army WHERE boss={$userid} AND amount > 0 ORDER BY unit";
    
    $r = mysql_query($sql);
    
    $has = false;
    
    while ($row = mysql_fetch_row($r))
    
    {
    
       $has = true;
    
       echo '<tr><td align="center">'.getUnitName($row[0]).'</td><td align="center">'.number_format($row[1]).'</td></tr>';
    
    }
    
    if ($has == false)
    
    {
    
       echo '<tr><td colspan="2" align="center"><B>None</B></td></tr>';
    
    }
    
    
    
    echo '</table><BR>';

  4. Hi,

     

    i want to have a map of the us in which in my game people can control and it turns there colour using co ordinates, i know how to get the coordinates from below but i dont know how to set the borders for each country or save the info into a table ie

     

    where                  controlledby

     

    texas                        player1

     

    washington              none

     

    and if it's controlled by the player then changed the colour of the square to there colour ie red?

     

    i hope this makes sense and someone can point me in the right direction

    <?
    $foo_x=$_POST['foo_x'];
    $foo_y=$_POST['foo_y'];
    echo "X=$foo_x, Y=$foo_y ";
    ?>
    
    <form action='' method=post>
    <input type="image" alt=' Finding coordinates of an image' src="map.jpg" name="foo" style=cursor:crosshair;/>
    </form>

  5. I want to make a map for my online game, i dont know if anyone has seen the map on the game sepica.com i really want to make something like that but dont know where to start?

     

    does anyone play on that site that can help?

     

    basicly i have a world map image that i want each country to be clickable and place the players team colour in it. they have it as loc?282,272 and i dont know how to achive it?

     

    any suggestions?

  6. I have an in game chatr script which works great apart from one little thing. when a user uses like ' or ; or = or ) the script doesnt post the message in the database can anyone help?

     

    <?php
    
    
    
    
    
    if ($sc == "")
    
    {
    
       diver ('Battle Of Species Global Game Talk');
       $sql3 = "UPDATE users SET gamechat=0 where id=$userid";
    
       mysql_query($sql3);
    
       echo '<center><BR>[<a href="index.php?cmd=chat&sc=chatadd">Add Post</a>]</center><BR><BR>';
    
    
    
       $sql = "SELECT id FROM comm2 WHERE parent=0 ORDER BY `time` DESC";
    
       $r = mysql_query($sql);
    
       while ($row = mysql_fetch_row($r)) 
    
       {
    
          echo '<table border="0"><tr><td>';
    
          showMessage($row[0], 0,$b);
    
          echo '</td></tr></table><BR><BR>';
    
       }
    
    
    
    
    
    }else if ($sc =="chatadd")
    
    {
    
       diver ('Enter Your Post Below');
    
       echo '<center>';
    
       echo '<form method="post" action="index.php?cmd=chat&sc=chatadd2">';
    
       echo '<input type="hidden" name="inPar" value="'.$inPar.'">';
    
       echo '<textarea rows="10" cols="45" name="inText" style="'.$boxStyle.'"></textarea><BR><BR><input type="submit" value="Post">';
    
       echo '</form></center>';
    
    }else if ($sc == "chatadd2")
    
    {
    
       diver ("Message Posted");
    
       $inText = clean($inText);
    
       $sql = "INSERT INTO comm2 (author,parent,time,post) VALUES ('{$userid}','{$inPar}','".time()."','{$inText}')";
    
       mysql_query($sql);
       
        $sql2 = "UPDATE users SET gamechat=1";
    
       mysql_query($sql2);
    
       echo '<BR><BR><center>You message has been posted!<BR>[<a href="index.php?cmd=chat">Back to Game Chat</a>]';
    
    }
    
    
    
    
    
    function showMessage($m, $l, $b)
    
    {
    
       global $prefDate;
    
       echo '<table border="0" style="font-famile: Verdana; font-size: 12px" cellpadding="4"><tr>';
    
       for ($i = 0; $i < $l; $i++)
    
       {
    
          echo '<td> </td>';
    
       }
    
       echo '<td>';
    
       $sql = "SELECT `post`,`author`,`id`,`time` FROM `comm2` WHERE `id`='{$m}'";
    
       $r = mysql_query($sql); $row = mysql_fetch_row($r);
    
       $row[0] = '<B>'.getvalue($row[1],'handle').'</B><BR>'. $row[0];
    
       $row[0] .= '<BR>[<a href="index.php?cmd=chat&sc=chatadd&inPar='.$row[2].'">Reply</a>] [Posted: '. date($prefDate,$row[3]) .']';
       
       
       
       
       
       
    
       echo str_replace('
    
    ','<BR>',$row[0]);
    
       echo '</td></tr></table>';
    
       $sql = "SELECT id FROM comm2 WHERE parent={$m} ORDER BY time DESC";
    
       $r = mysql_query($sql);
    
       while ($row = mysql_fetch_row($r))
    
       {
    
          showMessage($row[0], $l + 1, $b);
    
       }
    
    }
    
    
    

  7. can anyone help me i have a mysql database for the code

    <?php function gloss($word, $team)
    
    {
    
       $sql = "SELECT `team{$team}` FROM glossary WHERE word='{$word}'";
    
       return ret11($sql);
    
    }
    echo gloss("title", $teamid) .', Welcome to your <B>' .gloss("barracks",$teamid) . '</B>!'; ?>
    
    

     

    but they way i've made the table in the database it's not working. I think this is more sql help but i can provide the table i have made if it helps? can someone help me out with the layout or point me in the right direction?

    [/code]

    EDIT

    DATaBASE CODE

     

    --
    -- Table structure for table `glossary`
    --
    
    CREATE TABLE IF NOT EXISTS `glossary` (
      `title` text NOT NULL,
      `barracks` text NOT NULL,
      `word` text NOT NULL,
      `team` int(11) NOT NULL,
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    

     

  8. Hi,

     

    I have created a login that once worked on another server and i have changed the register globals on in the php.ini.. when I hit login the page does nothing..

     

    the page is located at www.ycreate.com/sos to see what i mean the login code is below..

     

     

    any idea's?

     

    LOGIN FORM

    <form method="post" action="index.php?cmd=login">
    
    <font size="3"><B>PLAYERS LOG IN BELOW</B><br />
    <br />
    <BR>
    
    </font><table border="0" style="font-family = Verdana; font-size = 12px">
    
    <tr><td><font size="1">Username:</font></td><td><font size="1"><input type="text" size="15" name="inUser" style="<?php echo $boxStyle;  ?>"></font></td></tr>
    
    <tr><td><font size="1">Password:</font></td><td><font size="1"><input type="password" size="15" name="inPass" style="<?php echo $boxStyle;  ?>"></font></td></tr>
    
    <tr><td colspan="2" align="center"><font size="1"><input type="submit" value="Login"></font></td></tr>
    
    </table></form>
    

     

    LOGIN SCRIPT

    
    (DB CONNECT)
    
    <? if ($cmd == "login")
    
    {
    
       setcookie('sosuser' , $inUser);
    
       setcookie('sospass' , $inPass);
    
       if ($_COOKIE['sossess'] == "")
    
       {
    
          $sql = "SELECT val FROM tickers WHERE id=1";
    
          $r = mysql_query($sql);
    
          $row = mysql_fetch_row($r);
    
          $next = $row[0];
    
          setcookie('sossess', $next, time()+60*60*24*365);
    
          $sql = "UPDATE tickers SET val=val+1 WHERE id=1";
    
          mysql_query($sql);
    
       }
    
       header('location: index.php?cmd=home');
    
    }else if ($cmd == "logout")
    
    {
    
       setcookie('sosuser' , ' ');
    
       setcookie('sospass' , ' ');
    
       header('location: index.php');
    
    }
    
    
    
    
    
    if ($cmd == '') { $cmd = 'default'; }
    
    
    
    $userid = -1;
    
    if (in_array($cmd, $iPages))
    
    {
    
    
    
       $sql = "SELECT id,team FROM users WHERE username='{$_COOKIE['sosuser']}' AND password='{$_COOKIE['sospass']}'";
    
       $r = mysql_query($sql);
    
       if (mysql_num_rows($r) == 0)
    
       {
    
          $cmd = "badlogin"; 
    
       }else
    
       {
    
          $row = mysql_fetch_row($r);
    
          $userid = $row[0];
    
          $teamid = $row[1];
    
    
    
          $sql = "UPDATE users SET lastaction=".time()." WHERE id={$userid}";
    
          mysql_query($sql);
    
       }
    
    
    
    }
    
    include ("serv.php");
    
    
    
    if (!in_array($cmd, $noHeader))
    
    {
    
       echo 'LOGGED IN' {;
    ?>

  9. Okay I have a login and every time someone tries to use it they get the error

     

    "Please fill out all fields."

     

    the code i have is

     

     

    
    <?php print"<form method=post action=login.php>
    <td width=100% align=center>
    <center><table >
    <tr align=center><td>
    Username
    
    </tD><td>
    Password
    </td><tr align=center>
    <tD>
    <input type=text name=user  size=17 class=dashb>
    
    </tD><tD>
    <input type=password name=pass size=17 class=dashb>
    
    
    </tD></tr>
    </table>
    </td></tR><tR>
    <td>
    <center> <input type=submit value=Login>"; ?>
    
    

     

    and for the login.php

     

    <?php
    if (!$user || !$pass) {
    include("headernologin.php");
    print "Please fill out all fields.";
    exit;
    }
    include("headernologin.php");
    $logres = mysql_num_rows(mysql_query("select * from players where user='$user' and pass='$pass'"));
    $stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));
    if ($logres <= 0) {
    print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again.";
    exit;
    } else {
    session_register("user");
    session_register("pass");
    }
    $ip = " $_SERVER[REMOTE_ADDR] ";
    mysql_query("update players set ip='$ip' where id=$stat[id]");
    print"<br><center>You are being logged at IP $ip";
    ?>
    

     

    the header file only have the database connect.

     

     

    any idea's why it keeps saying that?

  10. and sorry header1 is

     

    
    <?
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    if (!session_is_registered("user") || !session_is_registered("pass")) {
    
    
    
    
    
    
    
    print "<center><font color=silver>Your session is over you will need to log back in....<a href=index.php>CLICK HERE</a>.";
    
    
    
    
    
    
    
    exit;
    
    
    
    
    
    
    
    }
    
    
    
    
    
    
    
    $stat = mysql_fetch_array(mysql_query("select * from players where user='$user' and pass='$pass'"));
    
    
    
    
    
    
    
    if (empty ($stat[id])) {
    
    
    
    
    
    
    
    print "Invalid login.";
    
    
    
    
    
    
    
    exit;
    
    
    
    
    
    
    
    }
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.