Author Topic: Value Not Working Correctly  (Read 967 times)

Hello, I've been doing some private development and I'm a novice scripter, so it didn't go so perfectly.

I added this value here:
Code: [Select]
RPDB.addValue("Difficulty", 0);In my view, that added a Difficulty value that is set to 0 by default. If I am wrong please correct me.

That difficulty values shows its role here:
Code: [Select]
function ServerCmdToggleDifficulty(%client)
{
if (%client.RPData.value["Difficulty"] = 0)
{
%client.RPData.value["Difficulty"] = 1;
messageclient(%client, '', "Difficulty has been set to Hardcore");
}
else
{
%client.RPData.value["Difficulty"] = 0;
messageclient(%client, '', "Difficulty has been set to Normal");
return;
}
}
But for some reason, when I use /toggledifficulty it says Difficulty has been set to normal for however many times I enter the command /toggledifficulty. I am currently aiming for it to switch between Hardcore and Normal so if someone could show me how I could make it work that would be great.

And then there is this code:
Code: [Select]
function GameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);

if (%client.RPData.value["Difficulty"] = 1)
{
// Message about Stats
messageClient(%client, '', "\c6Your stats reset due to your difficulty setting.");
%client.RPData.value["tools"] = "";
%client.RPData.clear();
}
else
{
// Lose tools and Clear Stats
if (isObject(%client) && %client.isInRP())
{
%client.RPData.value["tools"] = "";
}
}
}
That was supposed to be determined by the Difficulty but whenever I die it says Your stats reset due to difficulty setting when ever I just start the game or use the /toggledifficulty command.

When I use the /toggledifficulty command it says my difficulty was set to normal but when I die after using the /toggledifficulty command, it still resets my stats. If anyone could post any fixes or could teach me how to fix these scripts it would be great. Thanks!

--Sgt. Gary

do RPDB.dump(); and tell me if you find the function "addValue" on there.

It's there because the other RP scripts use add value and are functioning properly.

It's there because the other RP scripts use add value and are functioning properly.
Because they made the function, most likely.

post the RPDB::addValue(%this, %name, %value) function here.

It's irrelevant. I won't be posting it.

.............. I won't be helping you then.
not cause of some stuffty reason - because i can't.

Don't know if this is a whole solution, but:
Code: [Select]
if (%client.RPData.value["Difficulty"] = 0)
{
The equal sign should be doubled:
Code: [Select]
if (%client.RPData.value["Difficulty"] == 0)
{
^in multiple cases

Eh... Why didn't you told me? :/

Don't know if this is a whole solution, but:
Code: [Select]
if (%client.RPData.value["Difficulty"] = 0)
{
The equal sign should be doubled:
Code: [Select]
if (%client.RPData.value["Difficulty"] == 0)
{
^in multiple cases

Yes my good friend told me this also, thanks.