Jump to content
MakeWebGames

2 questions - please help


Harley

Recommended Posts

Right now my game is setup so that player # 1 cannot be attacked. How can I add other player numbers so that they cannot be attacked either? Do I just use a simple comma between each number or what?

Also, my game needs to be reset but I do not know how to do this. Can anyone explain?

I believe this is the code that handles the non-attacking of staf and admin

 

else if ($odata['userid'] == 1)
{
print "Trying to attack an Admin?!?!";
$hosptime=(60);
$db->query("UPDATE users SET hospital=$hosptime,hospreason= 'Dont attack an Admin, Dumbass!' WHERE userid=$userid");
$h->endpage();
exit;
}
else if ($odata['userid'] == 3)
{
print "Staff cannot be attacked!";
$h->endpage();
exit;

 

Thanks for your time.

Harley

Link to comment
Share on other sites

Guest Anonymous

Re: 2 questions - please help

Another solution...

 

$user_ids = array('1', '2', '3');
if(in_array($_GET[iD], $user_ids)){
  echo 'This user cannot be attacked.';
  $h->endpage();
  exit;
}
Link to comment
Share on other sites

Re: 2 questions - please help

You could elaborate on that a bit and store a string of IDs that cannot be attacked.

 

$listString = (string) "3,4,5,35,65,77,35,66"; // list of IDs (could be from DB) in a string separated by commas
$list = explode(',',$listString); // create an array from the string

if(in_array($_REQUEST['ID'],$list)){

   // Condition was true, end page and echo warning! :)

}
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...