Author Topic: Return and Else Scripts  (Read 1319 times)

try
      if(%client.isAdmin)
      {

instead of
      if (%client.isAdmin)
      {

otherwise I dunno.

It will only attempt to clear the client's data if they either don't exist or they're not part of the RP.

It will only attempt to clear the client's data if they either don't exist or they're not part of the RP.

Why is that and how can I fix it?

There is no Syntax.
Now here's a pet peeve of mine
Lesson 1: What the term syntax means. It's basically the structure of arranging your code; like grammar. If you say your code has no syntax, it wouldn't make sense at all. The term you're looking for is syntax error


try
-snip-
otherwise I dunno.
I don't see what you did other than remove a space, which doesn't make a difference.

Why is that and how can I fix it?
Because of this:
Code: [Select]
if (isObject(%client) && %client.isInRP())
      return;
Remove the return and put the next two lines in brackets.

Try this code. I put it in an if..else structure like you were attempting to do, so you can learn from that
Code: [Select]
function GameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);

if (%client.isAdmin)
{
// Message about Stats
messageClient('', "<color:ffffff>Your stats have been preserved because you are admin.");
}
else
{
// Lose tools and Clear Stats
if (isObject(%client) && %client.isInRP())
{
%client.RPData.value["tools"] = "";
%client.RPData.clear();
}
}
}

(These two only apply if your code is all original, if you're working off an already made RP, ignore these)
Post the GameConnection::isInRP function
Is %client.RPData even an object, or are you trying to just arbitrarily create field names?

I don't see what you did other than remove a space, which doesn't make a difference.
I didn't think it did, I was trying to be safe rather than sorry

Now here's a pet peeve of mine
Lesson 1: What the term syntax means. It's basically the structure of arranging your code; like grammar. If you say your code has no syntax, it wouldn't make sense at all. The term you're looking for is syntax error

Sorry bout dat

I'll try the code right now, and thanks for the else part!

Try this:

Code: [Select]
// When the players gets killed
function GameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc)
{
Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %damageLoc);    
if(%client.isAdmin)
{
// Message about Stats
messageClient('', "<color:ffffff>Your stats have been preserved because you are admin.");
%client.RPData.value["tools"] = "";
return;
}
// Lose tools and Clear Stats
if(!isObject(%client) || !%client.isInRP())
return;

%client.RPData.value["tools"] = "";
%client.RPData.clear();
}
I fixed up the code like I said to earlier, on that last if statement

And lugnut, where did you get the idea that a space after if makes any sort of difference? Because it doesn't make any difference.

I didn't think it did, I was trying to be safe rather than sorry