Author Topic: Stupid variable issue  (Read 980 times)

I dont know which moron programmed this ATM script, but theres a problem in here which causes anyone who tries to break into an ATM via below always get caught. The reason for this is that %beencaught is always 0.

As for whoever thought a for statement could change that variable, a kick in the balls to them.

On second thought, it could be a jobSO issue.

Would simply changing %beencaught to $beencaught fix this?

Snippit of the suspected code below:

Code: [Select]
%stealchance = getRandom(1,2);
%caughtchance = getRandom(1,4);
%lockoutchance = getRandom(1,3);
%beencaught = 0;

for(%a = 0; %a < ClientGroup.getCount(); %a++)
{
%subClient = ClientGroup.getObject(%a);
if(isObject(%subClient.player) && isObject(%client.player) && %subClient != %client)
{
if(VectorDist(%subClient.player.getPosition(), %client.player.getPosition()) <= 30)
{
if(isObject(JobSO.job[1]) != 1)
%beencaught = 0;
else if(isObject(JobSO.job[1]) != 16)
%beencaught = 0;
else if(isObject(JobSO.job[1]) != 17)
%beencaught = 0;
else if(isObject(JobSO.job[1]) != 18)
%beencaught = 0;
else
%beencaught = 1;
}
}
}
if(%beencaught == 0)
{
messageAll('',"\c3" @ %client.name @ "\c6 has been caught attempting to hack an ATM!");
CityRPGXData.getData(%client.bl_id).valueDemerits += $CityRPGX::pref::hack::demerits;
return;
}
« Last Edit: October 13, 2012, 04:26:07 PM by Randomness »

This just makes no sense. Post the whole function, also if beencaught is false, then why are you saying they've been caught?

And the if checks on the jobso makes no sense to me either.
« Last Edit: October 13, 2012, 05:43:29 PM by elm »

Code: [Select]
function CityRPGXATMBrickData::parseData(%this, %brick, %client, %triggerStatus, %text)
{
if(%triggerStatus !$= "")
{
if(%triggerStatus == true && %client.stage $= "")
{
messageClient(%client, '', "\c6Welcome to BlockATM.");
if(CityRPGXData.getData(%client.bl_id).valueBank > 0)
{
messageClient(%client, '', "\c6- You have \c3$" @ CityRPGXData.getData(%client.bl_id).valueBank SPC "\c6in your account.");
}

messageClient(%client, '', "\c31 \c6- Withdraw money.");
messageClient(%client, '', "\c32 \c6- Hack ATM.");

%client.stage = 0;
}

if(%triggerStatus == false && %client.stage !$= "")
{
messageClient(%client, '', "\c6Logging out..");

%client.stage = "";
}

return;
}

%input = strLwr(%text);

if(mFloor(%client.stage) == 0)
{
if(strReplace(%input, "1", "") !$= %input || strReplace(%input, "one", "") !$= %input)
{
%client.stage = 1.1;

messageClient(%client, '', "\c6Withdraw amount:");

return;
}

if(strReplace(%input, "2", "") !$= %input || strReplace(%input, "two", "") !$= %input)
{
%client.stage = 1.2;
if(CityRPGXData.getData(%client.bl_id).valueEducation >= $CityRPGX::pref::hack::education)
{
%stealchance = getRandom(1,2);
%caughtchance = getRandom(1,4);
%lockoutchance = getRandom(1,3);
%beencaught = 0;

for(%a = 0; %a < ClientGroup.getCount(); %a++)
{
%subClient = ClientGroup.getObject(%a);
if(isObject(%subClient.player) && isObject(%client.player) && %subClient != %client)
{
if(VectorDist(%subClient.player.getPosition(), %client.player.getPosition()) <= 30)
{
if(isObject(JobSO.job[1]) != 1)
%beencaught = 0;
else if(isObject(JobSO.job[1]) != 16)
%beencaught = 0;
else if(isObject(JobSO.job[1]) != 17)
%beencaught = 0;
else if(isObject(JobSO.job[1]) != 18)
%beencaught = 0;
else
%beencaught = 1;
}
}
}
if(%beencaught == 0)
{
messageAll('',"\c3" @ %client.name @ "\c6 has been caught attempting to hack an ATM!");
CityRPGXData.getData(%client.bl_id).valueDemerits += $CityRPGX::pref::hack::demerits;
return;
}
else if(%this.hackable)
{
if(%stealchance == 1)
{
if(%lockoutchance != 1)
{
%stolen = getRandom($CityRPGX::pref::hack::stealmin,$CityRPGX::pref::hack::stealmax);
messageClient(%client,'',"\c6You managed to steal \c3$" @ %stolen @ "\c6 from the ATM.");
CityRPGXData.getData(%client.bl_id).valueMoney += %stolen;
if(%caughtchance == 1)
{
messageAll('',"\c3" @ %client.name @ "\c6 has been caught hacking an ATM!");
CityRPGXData.getData(%client.bl_id).valueDemerits += $CityRPGX::pref::hack::demerits;
}
}
else
{
%this.hackable = 0;
messageClient(%client,'',"\c6Your attempt failed, and you have been locked out of the machine.");
%revivetime = $CityRPGX::pref::hack::revivetime * 60000;
schedule(%revivetime, 0, %this.hackable++);
}
}
else
{
messageClient(%client,'',"\c6Your software malfunctioned. The machine is still hackable.");
}
}
else
{
messageClient(%client,'',"\c6You are locked out of this machine.");
}
}
else
{
messageClient(%client,'',"\c6Your education level must be \c3" @ $CityRPGX::pref::hack::education @ "\c6.");
}
return;
}

messageClient(%client, '', "\c3" @ %text SPC "\c6is not a valid option!");

return;
}

if(mFloor(%client.stage) == 1)
{
if(%client.stage == 1.1)
{
if(mFloor(%input) < 1)
{
messageClient(%client, '', "\c6Error.");

return;
}

if(CityRPGXData.getData(%client.bl_id).valueBank - mFloor(%input) < 0)
{
if(CityRPGXData.getData(%client.bl_id).valueATM < 1)
{
messageClient(%client, '', "\c6Insufficient funds.");

%brick.trigger.getDatablock().onLeaveTrigger(%brick.trigger, (isObject(%client.player) ? %client.player : 0));

return;
}

%input = CityRPGXData.getData(%client.bl_id).valueATM;
}

messageClient(%client, '', "\c6You have withdrawn \c3$" @ mFloor(%input) @ "\c6.");

%brick.trigger.getDatablock().onLeaveTrigger(%brick.trigger, (isObject(%client.player) ? %client.player : 0));

CityRPGXData.getData(%client.bl_id).valueBank -= mFloor(%input);
CityRPGXData.getData(%client.bl_id).valueMoney += mFloor(%input);

%client.SetInfo();
}
return;
}
}

Yeah I don't get it either. I'll probably rewrite this, since it makes so little sense.

change
if(%beencaught == 0) to if(%beencaught == 1)
should work.

It should, but I was worried about the reverse being true, the player might never get caught.

Instead, I've decided to chop out the beencaught variable out and the jobSO things, since beencaught seems to be towards certain jobs, which was a change I intended to make in the first place. If this works, its fixed.
« Last Edit: October 13, 2012, 05:42:13 PM by Randomness »

it appears that they hardcoded a system that is dynamically defined.

eg, jobso is defined when the server loads, based on a job.txt file or something.

I'm not sure why they loop through all clients though... why not just apply the checks to the hacker?

boy this is ugly code :(

This issue has been fixed by chopping unnecessary code out.

I know how you feel, Lugnut. I may one day start RPGX again from scratch.

..or so I thought, but now I have another issue. %this.hackable is always hackable. I'm sure I'm not doing something right, or this was Moppy's code to begin with. Either way, I wouldn't doubt either.

Code: [Select]
if(%this.hackable)
{
if($stealchance == 1)
{
if($lockoutchance != 1)
{
$stolen = getRandom($CityRPGX::pref::hack::stealmin,$CityRPGX::pref::hack::stealmax);
if(JobSO.job[CityRPGXData.getData(%client.bl_id).valueJobID].isCodemaster)
{
$stolen = getRandom($CityRPGX::pref::hack::masterstealmin,$CityRPGX::pref::hack::masterstealmax);
}
messageClient(%client,'',"\c6You managed to steal \c3$" @ $stolen @ "\c6 from the ATM.");
CityRPGXData.getData(%client.bl_id).valueMoney += $stolen;
if($caughtchance == 1)
{
messageAll('',"\c3" @ %client.name @ "\c6 has been caught hacking an ATM!");
CityRPGXData.getData(%client.bl_id).valueDemerits += $CityRPGX::pref::hack::demerits;
}
}
else
{
%this.hackable = 0;
messageClient(%client,'',"\c6Your attempt failed, and this machine has locked itself down.");
%revivetime = $CityRPGX::pref::hack::revivetime * 60000;
schedule(%revivetime, 0, %this.hackable++);
}
}
else
{
messageClient(%client,'',"\c6Your software malfunctioned. The machine is still hackable.");
}
}
« Last Edit: October 13, 2012, 06:18:37 PM by Randomness »

This issue has been fixed by chopping unnecessary code out.

I know how you feel, Lugnut. I may one day start RPGX again from scratch.
Your wasting your time making RPGX based off of CrapRPG, you'd be better off basing it off of DRPG, atleast the saving system doesn't suck horse richard. In reality, you should stop everything you've done and just rewrite from scratch. You'll save yourself a ton of time by just writing it from scratch. And try not to use CityRPG as a reference. It's a bad reference.


Ahem. So back to the issue. Everything works now except %brick.hackable actually changing hackable to 0 instead of 1.

Code: [Select]
if(strReplace(%input, "2", "") !$= %input || strReplace(%input, "two", "") !$= %input)
{
echo(%brick.hackable); // Debug lol.
%client.stage = 1.2;
if(JobSO.job[CityRPGXData.getData(%client.bl_id).valueJobID].isHacker)
{
%stealchance = getRandom(1,2);
%caughtchance = getRandom(1,4);
%lockoutchance = getRandom(1,6);
if(JobSO.job[CityRPGXData.getData(%client.bl_id).valueJobID].isCodemaster)
{
%caughtchance = getRandom(1,6);
%lockoutchance = getRandom(1,8);
}
if(%brick.hackable == 1)
{
if(%stealchance == 1)
{
if(%lockoutchance != 1)
{
%stolen = getRandom($CityRPGX::pref::hack::stealmin,$CityRPGX::pref::hack::stealmax);
if(JobSO.job[CityRPGXData.getData(%client.bl_id).valueJobID].isCodemaster)
{
%stolen = getRandom($CityRPGX::pref::hack::masterstealmin,$CityRPGX::pref::hack::masterstealmax);
}
messageClient(%client,'',"\c6You managed to steal \c3$" @ %stolen @ "\c6 from the ATM.");
CityRPGXData.getData(%client.bl_id).valueMoney += %stolen;
return;
if($caughtchance == 1)
{
messageAll('',"\c3" @ %client.name @ "\c6 has been caught hacking an ATM!");
CityRPGXData.getData(%client.bl_id).valueDemerits += $CityRPGX::pref::hack::demerits;
}
}
else
{
echo("DEBUG: Hello, im supposed to change it to 0."); // Moar debug LOL.
%brick.hackable = 0;
messageClient(%client,'',"\c6Your attempt failed, and this machine has locked itself down.");
%revivetime = $CityRPGX::pref::hack::revivetime * 60000;
schedule(%revivetime, 0, %this.hackable++);
}
}
else
{
messageClient(%client,'',"\c6Your software malfunctioned. The machine is still hackable.");
}
}
else
{
messageClient(%client,'',"\c6This machine is locked down from a previous hack attempt.");
}
}
else
{
messageClient(%client,'',"\c6I dont think I can hack this...");
}
return;
}

the part of that code:

Code: [Select]
else
{
echo("DEBUG: Hello, im supposed to change it to 0."); // Moar debug LOL.
%brick.hackable = 0;
messageClient(%client,'',"\c6Your attempt failed, and this machine has locked itself down.");
%revivetime = $CityRPGX::pref::hack::revivetime * 60000;
schedule(%revivetime, 0, %this.hackable++);
}

FIXED, Never mind. I dont know what the hell I did.

Oh, the checkATM package that assigned the %brick.hackable in the first place was in the wrong script. I moved it to atm.cs to fix it.

Silly me. Issue over.