Author Topic: Overwriting centerPrints?  (Read 1382 times)

My script doesn't work the way I wanted. A friend of mine told me the centerPrints were overwritting each other. He told me to use schedules, I tried to search for a solution but didn't find any. May anyone fix it please.

Quote from: server.cs
function serverCmdpoints(%client)
{
   commandToClient(%client, 'bottomPrint', "<color:FFFF00>You have" SPC %client.points SPC "points");
}
package test
{
   function gameConnection::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc, %y, %x)
   {
   parent::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc, %y, %x);
   %playername=%sourceClient.getPlayerName();
   %killedname=%client.getPlayerName();
   if(%sourceClient==0)
   {
      %playername="the enviroment";
   }   
   if(%client!=%sourceClient)
   {
   commandToClient(%sourceClient, 'centerPrint', "<color:FFFF00>You 0wn3d" SPC %killedname SPC "\nYou won 1 point",3,2);
   %client.centerPrint("<color:FFFF00>You died haha\nYou got 0wn3d by" SPC %playername SPC "\nYou lost 1 point",3,3);
   %client.points--;
   %sourceClient.points++;
   }
   else
   {
   commandToClient(%client, 'centerPrint', "<color:FFFF00>You died haha\nYou got 0wn3d by" SPC %playername SPC "\nYou lost 1 point",3,3);
   %client.points--;
   }
   %client.spawnPlayer();
   serverCmdpoints(%client);
   serverCmdpoints(%sourceClient);
   echo(%sourceClient);
   echo(%playername);
   echo(%client);
   echo(%killedname);
   }
};

activatePackage(test);

Quote from: part that isn't working
if(%client!=%sourceClient)
   {
   commandToClient(%sourceClient, 'centerPrint', "<color:FFFF00>You 0wn3d" SPC %killedname SPC "\nYou won 1 point",3,2);
   %client.centerPrint("<color:FFFF00>You died haha\nYou got 0wn3d by" SPC %playername SPC "\nYou lost 1 point",3,3);
   %client.points--;
   %sourceClient.points++;
   }
   else
   {
   commandToClient(%client, 'centerPrint', "<color:FFFF00>You died haha\nYou got 0wn3d by" SPC %playername SPC "\nYou lost 1 point",3,3);
   %client.points--;
   }

Thank you!

Schedule the 2nd centerPrint like this:
Code: [Select]
%client.schedule(%timeInMS,0,'centerPrint',%message,%timeInSeconds);

I changed the thing to that and it still didn't work :/

Quote from: server.cs
function serverCmdpoints(%client)
{
   commandToClient(%client, 'bottomPrint', "<color:FFFF00>You have" SPC %client.points SPC "points");
}
package test
{
   function gameConnection::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc, %y, %x)
   {
   parent::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc, %y, %x);
   %playername=%sourceClient.getPlayerName();
   %killedname=%client.getPlayerName();
   %client.spawnPlayer();
   if(%sourceClient==0)
   {
   commandToClient(%client, 'centerPrint', "<color:FFFF00>You got 0wn3d by gravity\nYou lost 1 point",3,2);
   %client.points--;
   }
   else if(%client!=%sourceClient)
   {
   commandToClient(%sourceClient, 'centerPrint', "<color:FFFF00>You 0wn3d" SPC %killedname SPC "\nYou won 1 point",3,2);
   %client.schedule(100,0,'centerPrint',"<color:FFFF00>You got 0wn3d by" SPC %playernamename SPC "\nYou lost 1 point",3);
   %client.points--;
   %sourceClient.points++;
   }
   else
   {
   commandToClient(%client, 'centerPrint', "<color:FFFF00>You got 0wn3d by yourself\nYou lost 1 point",3,3);
   %client.points--;
   }
   serverCmdpoints(%client);
   serverCmdpoints(%sourceClient);
   echo(%sourceClient);
   echo(%playername);
   echo(%client);
   echo(%killedname);
   }
};

Did I do anything wrong?

100 milliseconds is one tenth of a second.

Use 3000 milliseconds, as you have the first centerPrint set to last for 3 seconds.

But that would take 3seconds for the player who got killed to receive the message

I don't think you are understanding what I mean.


Quote
commandToClient(%sourceClient, 'centerPrint', "<color:FFFF00>You 0wn3d" SPC %killedname SPC "\nYou won 1 point",3,2);
%client.schedule(100,0,'centerPrint',"<color:FFFF00>You got 0wn3d by" SPC %playernamename SPC "\nYou lost 1 point",3);

It's to appear a message on who killed and who got killed. But I already tested and it does nothing. Not even with normal centerPrints or schedules.

And thank you for helping Space Guy, but I already knew it was milliseconds.

   echo(%sourceClient);
   echo(%playername);
   echo(%client);
   echo(%killedname);


Apply a getClassName(); to each variable, and it'll tell you if it's a GameConnection, or a Player.

Quote from: contents of console
17561(%sourceClient)
Olaf(%playername)
7543(%client)
MysteryGuy(%killedname)
GameConnection(%sourceClient)
Unable to find object "Olaf" attempting to call function "getClassName"(%playername)
GameConnection(%client)
Unable to find object "MysteryGuy" attempting to call function "getClassName"(%killedname)

I copied that from console by hand, so the "Unable to find object "Olaf" attempting to call function "getClassName" is not the complete sentence, or else people would leave my testing server.

That's what happens with:
Quote
echo(%sourceClient);
echo(%playername);
echo(%client);
echo(%killedname);
echo(%sourceClient.getClassName());
echo(%playername.getClassName());
echo(%client.getClassName());
echo(%killedname.getClassName());

%sourceClient and %client, which I used are both GameConnections

There are only 5 arguments
%this, %killerPlayer, %killerClient, %damageType, %damageLoc

%this is the killed client, I just name it like that

Ok, I changed it to this:
Quote
(...)
package test
{
   function gameConnection::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc)
   {
   parent::onDeath(%client, %sourceObject, %sourceClient, %damageType, %damLoc);
   %playername=%sourceClient.getPlayerName();
   %killedname=%client.getPlayerName();
(...)

And I believe I can still use the args as I set them right?

Currently I have no one to test with this script too though, got to wait for someone to give me feedback.Tested, doesn't work.
« Last Edit: November 06, 2009, 07:36:47 PM by Mystery Guy »

Bump, I still need help.

I heard schedules can only be run after 33 seconds, and not 0, is that true?

That is what happens with events, although it might just be to stop noobs to fire infinite projectiles in less than one second.
« Last Edit: November 08, 2009, 06:49:17 PM by Deriboy »

That is what happens with events, although it might just be to stop noobs to fire infinite projectiles in less than one second.
Well if you're not a handicapped who sets their projectile limit very high. It would also start a non-terminating loop.

Well if you're not a handicapped who sets their projectile limit very high. It would also start a non-terminating loop.

There are people who do that...