Author Topic: Colors  (Read 4179 times)

Hi, I am having a problem with this and have no idea how to go about doing this.

I guess I would modify the death code to send out a function?

Please tell me how to go about doing this. I wouldn't understand "chaeng d4 d3th function n00b".

I'm making a Regeneration mod, and need regen code to be activated when someone dies.
« Last Edit: December 31, 2014, 07:41:46 PM by Johnny Blockhead »

Package and parent gameconnection::onDeath.


package johnDoe
{
   function GameConnection::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc)
   {
      Parent::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc);
      //do stuff
  }
};
activatePackage(johnDoe);

And that would be server sided, correct?


Ok, I am presuming its server-sided.

Here is a code I strung together

Code: [Select]
package TriggerAndRegenCode
{
   function GameConnection::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc)
   {
      Parent::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc);
 
      //Skin Regeneration Code
  switch(%var){case1: White Skin Code case 2: Black Skin Code} //ect
  }
};
activatePackage(TriggerAndRegenCode);

Only problem is, I got this code from Dr. Kirby:

Code: [Select]
fcbn("Player").nodeColor = "blah";

But you would have to state a players name and that means it would only work on one player out of the 50,000.
Is there a better way of doing this (server side)

format the switch properly, first


switch$(%var)
{
  case 1:
   White_Skin_Code();

  case 2:
   Black_Skin_Code();
}


case 1 will be called if %var equals 1 and case 2 will be called if %var is equal to 2

I think I know what you we're trying to do so I'll do it for you with comments explaining what is happening

package TriggerAndRegenCode
{
   function GameConnection::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc)
   {
      parent::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc);  //Parent the function
      %var = getrandom(1,2);  //Get a random number to see which skin the player will have
      switch$(%var)  //Start the switch
      {
         case 1:  //If random var equals 1 do this
         BlackSkinFunction();  //Call Black Skin Code function
         
         case 2:  // If random var equals 2 do this
         WhiteSkinFunction();  //Call White Skin Code function
      }
   }
};
Activatepackage(TriggerandRegenCode);

Thanks for the help Vortex, but I still need to know

Only problem is, I got this code from Dr. Kirby:

Code: [Select]
fcbn("Player").nodeColor = "blah";

But you would have to state a players name and that means it would only work on one player out of the 50,000.
Is there a better way of doing this (server side)

Thanks for the help Vortex, but I still need to know

Tell me what you are trying to do first, I cannot understand fully, but I already see a problem


in fcbn("Player").nodeColor = "blah" the function fcbn is not default, make sure somewhere in the script you include this:

function fcbn(%c)
{
    return findclientbyname(%c);
}


Or just replace fcbn with findclientbyname like so

findclientbyname("Player").nodeColor = "blah"



Later in the script I define fcbn as findclientbyname.

But what I am trying to do is for

White_Skin_Code();
and
Black_Skin_Code();

If I used


findclientbyname("Player").nodeColor = "blah"


It would set a user named "Player"s nodeColor. I want it to work on anyone who happens to join the server and die.

package TriggerAndRegenCode
{
   function GameConnection::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc)
   {
      parent::onDeath(%client, %killerPlayer, %killerClient, %damageType, %damageLoc);  //Parent the function
      %var = getrandom(1,2);  //Get a random number to see which skin the player will have
      switch$(%var)  //Start the switch
      {
         case 1:  //If random var equals 1 do this
         %client.player.nodeColor = "blah";  //Call Black Skin Code function
         
         case 2:  // If random var equals 2 do this
         %client.player.nodeColor = "blah";  //Call White Skin Code function
      }
   }
};
Activatepackage(TriggerandRegenCode);


Now keep in mind that this isn't going to work.

Instead of using the death function, you need to use the respawn function, as the players node will be set when they have no playerobject, so when they do respawn nothing is going to happen.


Now keep in mind that this isn't going to work.

Instead of using the death function, you need to use the respawn function, as the players node will be set when they have no playerobject, so when they do respawn nothing is going to happen.

so
I don't
;=;

Would I just have to replace deaths with respawn

something tells me its more complex then that
;=;

so
I don't
;=;

Would I just have to replace deaths with respawn

something tells me its more complex then that
;=;
luckily it isn't, just find the function called when someone respawns, this can be done by disabling all mods (this isn't necessary but helps a lot), then typing trace(1); into the console, killing yourself, respawning, and seeing what the console called when you respawned.

I did that, but I couldn't find the code that had to do with respawning

The function called whenever someone respawns is spawnPlayer.

function gameConnection::spawnPlayer(%client)

When doing %client.player.nodeColor = "blah";

What would I replace blah with. Hex codes? What format of web coloring?