Harley Posted April 10, 2009 Share Posted April 10, 2009 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 Quote Link to comment Share on other sites More sharing options...
Karlos Posted April 10, 2009 Share Posted April 10, 2009 Re: 2 questions - please help if ($odata['userid'] == '1' OR $odata['userid'] == '2' OR $odata['userid'] == '3') { echo 'Tut Tut Tut....'; $h->endpage(); exit; } Quote Link to comment Share on other sites More sharing options...
Harley Posted April 10, 2009 Author Share Posted April 10, 2009 Re: 2 questions - please help Cool thanks very much. What does the echo Tut Tut Tut do? Quote Link to comment Share on other sites More sharing options...
Karlos Posted April 10, 2009 Share Posted April 10, 2009 Re: 2 questions - please help http://uk2.php.net/manual/en/function.echo.php Faster than print... Not noticable though. Quote Link to comment Share on other sites More sharing options...
Guest Anonymous Posted April 10, 2009 Share Posted April 10, 2009 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; } Quote Link to comment Share on other sites More sharing options...
Karlos Posted April 10, 2009 Share Posted April 10, 2009 Re: 2 questions - please help Gah, i've been using in_array() in a few of my mods recently, yet I forget about it.. :| *Karlos headbutt's the wall. Quote Link to comment Share on other sites More sharing options...
POG1 Posted April 10, 2009 Share Posted April 10, 2009 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! :) } Quote Link to comment Share on other sites More sharing options...
DELETE ME NOW! Posted April 11, 2009 Share Posted April 11, 2009 Re: 2 questions - please help Yar or like if($_GET['ID'] == 1) { echo 'Dude what are you smoking?'; $h->endpage(); exit; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.