Author Topic: Round Debugging Help!  (Read 1096 times)

I fixed up and debugged some of the Murder Mystery code, but when someone dies, it shows who killed them, and when the murderer has killed everyone, the minigame doesnt end. Please help me! I spent 2 hours debugging it and just to find out its still bugged.


Here is the code:

Code: [Select]
forcerequiredaddon("Emote_Alarm");

datablock AudioProfile(ScreamSound)
{
filename = "./scream.wav";
description = AudioClosest3d;
preload = true;
};
function servercmdEnableMM(%client)
{
if(%client.isSuperAdmin)
{
if(isObject(%client.minigame))
{
messageall('', '<font:impact:25><color:FFFF00>%1 <color:FFFFFF>has enabled the Murder Mystery.', %client.name);
activatepackage(MurderMysteryPackage);
MurderMysteryBootUp(%client);
}
else
{
messageclient(%client, '', '<font:impact:25><color:FFFFFF>You must be in a minigame to activate <color:FFFF00>Murder Mystery<color:FFFFFF>.');
}
}
}

function servercmdDisableMM(%client)
{
if(%client.isSuperadmin)
{
if(isObject(%client.minigame))
{
$MMmini.ClearEveryone();
$MMmini = "";
messageall('', '<font:impact:25><color:FFFF00>%1 <color:FFFFFF>disabled murder mystery.', %client.name);
deactivatepackage(MurderMysteryPackage);
}
else
{
messageclient(%client, '', '<font:impact:25><color:FFFFFF>You must be in a minigame to disable <color:FFFF00>Murder Mystery<color:FFFFFF>.');
}
}
}
function servercmdCheat(%client)
{
if(%client.isAdmin)
{
if($murderer !$= "")
{
commandtoclient(%client, 'centerprint', "<font:impact:25><color:FFFFFF>The murderer this round is<color:FFFF00> " @ $murderer @"<color:FFFFFF>. \nGod, why do you have to cheat?",3);
}
}
}

package MurderMysteryPackage
{
function MurderMysteryBootUp(%client)
{
$victims = 0;
$playersleft = 0;
$time = 500;
$MMmini = %client.minigame;
cancel($countDownLoop);
cancel($countDownLoop);
$MMmini.countdown();
$MMmini.UpdateEveryone();

%players = 0;
for(%i = 0; %i < clientgroup.getCount(); %i++) //Populating the bottomPrint and picking the murderper.
{
%person = clientgroup.getObject(%i); //We are not gonna shove a bunch of "if>isObject>Murderer" because we know everyone has respawned and it is impossible to die in 0.000001 seconds... Unless someone joined and then died like they do.
%players++;
%player[%players] = %person;

%person.I = true;
%person.M = false;
%person.Used = false;
%person.camera.mode = "";
}
%RanClient = %player[getRandom(1, %players)];
%RanClient.M = true;
%RanClient.I = false;
%RanClient.isCorpse = false;
if(isObject(%RanClient.player))
{
messageclient(%ranClient, '', "<font:impact:25><color:FFFFFF>You have been selected to be the <color:FFFF00>murderer<color:FFFFFF> this round. Your job is to <color:FF0000>murder everyone<color:FFFFFF>.");
%ranClient.play2d(alarmSound);
$murderer = %ranclient.name;
}
else
{
MurderMysteryBootup(%client); //cycle through until the person has a valid player object.
}
for(%i = 0; %i < clientgroup.getCount(); %i++)
{
%person = clientgroup.getObject(%i);
if(!%person.M && %person.I)
{
if(isObject(%person.player))
{
$playersleft++;
}
}
}
}

function Gameconnection::OnClientEnterGame(%client)
{
parent::OnClientEnterGame(%client);
%client.player.schedule(3000, "kill");
schedule(3000, 0, "messageclient", %client, '', "<font:impact:25><color:FFFFFF>You will participate in the next round.");
%client.UpdateBottomPrint();
}

function MinigameSO::removeMember(%this,%client)
{
if(%client.M && !%client.I)
{
messageall('', "<font:impact:25><color:FFFFFF>The <color:FFFF00>murderer<color:FFFFFF> has left the game. <color:FFFF00>Resetting<color:FFFFFF>...");
%owner = $MMmini.owner;
cancel($countDownLoop);
cancel($countDownLoop);
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
$MMmini.schedule(5000, reset, %owner);
}
if(isObject(%client.player) && !%client.M && %client.I)
{
$playersleft--;
$MMmini.updateeveryone();
}
parent::RemoveMember(%this,%client);
}
function MinigameSO::reset(%this, %client)
{
parent::reset(%this, %client);
MurderMysteryBootUp(%client);
}
function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow)
{
if(%damagetype $= $damagetype::fall)
{
if(%killer != %client)
{
if(!%client.M && %client.I)
{
messageall('', "<font:impact:25><color:FFFF00>"@ %client.name @"<color:FFFFFF> has fallen to a painful death...");
$playersleft--;
echo("An innocent fell to his death.");
$MMmini.Updateeveryone();
scream();
if($MMmini.getNumberOfSurvivors() < 1) //Those idiots killed themselfs off...
{
%owner = $MMmini.owner;
cancel($countDownLoop);
cancel($countDownLoop);
messageall('', "<font:impact:25><color:FFFFFF>The <color:FF0000>murderer<color:FFFFFF>, <color:FFFF00>"@ %killerc.name @"<color:FFFFFF> has murdered everyone. <color:FFFF00>Resetting in 5 seconds...");
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
$MMmini.schedule(5000, reset, %owner);
}
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
else
{
messageall('', "<font:impact:25><color:FF0000>Murderer <color:FFFF00>"@ %client.name @"<color:FFFFFF> has fallen to his death... <color:FFFF00>Resetting minigame in 5 seconds...");
scream();
$MMmini.Updateeveryone();
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
%owner = $MMmini.owner;
$MMmini.schedule(5000, reset, %owner);
cancel($countDownLoop);
echo("The murderer fell to his death.");
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
}
else
{
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
}
%killerc = %killer;
if(!%killerc.M && %killerc.I) //if the killer is not the murderer...
{
if(%damagetype !$= $damagetype::fall) //and the person did not die because he fell...
{
if(!%client.M && %client.I) //if the person whos geting shanked is not the murderer...
{
if(%killer != %client) //the "Addmember" function would screw up if this was not here...
{
%killer.player.kill();
$playersleft--;
messageall('', "<font:impact:25><color:FFFF00>"@ %killerc.name @"<color:FFFFFF> has murdered the innocent<color:FFFF00> "@ %client.name @"<color:FFFFFF> - he has been slayed.");
scream();
echo("An innocent killed another innocent.");
$playersleft--; //cause two people died.
$MMmini.updateEveryone();
if($MMmini.getNumberOfSurvivors() < 1) //Those idiots killed themselfs off...
{
%owner = $MMmini.owner;
cancel($countDownLoop);
cancel($countDownLoop);
messageall('', "<font:impact:25><color:FFFFFF>The <color:FFFF00>murderer<color:FFFFFF> has won the round - Everyone killed eachother. <color:FFFF00>Resetting in 5 seconds...");
echo("They killed themselves off...");
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
$MMmini.schedule(5000, reset, %owner);
}
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
else
{
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
}
else //if the person who is geting raped is the murderer...
{
messageall('', "<font:impact:25><color:FFFF00>Innocents<color:FFFFFF> have succeeded this round. <color:FFFF00>"@ %killerc.name @"<color:FFFFFF> has killed the murderer. <color:FF0000>Murderer<color:FFFFFF>, <color:FFFF00>"@ %client.name @"<color:FFFFFF> is no more. <color:FFFF00>Resetting in 5 seconds...");
scream();
echo("The murderer was killed.");
%owner = $MMmini.owner;
cancel($countDownLoop);
cancel($countDownLoop);
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
$MMmini.schedule(5000, reset, %owner);
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
}
}
else //if the killer is the murderer...
{
if(%damagetype !$= $damagetype::Fall) //There cannot be more than one murderer, so we don't need a bunch of if the client is innocent etc.
{
if(%killer != %client)
{
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
messageall('', "\c3"@ %client.name @"\c6 has come to a bloody death...");
echo("The murderer killed an innocent.");
scream();
$time += 70;
$victims++;
$playersleft--;
$MMmini.upDateEveryone();
if($MMmini.getNumberOfSurvivors() < 1) //Space guy's TDM mod takes care of this, considering that the last player standing wins, so this is pretty much useless.
{
%owner = $MMmini.owner;
cancel($countDownLoop);
cancel($countDownLoop);
messageall('', "<font:impact:25><color:FFFFFF>The <color:FF0000>murderer<color:FFFFFF>, <color:FFFF00> "@ %killerc.name @"<color:FFFFFF> has murdered everyone. <color:FFFF00>Resetting in 5 seconds...");
echo("The murder killed everyone.");
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
$MMmini.schedule(5000, reset, %owner);
}
}
else
{
parent::onDeath(%client, %killerPlayer, %killer, %damageType, %someValueIdontKnow);
}
}
}
}
function servercmdSelf Delete(%client)
{
if($MMmini = "")
{
parent::servercmdSelf Delete(%client);
}
else
{
commandtoclient(%client, 'centerprint', "<font:impact:25><color:FFFFFF>Self Delete is disabled so nobody can chicken out.", 3);
}
}
function MinigameSO::UpdateEveryone(%so)
{
for(%a = 0; %a < %so.member[%a]; %a++)
{
%person = %so.member[%a];

%person.UpdateBottomPrint();
}
}
function MinigameSO::ClearEveryone(%so)
{
for(%a = 0; %a < %so.member[%a]; %a++)
{
%person = %so.member[%a];

commandtoclient(%person, 'bottomprint', "<font:impact:25><color:FFFFFF>...", 0.1);
}
}
function gameconnection::UpdateBottomprint(%client)
{
%font = "<font:impact:25>";
%client.InfoPrint = %font;

//TIME
%client.infoPrint = %client.infoprint @ "<font:impact:25><color:FFFF00> Time: <color:FFFFFF>" @ $time;

//VICTIMS
%client.infoPrint = %client.infoprint @ "<font:impact:25><color:FFFF00> Victims: <color:FFFFFF>" @ $victims;

//SURVIVORS
%client.infoPrint = %client.infoprint @ "<font:impact:25><color:FFFF00> Survivors: <color:FFFFFF>" @ $playersleft;

//STATUS
if(!%client.M && %client.I)
{
%client.infoPrint = %client.infoprint @ "<font:impact:25><color:FFFF00> Status: <color:EEC900>INNOCENT";
}
else
{
%client.infoPrint = %client.infoprint @ "<font:impact:25><color:FFFF00> Status: <color:FF0000>MURDERER";
}
commandToClient(%client, 'bottomPrint', %client.infoPrint);
}
function MinigameSO::getNumberOfSurvivors(%so)
{
%count = 0;

for(%a = 0; %a < %so.member[%a]; %a++)
{
%member = %so.member[%a];

if(isObject(%member) && !%member.M && %member.I) //If the murderer is innocent... continue.
{
%count++;
}
}

return %count; //When this function is called, it will return %count. Example: there are 5 players left, one is the murderer. $MMmini.getNumberOfSurvivors(); -> 4 people left.
}
function MinigameSO::countDown(%so)
{
if($time > 0)
{
$time--;
$countDownLoop = $MMmini.schedule(1000, countDown);
$MMmini.updateeveryone();
}
else
{
messageall('', "<font:impact:25><color:FFFFFF>Innocents have won the round. The murderer ran out of time. <color:FFFF00>Resetting...");
%owner = $MMmini.owner;
cancel($countDownLoop);
cancel($countDownLoop); //Sometimes its right on top of rescheduling, so we need to do it twice.
for(%a = 0; %a < %so.numMembers; %a++)
{
%cl = %so.member[%a];
%cl.setControlObject(%cl.camera);
%cl.camera.setMode("Corpse",%cl.player);
}
$MMmini.schedule(5000, reset, %owner);
}
}
function scream()
{
for(%a = 0; %a < clientGroup.getCount(); %a++)
{
%cl = clientgroup.getObject(%a);
%cl.play2d(ScreamSound);
}
}
   function Armor::onTrigger(%this,%obj,%slot,%val)
   {
switch(%slot)
{
case 0:
%obj.fire = %val;
case 2:
%obj.jump = %val;
case 3:
%obj.crouch = %val;
case 4:
%obj.jet = %val;
}
%oclient = %obj.getControllingClient();
   if(%obj.camera.mode !$= "Corpse")
   {
if(%slot == 4 && %val)
{
     if(%oclient.M && !%oclient.I)
   {
if(!%oclient.Used && %obj.getmountedImage(0) $= ButterflyknifeImage.getid())
{
if(%obj.getmountedImage(0) $= ButterflyknifeImage.getid())
{
if(!%obj.crouch)
{
if(vectorLen(%obj.getVelocity()) < 0.1)
{
      %obj.playthread(2, death1);
scream();
%oclient.Used = true;

%oclient.schedule(100, setControlObject, %oclient.camera);

%obj.schedule(2000, playthread, 2, root);
%oclient.schedule(2000, setControlObject, %obj);

commandtoclient(%oclient, 'centerprint', "<font:impact:25><color:FFFFFF>You have faked your death...", 3);
messageall('', "<font:impact:25><color:FFFF00>"@ %oclient.name @"<color:FFFFFF> has come to a bloody death...");
}
else
{
commandtoclient(%oclient, 'centerprint', "<font:impact:25>color:FFFFFF>You must be standing still for fakekill to work.", 3);
}
}
else
{
commandtoclient(%oclient, 'centerprint', "<font:impact:25><color:FFFFFF>You may not be crouching while attempting fakekill.", 3);
}
}
}
else if(%oclient.Used && %obj.getmountedImage(0) $= ButterflyknifeImage.getid())
{
commandtoclient(%oclient, 'centerprint', "<font:impact:25><color:FFFFFF>You may only use fakekill once per round.", 3);
}
}
else
{
parent::onTrigger(%this, %obj, %slot, %val);
}
}
else
{
parent::onTrigger(%this, %obj, %slot, %val);
}    
}
  }
function Observer::onTrigger(%this,%obj,%trigger,%state)
{
if(!isObject(%obj))
{
return parent::onTrigger(%this,%obj,%trigger,%state);
}
}
};
« Last Edit: May 29, 2013, 05:17:48 PM by Aerodynamic »

It's because hide kills isn't in the folders, in the old fixed up murder mystery, the one, nobot, brian smith, me, and others have has it.

Just look at for hide kills and put it inside the folder, or put it in seperately.

It's because hide kills isn't in the folders, in the old fixed up murder mystery, the one, nobot, brian smith, me, and others have has it.

Just look at for hide kills and put it inside the folder, or put it in seperately.

Will that fix the problem with the rounds not resetting properly?

Will that fix the problem with the rounds not resetting properly?
Nope, just makes it so you can't see who dies.

The problem with the rounds reseting? yeah I could never figured out why the bottom print wouldn't update when the round reset, I would compare the fixed with the buggy one, but I have no reason to.

Nope, just makes it so you can't see who dies.

The problem with the rounds reseting? yeah I could never figured out why the bottom print wouldn't update when the round reset, I would compare the fixed with the buggy one, but I have no reason to.
PM me the comparison?