Author Topic: Karma system not working.  (Read 879 times)

So, I attempted to make a Karma system for SMM. I'm not the best coder, but I tried.

It plain does not work.

Is mafia does work. It is a check in SMM. This is all in a package.

Code: [Select]
function Quit()
{
export("$SMM_PlayerKarma_*", "config/server/Super Murder Mystery/karma.cs");
Parent::Quit();
}

//Karma System
function Projectile::onCollision(%db, %proj, %hit, %a, %b, %c)
{
Parent::onCollision(%db, %proj, %hit, %a, %b, %c);
if ($SMM_PlayerKarma_[%sourceClient.getBL_ID] > 0)
{
%damage -= $SMM_PlayerKarma_[%sourceClient.getBL_ID]/2;
}

if (!%sourceClient.isMafia && !%this.isMafia)
{
if (!%sourceClient == %this)
{
$SMM_PlayerKarma_[%sourceClient.getBL_ID]+= %damage - $SMM_PlayerKarma_[%sourceClient.getBL_ID]/10;
}

if ($SMM_PlayerKarma_[%sourceClient.getBL_ID] >= 500)
{
$SMM_PlayerBans_[%sourceClient.getBL_ID]++;
export("$SMM_PlayerBans_*", "config/server/Super Murder Mystery/bans.cs");
commandtoserver('ban', 0, %sourceClient.getBL_ID, 60*$SMM_PlayerBans_[%client.getBL_ID],"You've been banned for RDMing.");
}
}

//Reward for killing mafia
if (!%sourceClient.isMafia && %this.isMafia)
{
if (!%sourceClient == %this)
{
$SMM_PlayerKarma_[%sourceClient.getBL_ID]-= %damage/2;
}
}

if (%sourceClient.isMafia && %this.isMafia)
{
if (!%sourceClient == %this)
{
$SMM_PlayerKarma_[%sourceClient.getBL_ID]+= %damage - $SMM_PlayerKarma_[%sourceClient.getBL_ID]/10;
}

if ($SMM_PlayerKarma_[%sourceClient.getBL_ID] >= 500)
{
$SMM_PlayerBans_[%sourceClient.getBL_ID]++;
export("$SMM_PlayerBans_*", "config/server/Super Murder Mystery/bans.cs");
commandtoserver('ban', 0, %sourceClient.getBL_ID, 60*$SMM_PlayerBans_[%client.getBL_ID],"You've been banned for RDMing.");
}
}
}

Pastebin link: http://pastebin.com/vcUpmK8x


Are there any syntax errors?

The function should be projectileData::onCollision.
The arguments are %data, %proj, %col, %fade, %pos, %norm.
None of the variables you're using in the function exist. Define them. I think the source client is %proj.sourceClient. Not sure what you're trying to use %this as. The person that got hit's client?
.getBL_ID isn't a variable. It's a function. And there's no underscore in it. So it should be .getBLID();

Are there any syntax errors?
No surprisingly. The gamemode still worked, but not this code.

Edit: %this is suppose to represent to hit client, yes. How would I define the variables?
« Last Edit: January 27, 2016, 08:15:57 PM by rggbnnnnn »

To get the client use %proj.client, make sure you make sure it exists before you do a bit of code so you don't get whacky errors
To get the player use %proj.sourceObject, sometimes there's a chance it could be AIPlayer, and a chance of it being a brick(?)

Maybe important to note, but %sourceClient is not defined or assigned to a specific value at all. It doesn't match any of the parameters under OnCollision. My best guess is that %sourceClient will literally return a blank value every time

Yeah I was gonna say, where the forget does %sourceclient come from?