Jump to content
MakeWebGames

attack sides


peterisgb
 Share

Recommended Posts

hello i need a little help with a sql which i'm not quite understand. could i have some help

$db->query("UPDATE users SET sides=sides+1 WHERE userid={$ir['userid']}",$c);

This is what i got so far, how would i get this formula to work like this sides +1 if (userid % 2) = 0"); and (userid % 2) <> 0");

so you only get a +1 if you are odd ID attacking Even ID and same vice versa.

Link to comment
Share on other sites

well in ODD userid attacks a EVEN user ID then that user will get a +1,

and if an EVEN id attacks a ODD user id they get a +1

but if a EVEN ID user attacks and EVEN user id they dont get a +1 same with ODD attacking ODD

Its battles with good and evil. odds being evil and even id are good, that system is there now but i cant figure this line out to add to attackwon.php etc.

Link to comment
Share on other sites

so if i'm right like this?

$db->query("UPDATE users SET sides=sides+1 WHERE userid={$ir['userid']} AND ((($ir['userid'] % 2) != 0)) AND (($r['userid'] % 2) == 0))) ",$c);

or like this

$db->query("UPDATE users SET sides=sides+1 WHERE userid=$userid AND (($ir['userid'] % 2) != 0))",$c);

$db->query("UPDATE users SET sides=sides+1 WHERE userid=$userid AND (($r['userid'] % 2) == 0))",$c);

or is that wrong.

Edited by peterisgb
Link to comment
Share on other sites

Do the following;

 

/*
 * For attackwon, and other won outcomes
I'm using $r, but preferably I'd use the query string 
*/
if( ((($ir['userid'] % 2) == 0) AND (($r['userid'] % 2) != 0)) 
       OR 
   ((($ir['userid'] % 2) != 0) AND (($r['userid'] % 2) == 0)) ) {
   $db->query("UPDATE `users` SET `sides`=`sides`+1 WHERE `userid`={$userid}", $c);
}

/*
 * For attacklost, and other lost outcomes
I'm using $r, but preferably I'd use the query string 
*/
if( ((($ir['userid'] % 2) == 0) AND (($r['userid'] % 2) != 0)) 
       OR 
   ((($ir['userid'] % 2) != 0) AND (($r['userid'] % 2) == 0)) ) {
   $db->query("UPDATE `users` SET `sides`=`sides`+1 WHERE `userid`={$r['userid']}", $c);
}

 

In theory, that should work how you require it to.

Also, to get the winning side, just count the values of sides for each side ;)

Link to comment
Share on other sites

thanks it worked like a charm, just another little help

The default userlist pages, is there a way i can create another userlist and get it to display only Odd ID's or Even ID's?

Depends on how you want to do it.

<?php

$query = 'SELECT `username` FROM `users` WHERE ( `userid` % 2 = '.( array_key_exists ( 'odd', $_GET ) ? 1 : 0 ).' )';

echo '<a href="userlist.php" title="Even users">Even users</a>&dash;<a href="userlist.php?odd" title="Odd users">Odd Users</a>';

//Execute query & do whatever else you wish to do.

May work.

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.

 Share

×
×
  • Create New...