I need help with this code!


#1

Hi

I ned help with this code

is something wrong with it?

The Sentry Skill upgarde didn’t work! Why?

This is the code:

function Trainupgrade($user,$type) { if($type=='spy'){ $pris=pow(2,$user->currentSpySkill)*12000; if($pris <= ($user->gold+$user->bank)){ if($pris>$user->gold){ $bank=$pris-$user->gold; $pris=$user->gold; } $q = @mysql_query("update `UserDetails` set currentSpySkill=currentSpySkill+'1', gold=gold-'$pris', bank=bank-'$bank' where ID='$user->ID' "); }else return 'NO GOLD LEFT!!!';} if($type=='spy'){ $pris=pow(2,$user->currentSentrySkill)*12000; if($pris <= ($user->gold+$user->bank)){ if($pris>$user->gold){ $bank=$pris-$user->gold; $pris=$user->gold; } $q = @mysql_query("update `UserDetails` set currentSentrySkill=currentSentrySkill+'1', gold=gold-'$pris', bank=bank-'$bank' where ID='$user->ID' "); }else return 'NO GOLD LEFT!!!';} if($type=='bank'){ $pris=pow(2,$user->bankSkill)*100000; if($pris <= ($user->gold+$user->bank)){ if($pris>$user->gold){ $bank=$pris-$user->gold; $pris=$user->gold;


#2

This looks a suspicious lot like this thread.

Again, these apply:

  • What errors are you getting?
  • What have you tried to solve these problems?
  • Did you search the internet, and if so, which results did you get (and why did they not solve your problem)?

#3

if u don’t know the answer plz don’t reply to my thread!!!

no need for your BIG help!


#4

First off…

He did answer your question with a couple more questions…

Questions which are needed to help solve whatever problem it is you have, which we are quite unsure as to what this might be at the moment.

Contrary to popular belief, we have not come accross every problem in every script before. So by you saying:

I ned help with this code

is something wrong with it?

The Sentry Skill upgrade didn’t work! Why?

How are we supposed even began to troubleshoot. We are here to help people by own free will, we don’t need to be chastised by someone coming to us looking for free help.


#5

if u search for the error better to right this PHD article I think you will be good helper for others!!

AGAIN, I don’t wont PHD articles here, I need help!

If you don’t know how to do it…just keep your mouth SHUT !!


#6

Ok, did you or did you not create this script yourself??

If you did not, don’t bother us with 3rd party scripts, maybe you should check with the orginial programmer. We are not here to sit and answer questions about someones elses scripts, in which you do not even know how it works.

And if I am understanding you correctly your telling me to go search for the answer to your problem, if you are to lazy to do this research yourself, then we are to lazy to help you.

Have a nice day!


#7

Thanx mate for your reply, but again I searched the forum and I did not find the answer, coz I am not a coder!

I know some php knowlodge but not that much

I give the hint to you guys to help me with it, I thought it is easy for you and not that much, I am in phphelp.com forum right?

Anyway, if you can help me plx do so, if not I will keep searching

btw, I tried to contact the programmer but he never reply since 2 months now!

Thanx again mate!


#8

Yes, this is the PHPHelp.com forum, not the PHPFixMyScript.com forum. If you cannot contact the original author of this script, you might want to turn to another script, or, which is what we DO provide some sort of help on, write your own.

Again, we’re not some sort of psychics, we don’t know what goes wrong in your script. So we ask for hints: are you getting any errors? What is it (not) doing that it should(n’t) do? What have you tried to solve these problems? I’m pretty sure you searched and didn’t find anything, but that doesn’t help us any further.

On a sidenote: I don’t know what the hell you’re talking about with all that PHD crap.


#9

Will first thanx for your reply

about the script…the function should work like this:

when the player press (upgrade Sentry Skill) It should upgarde to the next level of Sentry Skill after deduction the sum of money from the gold he/she got

Every upgrade works fine excpet the (upgrade Sentry Skill), it dosn’t move! And if the player press the upgrade button the error message appers in the page (No Gold Left) but he got enogh gold to buy the next level of Sentry Skill !

Thats all mate!

I am thinking ( after I asked alot and searched lol) that the error maybe comes from two php file:
1- (vsys.php)
2- (train.php)

coz these both files got the word and function of (upgrade Sentry Skill ) but I don’t know how to change it to the correct way!

if you want me to attach these two files here I will, but at least I want someone to know what I am talking about :-)

regards and sorry,


#10

See? It’s not that hard :slight_smile: You actually showed some gratitude to what we are doing, asked us if we could assist you, gave us some more information with which we could actually do something, and I’ve put some effort into looking into your problem and finding out what’s wrong.

I just have one more question for you:
If a user upgrades their Spy skill, does their Sentry skill go up as well?

I’m asking you this because I already know why the Sentry Skill upgrade thingy doesn’t work :wink: I took a glance at your code and noticed that you use the following for both Spy Skill upgrade and the Sentry skill upgrade:

[php]if($type==‘spy’){[/php]

Very easy to fix, may be very hard to spot.


#11

YES!

when ther are trying to upgarde the Sentry skill the spy skill goes up!

Now!

How can I fix this code!


#12

By changing the if statement that checks the $type variable for whatever the value of $type is when the Sentry Skill should be upgraded?


#13

right mate!

But i changed the spy code to Sentry but again nothing happned!

i.e.

this one

function Trainupgrade($user,$type) { if($type=='spy'){ $pris=pow(2,$user->currentSpySkill)*12000; if($pris <= ($user->gold+$user->bank)){ if($pris>$user->gold){ $bank=$pris-$user->gold; $pris=$user->gold;

I leave it as it is in (train.php) file

but the other line here

} $q = @mysql_query("update `UserDetails` set currentSpySkill=currentSpySkill+'1', gold=gold-'$pris', bank=bank-'$bank' where ID='$user->ID' "); }else return ',No Gold Left;} if($type=='sentry'){ $pris=pow(2,$user->currentSentrySkill)*12000; if($pris <= ($user->gold+$user->bank)){ if($pris>$user->gold){ $bank=$pris-$user->gold; $pris=$user->gold;


#14

Can this code give you a hint mate!

[code]<?
include “vsys.php”;
$user=getUserDetails($_SESSION[‘isLogined’],"");
if($cgi[train]){
$wal=round($wal);
if($cgi[atsold]){
$wal=$cgi[atsold];$typ=0;
$detail.=Train($user,$wal,$typ);
$buylog=BuyLog(AT,$wal,$cgi[atsold],$user,1,$HTTP_SERVER_VARS[‘REMOTE_ADDR’]);
$user=getUserDetails($_SESSION[‘isLogined’],"
");
}
if($cgi[defsold]){
$wal=$cgi[defsold];$typ=1;
$detail.=Train($user,$wal,$typ);
$buylog=BuyLog(DE,$wal,$cgi[atsold],$user,0,$HTTP_SERVER_VARS[‘REMOTE_ADDR’]);
$user=getUserDetails($_SESSION[‘isLogined’],"");
}
if($cgi[spy]){
$wal=$cgi[spy];$typ=2;
$detail.=Train($user,$wal,$typ);
$buylog=BuyLog(SP,$wal,$cgi[atsold],$user,1,$HTTP_SERVER_VARS[‘REMOTE_ADDR’]);
$user=getUserDetails($_SESSION[‘isLogined’],"
");
}
if($cgi[sentry]){
$wal=$cgi[sentry];$typ=5;
$detail.=Train($user,$wal,$typ);
$buylog=BuyLog(SE,$wal,$cgi[atsold],$user,0,$HTTP_SERVER_VARS[‘REMOTE_ADDR’]);
$user=getUserDetails($_SESSION[‘isLogined’],"*");
}
if($cgi[reat]){
$wal=$cgi[reat];$typ=3;
$detail.=Train($user,$wal,$typ);
}
if($cgi[redef]){
$wal=$cgi[redef];$typ=4;
$detail.=Train($user,$wal,$typ);
}

	//echo "--$typ--";
	header("Location: train.php?strErr=$detail");
	}

if($cgi[spyupgrade]){$detail=Trainupgrade($user,'spy');header("Location: train.php?strErr=$detail");}
	if($cgi[sentryupgrade]){$detail=Trainupgrade($user,'spy');header("Location: train.php?strErr=$detail");}
if($cgi[unitupgrade]){$detail=Trainupgrade($user,'unit');header("Location: train.php?strErr=$detail");}
if($cgi[unitupgradeall]){$detail=TrainupgradeAll($user,'unitall');header("Location: train.php?strErr=$detail");}
if($cgi[unitupgradeallwithout]){$detail=TrainupgradeAllWithout($user,'unitall');header("Location: train.php?strErr=$detail");}

?>[/code]


#15

You seem to be using ‘spy’ in multiple places where ‘sentry’ should have been, as far as I can tell. What you need to do is find all occurrences of ‘spy’ (most text editors have a nifty little search function for that), and see if it shouldn’t be ‘sentry’ instead.


#16

Thanx Zyppora,

I tried this way, and I searched all ‘spy’ word using the dreamweaver in the whole script folder, and I change the another ‘spy’ word to ‘sentry’ but nothing happned!

Sorry!