Jump to content
MakeWebGames

(Request) Gang wars - attacking - respect


radio_active

Recommended Posts

Helllo

I am looking for a small piece of code which changes the way users get respect in gang wars, as far as i know its a small mathematical equation.

Basically respect is based on the level of the person you attack. SO

Heres the situation. I am a level 20.

If i attack and hospitalize a level 20 i get 1 respect for the gang.

If i attack a level 5 i get 0.25 respect for the gang

If i attack a level 36 i get 1.80 respect for the gang

'---------------'level 1 i get 0.05 respect

'---------------'Level 100 i get 5 respect.

 

This makes users want to stay a low level with higher stats so they can get more respect in gang wars and solves a few problems of people lvling to 350+

Please let me know if you can make this for free, i once had it but the server shutdown and the my last backup was a few weeks before i and lost ALOT of work and the coder who made it (Nurples) refused to make it again even though it was maybe 20-30 lines long which shows how great his customer service is.

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

The math formula you want would be like so:

$respect = $defender_lvl / $attacker_lvl;

if( $respect > 1 ) $respect = 1;

Change the variables to the correct names (not sure what mccodes calls them). If you start at level 0 with mccodes then you would need to check for level zero or else you'll throw an divide by zero error.

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

Reading your post felron, i think you have the slight wrong impression.

if $ir 'level' = $r 'level'

respect = 1

(i know i havnt included brackets in them but that because its not code.

for every level above, 0.05 respect extra is added onto 1 and for every level below $ir level ($ir being your level) is -0.05 respect off 1.

Get me?

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

give this a shot and let me know

if($ir['level'] < $r['level'] or $ir['level'] > $r['level'])
{
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+$r['level']*0.05 WHERE gangID={$ir['gang']}");
}
else if($ir['level'] == $r['level'])
{
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$ir['gang']}");
}
Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

 

give this a shot and let me know

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+$r['level']*0.05 WHERE gangID={$ir['gang']}");

 

By the look of that query its going to give 0.05 respect per how much the level of the opponent is so if they are level 20 you will get 1 respect. I want it so that if a level 1 attacks a level 10 they will get 1.5 respect, if they attack a level 5 and win, they get 1.25 respect.

That query will not work. It needs a mathematical equation, about 20 lines of code i think using spaced code that is, so a few queries. Thanks for trying-

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

 

give this a shot and let me know

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+$r['level']*0.05 WHERE gangID={$ir['gang']}");

 

By the look of that query its going to give 0.05 respect per how much the level of the opponent is so if they are level 20 you will get 1 respect. I want it so that if a level 1 attacks a level 10 they will get 1.5 respect, if they attack a level 5 and win, they get 1.25 respect.

if you notice i did change what i posted when i had a 2nd look at it

but what felron just posted looks like it would work

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

if( $defender_lvl > $attacker_lvl ) {

$respect = $defender_lvl + $attacker_lvl *.05

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+$respect WHERE gangID={$ir['gang']}");

}

elseif( $defender_levl < $attacker_lvl ) {

$respect = $defender_lvl - $attacker_lvl *.05

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-$respect WHERE gangID={$ir['gang']}");

}

else {

$respect = 1;

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$ir['gang']}");

}

Sorry about the first post I didn't see that you wanted to go up past 1.0 my bad. I pulled the queries from the post above so I'm not sure it that is exactly what you need or not.

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

$respect = $defender_lvl + $attacker_lvl *.05

If the defender is level 36, and the attacker is level 20, you get 56 * 0.05 or 2.8

Which, clearly, isn't the 1.8 asked for.

 

If i attack a level 36 i get 1.80 respect for the gang

Please note that in that scenario, he's stated he was the level 20 attacker.

The equation you want is:

1 + ( ($them_level - $us_level) * 0.05)

Which, with them at 36, and us at 20, translates into

1 + ( (36 - 20) * 0.05)

1+ ( 16 * 0.05)

1+ 0.8

1.8 ----- Respect gained

With them at 20 and us at 36:

1 + ( (20 - 36) * 0.05)

1+ ( -16 * 0.05)

1+ -0.8

0.2 ----- Respect gained

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

sooooo

if( $defender_lvl > $attacker_lvl ) {

$respect = 1 + ( ($them_level - $us_level) * 0.05)

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+$respect WHERE gangID={$ir['gang']}");

}

elseif( $defender_levl < $attacker_lvl ) {

$respect = 1 - ( ($them_level - $us_level) * 0.05)

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-$respect WHERE gangID={$ir['gang']}");

}

else {

$respect = 1;

$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$ir['gang']}");

}

So is that it?

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

My equation is a catch all.

It doesn't matter if their level is higher or lower.

If their level is higher, you get +0.05 multiplied by the distance from your level to theirs,

if their level is lower, you get -0.05 multiplied by the ^^^^^^^^^^^^^^^^^^^^

And if their level is equal to yours, the quation returns 1.

No if's, else, and else ifs needed there.

Just add the result to their respect.

If their level is way lower than yours (you being the attacker) say, 50 levels lower, you'd actually lose 1.5 respect.

I.e., your existing respect + respect gain or

say 1234 (existing respect) + -1.5

1234 + -1.5

resulting in 1232.5

Link to comment
Share on other sites

Re: (Request) Gang wars - attacking - respect

Okay im getting little bit confused where to put this

1 + ( ($them_level - $us_level) * 0.05)

where the attack query is

 

if (!$count) {
	$war=$db->fetch_row($warq);
	$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-2 WHERE gangID={$r['gang']}");
	$ga['gangRESPECT']-=2;
	$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+2 WHERE gangID={$ir['gang']}");
	print "
You earnt 2 respect for your gang!";
}
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...