Jump to content
MakeWebGames

Recommended Posts

Posted

For some reason, when people are attacking, and leaving for exp...they're not getting any EXP. Please help :)

 

<?php
$atkpage=1;
include "globals.php";

$_GET['ID']=abs((int) $_GET['ID']);
$_SESSION['attacking']=0;
$ir['attacking']=0;
$db->query("UPDATE users SET attacking=0 WHERE userid=$userid");
$od=$db->query("SELECT * FROM users WHERE userid={$_GET['ID']}");
if($_SESSION['attackwon'] != $_GET['ID'])
{
die ("Cheaters don't get anywhere.");
}
if($db->num_rows($od))
{
$r=$db->fetch_row($od);
$gq=$db->query("SELECT * FROM gangs WHERE gangID={$r['gang']}");
$ga=$db->fetch_row($gq);
if($r['hp'] == 1)
{
print "What a cheater u are.";
}
else
{
print "You beat {$r['username']} ";
$qe=$r['level']*$r['level']*$r['level'];
$expgain=rand($qe/2,$qe);
$expperc=(int) ($expgain/$ir['exp_needed']*100);
print "and gained $expperc% EXP!

You honor {$r['username']} to the gods praying for a safe passage to Hades.";
$hosptime=rand(10,20);
$db->query("UPDATE users SET hp=1,hospital=$hosptime,hospreason='honored by <a href=\'viewuser.php?u={$userid}\'>{$ir['username']}</a>' WHERE userid={$r['userid']}");
event_add($r['userid'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] defeated you and honored your death.",$c,'combat');
$atklog=mysql_escape_string($_SESSION['attacklog']);
$db->query("INSERT INTO attacklogs VALUES('',$userid,{$_GET['ID']},'won',unix_timestamp(),-2,'$atklog');");
$_SESSION['attackwon']=0;
$warq=$db->query("SELECT * FROM gangwars WHERE (warDECLARER={$ir['gang']} AND warDECLARED={$r['gang']}) OR (warDECLARED={$ir['gang']} AND warDECLARER={$r['gang']})");
if ($db->num_rows($warq) > 0)
{
$war=$db->fetch_row($warq);
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-1 WHERE gangID={$r['gang']}");
$ga['gangRESPECT']-=1;
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$ir['gang']}");
print "
You earnt 1 respect for your gang!";

}
//Gang Kill
if ($ga['gangRESPECT']<=0 && $r['gang'])
{
$db->query("UPDATE users SET gang=0 WHERE gang={$r['gang']}");

$db->query("DELETE FROM gangs WHERE gangRESPECT<='0'");
$db->query("DELETE FROM gangwars WHERE warDECLARER={$ga['gangID']} or warDECLARED={$ga['gangID']}");
}
$npcs=array(
);
$db->query("UPDATE users SET pleft=pleft+1 WHERE userid=$userid",$c);
$db->query("UPDATE users SET awon=awon+1 WHERE userid=$userid",$c);
$db->query("UPDATE users SET atotal=atotal+1 WHERE userid=$userid",$c);
$db->query("UPDATE users SET tattacked=tattacked+1 WHERE userid={$r['userid']}",$c);
if($r['user_level']==0)
{
$q=$db->query("SELECT * FROM challengebots WHERE cb_npcid={$r['userid']}");
if ($db->num_rows($q)) {
$cb=$db->fetch_row($q);
$qk=$db->query("SELECT * FROM challengesbeaten WHERE userid=$userid AND npcid={$r['userid']}");
if(!$db->num_rows($qk))
{
$m=$cb['cb_money'];
$db->query("UPDATE users SET money=money+$m WHERE userid=$userid");
print "
You gained ?$m for beating the challenge bot {$r['username']}";
$db->query("INSERT INTO challengesbeaten VALUES($userid, {$r['userid']})");
}
}
}


}
}
else
{
print "You beat Mr. non-existant!";
}

$h->endpage();
?>
<center><script type="text/javascript"><!--
google_ad_client = "pub-2581558253444379";
/* Legends (Game)  Add */
google_ad_slot = "5202311777";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>
Posted

Re: Exp from leaving people not working

That's the main bit you'll change to make it higher...

 

$qe = $r['level']*$r['level']*$r['level'];
$expgain = rand($qe/2,$qe);
$expperc = (int) ($expgain/$ir['exp_needed']*100);
Posted

Re: Exp from leaving people not working

As karlos pointed out to you. If the member is level 1 it's going to be like

1 x 1 x 1 = ??? 1!

Now we checking for a rand value

1 / 2 = 0;

rand(0,1);

Your ratio to getting 1 will be 50% ;)

Posted

Re: Exp from leaving people not working

I attack someone, it states you've gained 3% exp, yet the 3% doesn't apply to the character. I understand the formula, but the values are not being placed into the SQL. I was wondering if anyone can help me code that :)

Posted

Re: Exp from leaving people not working

So in short, you are using my problem to raise your post count... I'm having an error that I cannot figure out, and I'm looking for help. The facts are simple, you can attack another player, but the exp is not sticking. Is there anything wrong with the code? I've received this complaint from my friends that are beta testing.

You attack the player, and beat them, it say's you gain X amount experience in percentage...then when you recycle the page to lets say index....you don't gain the EXP.

Now if you can please help me out by explaining what in my code I need to change, I would really appreciate it...but please don't continue to question my intelligence by just restating the main issue i'm having

Posted

Re: Exp from leaving people not working

Ok let me explain cocky boi ;).

The mccode attack system display's in a % of how much you gain. BUT! when it come's to the query, it is not inserted as a %!.

Now as for us to spoon feed you, maybe try learn a little and you might get some where in life eh?

Anyway, your problem is with the %. So here you go cocky boy.. i'll spoon feed it to you so you don't get no where in life.

 

<?php
$atkpage=1;
include "globals.php";

$_GET['ID']=abs((int) $_GET['ID']);
$_SESSION['attacking']=0;
$ir['attacking']=0;
$db->query("UPDATE users SET attacking=0 WHERE userid=$userid");
$od=$db->query("SELECT * FROM users WHERE userid={$_GET['ID']}");
if($_SESSION['attackwon'] != $_GET['ID'])
{
die ("Cheaters don't get anywhere.");
}
if($db->num_rows($od))
{
$r=$db->fetch_row($od);
$gq=$db->query("SELECT * FROM gangs WHERE gangID={$r['gang']}");
$ga=$db->fetch_row($gq);
if($r['hp'] == 1)
{
print "What a cheater u are.";
}
else
{
print "You beat {$r['username']} ";
$qe=$r['level']*$r['level']*$r['level'];
$expgain=rand($qe/2,$qe);
$expperc=(int) ($expgain/$ir['exp_needed']*100);
print "and gained $expperc% EXP!

You honor {$r['username']} to the gods praying for a safe passage to Hades.";
$hosptime=rand(10,20);
$db->query("UPDATE users SET hp=1,hospital=$hosptime,hospreason='honored by <a href=\'viewuser.php?u={$userid}\'>{$ir['username']}</a>' WHERE userid={$r['userid']}");
$db->query("UPDATE users SET exp = exp + ".$expperc." WHERE userid = ".$ir['userid']);
$expgain = 0;
$expperc = 0;
event_add($r['userid'],"[url='viewuser.php?u=$userid']{$ir['username']}[/url] defeated you and honored your death.",$c,'combat');
$atklog=mysql_escape_string($_SESSION['attacklog']);
$db->query("INSERT INTO attacklogs VALUES('',$userid,{$_GET['ID']},'won',unix_timestamp(),-2,'$atklog');");
$_SESSION['attackwon']=0;
$warq=$db->query("SELECT * FROM gangwars WHERE (warDECLARER={$ir['gang']} AND warDECLARED={$r['gang']}) OR (warDECLARED={$ir['gang']} AND warDECLARER={$r['gang']})");
if ($db->num_rows($warq) > 0)
{
$war=$db->fetch_row($warq);
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT-1 WHERE gangID={$r['gang']}");
$ga['gangRESPECT']-=1;
$db->query("UPDATE gangs SET gangRESPECT=gangRESPECT+1 WHERE gangID={$ir['gang']}");
print "
You earnt 1 respect for your gang!";

}
//Gang Kill
if ($ga['gangRESPECT']<=0 && $r['gang'])
{
$db->query("UPDATE users SET gang=0 WHERE gang={$r['gang']}");

$db->query("DELETE FROM gangs WHERE gangRESPECT<='0'");
$db->query("DELETE FROM gangwars WHERE warDECLARER={$ga['gangID']} or warDECLARED={$ga['gangID']}");
}
$npcs=array(
);
$db->query("UPDATE users SET pleft=pleft+1 WHERE userid=$userid",$c);
$db->query("UPDATE users SET awon=awon+1 WHERE userid=$userid",$c);
$db->query("UPDATE users SET atotal=atotal+1 WHERE userid=$userid",$c);
$db->query("UPDATE users SET tattacked=tattacked+1 WHERE userid={$r['userid']}",$c);
if($r['user_level']==0)
{
$q=$db->query("SELECT * FROM challengebots WHERE cb_npcid={$r['userid']}");
if ($db->num_rows($q)) {
$cb=$db->fetch_row($q);
$qk=$db->query("SELECT * FROM challengesbeaten WHERE userid=$userid AND npcid={$r['userid']}");
if(!$db->num_rows($qk))
{
$m=$cb['cb_money'];
$db->query("UPDATE users SET money=money+$m WHERE userid=$userid");
print "
You gained ?$m for beating the challenge bot {$r['username']}";
$db->query("INSERT INTO challengesbeaten VALUES($userid, {$r['userid']})");
}
}
}


}
}
else
{
print "You beat Mr. non-existant!";
}

$h->endpage();
?>
<center><script type="text/javascript"><!--
google_ad_client = "pub-2581558253444379";
/* Legends (Game)  Add */
google_ad_slot = "5202311777";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>

 

And since i just posted this and saw, your error is probly comming from your event add unless you added more field's to it.

Anyway, please when you make retarded edit's to your script's. Back it up and check your error's FOO!

And for my post count. No it is not to raise it. I just aint going to just spoon feed you so you can not learn such an easy task.

Posted

Re: Exp from leaving people not working

First, my name is Annie...I'm not a cocky Boi, but an extremely tired girl.

Second of all, you pompous twit, Its 4:35 am local for me, and I've been spending several hours trying to figure this out/

Third, you NEED to understand that not everyone completely understands coding here. Some people are new to this. I myself majored in Biology in undergrad, graduate school, and doctorate. I've had limited math in the past seven years. Nor never took a computer science course.

Fourth, I posted here for HELP with a situation as a newer member. When dealing with someone who is new, you must not be coy or basic. If you had explained, or sorted my question out sooner, I would not have been short with you.

So thank you for taking a look at my question, but please learn some manors Lad.

P.S. I never asked for you to spoon feed me with by inserting it into the code. I just wanted to know at what point I was making my mistake at, and what I could do to change that. You reposting the code does nothing for me...

Posted

Re: Exp from leaving people not working

1.- replace "cocky boi" to "cocky girl"

2.- several hour's and we pointed it to you in basicly the second post.

3.- If people do not understand coding? Why not pay some one to do the work for them?

4.- You posted for help, and would you like everything spoon fed to you? It's like this, Do you think some stranger will just come up to you and give you 5 billion cash? Basicly that's spoon feeding you to supporting you up till you 99 year's old.

Your welcome, but i do have manner's ;)

Posted

Re: Exp from leaving people not working

Ok, just to play you, your change had no effect. The information is not being injected into the SQL still. Now, can someone else please help me with this situation, because this guy seems to know less than I do.

Posted

Re: Exp from leaving people not working

 

And since i just posted this and saw, your error is probly comming from your event add unless you added more field's to it.

 

Anyway, please when you make retarded edit's to your script's. Back it up and check your error's FOO!

Maybe try reading for a bit?

the v2 event_add() function only allow's 2 parameter's, while you are trying to run 4. Have you changed the

function event_add to allow 4 parameter's?

Posted

Re: Exp from leaving people not working

Hey smart guy, news for you... you were wrong all together

exact code was:

$db->query("UPDATE users SET exp=exp+$expgain WHERE userid=$userid");

not the modification that you placed in there.

It was missing a SQL injection all along, like I stated originally. There was nothing wrong with the exp given per attack, and the code you programmed was wrong.

So I got to experience all this headache from a guy who was wrong the whole time? Wow yeah, fail. TYVM...I know who not to hire when it comes time to buy some mods.

Oh and by the way...some people like to take longer by programming things themselves, just to learn something new. So yeah, that's why I didn't hire a coder for this project.

Posted

Re: Exp from leaving people not working

To explain your epic failure of your post. You asked for a % to be given as the exp. So there you are wrong. Not to hire when it come's to mod's. Please do not hire me because i definatly do not have time for a cocky bitch. Bye.

Posted

Re: Exp from leaving people not working

 

To explain your epic failure of your post. You asked for a % to be given as the exp. So there you are wrong. Not to hire when it come's to mod's. Please do not hire me because i definatly do not have time for a cocky bitch. Bye.

Learn to read...I never once asked to inject a % into the SQL. So ty for the help you tried to give...but please go away :)

Posted

Re: Exp from leaving people not working

 

To explain your epic failure of your post. You asked for a % to be given as the exp. So there you are wrong. Not to hire when it come's to mod's. Please do not hire me because i definatly do not have time for a cocky bitch. Bye.

Wow, nice try at trying to still make it look like your right. :roll:

Posted

Re: Exp from leaving people not working

like i said before......might not of explained good i know im not that good at that...

from quick look very early in morning.

$db->query("UPDATE users SET exp=exp+$expgain WHERE userid=$userid");

is missing from your file.

Posted

Re: Exp from leaving people not working

 

like i said before......might not of explained good i know im not that good at that...

from quick look very early in morning.

$db->query("UPDATE users SET exp=exp+$expgain WHERE userid=$userid");

is missing from your file.

Correct i would do

$sql = sprintf("UPDATE `users` SET `exp` = `exp` + '%u' WHERE (`userid` = '%u')", $expgain, $userid);

$db->query($sql);

Posted

Re: Exp from leaving people not working

I had the same problem with my attack not giving exp. In my case it would tell you that you received so much exp (3%), but it would actually remove the exp from the players. In the end I found out it was an image that was not on my server, but was called out for in the code. The problem was in my header, so it was messing up alot of things on my site. This could be your problem especially if your having problems with firefox. I was having loads of them in FF and they turned out to be that.

 

Edit-Just so you all dont start flamming me. If you dont have a query adding the exp to the db you wont get any. So I would also check that as the other posts have said.

Posted

Re: Exp from leaving people not working

 

like i said before......might not of explained good i know im not that good at that...

from quick look very early in morning.

$db->query("UPDATE users SET exp=exp+$expgain WHERE userid=$userid");

is missing from your file.

Correct i would do

$sql = sprintf("UPDATE `users` SET `exp` = `exp` + '%u' WHERE (`userid` = '%u')", $expgain, $userid);

$db->query($sql);

If you don't mind explaining for me, since I am new to coding, whats the difference between coding it that way, and coding it

$db->query("UPDATE users SET exp=exp+$expgain WHERE userid=$userid"); ?

BTW, i'm not asking to be a smartass, nor am I typically so harsh to people. I was just tired and annoyed...and really new to computer programming.

Posted

Re: Exp from leaving people not working

search sprintf on php.net

I use it...but when im postin on here i usually don't use it. cuase alot of people get confussed by it..

Its just a string that verifieds data sent to the database......its good to use.

Posted

Re: Exp from leaving people not working

 

Maybe try reading for a bit?

the v2 event_add() function only allow's 2 parameter's, while you are trying to run 4. Have you changed the

function event_add to allow 4 parameter's?

Let me see...

On the mysql class file... 2 parameter as you told...

function event_add($user, $event)

{

$this->query(sprintf("INSERT INTO `event` VALUES('', '%d', '%s', '%d', 0)", $user, $event, unix_timestamp()));

$this->query(sprintf("INSERT INTO `event_log` VALUES('', '%d', '%s', '%d')", $user, $event, unix_timestamp()));

$this->query(sprintf("UPDATE `user` SET new_events=new_events+1 WHERE userid='%d'", $user));

}

And incredibly... on globals file... 3 parameters

function event_add($userid,$text,$connection=0)

{

global $db;

$text=mysql_escape($text);

$db->query("INSERT INTO events VALUES('',$userid,UNIX_TIMESTAMP(),0,'$text')");

$db->query("UPDATE users SET new_events=new_events+1 WHERE userid={$userid}");

return 1;

}

And now i ask, 2 parameters? hell afterall its not 2, maybe 3, and why not 4?

You seem so smart, yet so dumb. You brag about doing mod's with over 5K lines of code and yet you don't even got a clue of what that code is? After all i ask... what are you coding for if you don't even know the damn engine? check again on that "event_add" syntax and you might just find out that is something that effectivelly works as an even, taken somewhere from the log if my memory doesn't fails me.

And yet to explain YOUR epic failure, not EineyEntertainment's one. YOU did mention the % thingy not her. She did had a hint towards the potential solution and you went right to the %.

As you tend to say to other users, State your facts first, open your mouth after.

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