Author Topic: Call of Duty Mod NEED HELP!  (Read 1807 times)

Hey everyone, I have 2 questions.

First off I wanted to make a Call of Duty sort of mod. I made it so if you killed someone, in the center of your screen it says +50. Well, that didn't work.

Also for my 2nd questions, I was wondering what the coding was for resetting a mini-game. You can find my most likely failed attempt at it at line 93.

Code: [Select]
package Cod
{
function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %a)
{
Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %a);

if(1 == 1)
{
if(%client.kills >= 1)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
%client.kills=0;
%killer.kills++;
if(%killer.kills == 2)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 3)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 4)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 5)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 6)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 7)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 8)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 9)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 10)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 11)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 12)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 13)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 14)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 15)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 16)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 17)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills == 18)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills >= 19)
{
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
}
else if(%killer.kills >= 20)
{
messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");
}
else if(%killer.kills >= 20)
{
resetMinigame;
}
activatePackage(Cod);

Wait a second... is HTML compatible with Torque? o_O

Code: [Select]
package Cod {
   function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %a) {
      Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %a);
      %client.kills = 0;
      if(%client $= %killer)
         return;
      %killer.kills++;
      if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
      else if(%killer.kills >= 20) {
         messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");
         if(isObject(%mini = %killer.miniGame))
            %mini.reset(%mini.owner);
      }
   }
};
activatePackage(Cod);

So with RTB Preferences to enable/disable it, it would be...

Code: [Select]
RTB_registerPref("Enable Nuke Script", "Nuke Script", "$ScriptNuke::Enable/Disable", "bool", "Script_Nuke", false, true, false, "");
package Nuke {
   function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %a) {
      Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %a);
      %client.kills = 0;
      if(%client $= %killer)
         return;
      %killer.kills++;
      if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
      else if(%killer.kills >= 20) {
         messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");
         if(isObject(%mini = %killer.miniGame))
            %mini.reset(%mini.owner);
      }
   }
};
activatePackage(Nuke);

Wait a second... is HTML compatible with Torque? o_O
Torque uses TorqueML which is actually fairly different, although it bears similarities to HTML.

Wait a second, I have another problem... On line 9 I have a problem. When the killer kills a player, the killer doesn't get the message, the player that is killed gets it. I tried


Code: [Select]
     if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%killer, "<color:FFFFFF>+<color:00FF00>50", 2);

And...

   
Code: [Select]
  if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%killerPlayer, "<color:FFFFFF>+<color:00FF00>50", 2);

There seems to be many bugs o_O

Wow, could I get my hands on thes script after?

Wow, could I get my hands on thes script after?

I'll put it on either the forums or RTB afterwords, so sure lol. But don't copy pasta or I'll find you -.-

Quote
RTB_registerPref("Enable Nuke Script", "Nuke Script", "$ScriptNuke::Enable", "bool", "Script_Nuke", false, true, false, "");
package Nuke {
   function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %a) {
      Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %a);
        if(!$ScriptNuke::Enable)
           return;

      %client.kills = 0;
      if(%client $= %killer)
         return;
      %killer.kills++;
      if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
      else if(%killer.kills >= 20) {
         messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");
         if(isObject(%mini = %killer.miniGame))
            %mini.reset(%mini.owner);
      }
   }
};
activatePackage(Nuke);

Bold are my changes.

  • You can't have a / in a variable. / is used for divide
  • You can't just add the RTB pref, you need a check to see if the mod is enabled.

Code: [Select]
RTB_registerPref("Enable Nuke Script", "Nuke Script", "pref::scriptNuke::enable", "bool", "Script_Nuke", false, true, false, "");
package Nuke {
   function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %a) {
      Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %a);
        if(!$pref::scriptNuke::enable)
           return;
      %client.kills = 0;
      if(%client $= %killer)
         return;
      %killer.kills++;
      if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
      else if(%killer.kills >= 20) {
         messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");
         if(isObject(%mini = %killer.miniGame))
            %mini.reset(%mini.owner);
      }
   }
};
activatePackage(Nuke);

Quote from: Changes
  • Fixed the fact that RTB pref registration should not contain a $ in the variable name.
  • Now saves the variable even though you restart the server.

Code: [Select]
RTB_registerPref("Enable Nuke Script", "Nuke Script", "pref::scriptNuke::enable", "bool", "Script_Nuke", false, true, false, "");
package Nuke {
   function gameConnection::onDeath(%client, %killerPlayer, %killer, %damageType, %a) {
      Parent::onDeath(%client, %killerPlayer, %killer, %damageType, %a);
        if(!$pref::scriptNuke::enable)
           return;
      %client.kills = 0;
      if(%client $= %killer)
         return;
      %killer.kills++;
      if(%killer.kills > 1 && %killer.kills < 20)
         centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2);
      else if(%killer.kills >= 20) {
         messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");
         if(isObject(%mini = %killer.miniGame))
            %mini.reset(%mini.owner);
      }
   }
};
activatePackage(Nuke);


Dude I must say, I really appreciate your help. But there is still 1 error that you might not have found.

The +50 message on line 12 displays to the player that is killed rather than the killer. I am pretty sure what I did, (change 
Code: [Select]
centerPrint(%client, "<color:FFFFFF>+<color:00FF00>50", 2); to
Code: [Select]
centerPrint(%client.killer, "<color:FFFFFF>+<color:00FF00>50", 2);)

Tell me if I'm right I haven't had a chance to test it.

P.S. I tried centerPrint
Code: [Select]
(%killer, "<color:FFFFFF>+<color:00FF00>50", 2);and
Code: [Select]
centerPrint(%killerPlayer, "<color:FFFFFF>+<color:00FF00>50", 2);


Isn't that 50+ thing possible with events?

try:
Code: [Select]
centerPrint(%killer.client, "<color:FFFFFF>+<color:00FF00>50", 2);


also change:
      if(%client $= %killer)
         return;

to:
      if(%client == %killer)
         return;

$= is to compare strings, but %client is a number

and:
messageAll('',"<color:FFFF00>"@%killer.name@"<color:FFFFFF> got the nuke!");

to:
messageAll('',"<color:FFFF00>"@%killer.getPlayerName()@"<color:FFFFFF> got the nuke!");

in some cases %killer.name will not work.  but getPlayerName()  always works.

Isn't that 50+ thing possible with events?

Probably but that would require a lot of VCE/onPlayerTouch ifVariables and some people don't want to go through that.