I want some simple coding. (At least I think it is simple..

Author Topic: I want some simple coding. (At least I think it is simple..  (Read 4302 times)

I would like some simple coding. How would I make it so when you touched a weapon, it would announce something? All I know is On::Collision ... what would I do next?

Also, where would I put it in the code?

If you need my weapon code, I could post it if needed.

Quote from: QuoteForBold
function ItemName::onPickup(%this,%obj,%col,%amount)
{
 messageall('',"Message");
 Parent::onPickup(%this,%obj,%col,%amount);
}

Look for my posts here for how do do coloured messages.

Thanks, Spaceguy!  :cookie: for you!

So, I can put this anywhere in my coding, and, of course, change the words in bold?

Also, how would you make it so when you dropped it it said something? (Probably something really simple and easily changeable.)

Also, I would like some code on changing chest color. I attempted:

Code: [Select]
function serverCmdsetred(%this, %client){
      %this.chest = "0";
      %this.chestcolor = "1 0 0 1";
}
« Last Edit: October 06, 2007, 12:47:29 PM by Black Panther »

Code: [Select]
function serverCmdSetRed(%client){
      %client.chest = "0";
      %client.chestcolor = "1 0 0 1";
      %client.ApplyBodyColors();
}

Quote
function serverCmdSetRed(%client){
      %client.chest = "0";
      %client.chestcolor = "1 0 0 1";
      %client.ApplyBodyParts();
      %client.ApplyBodyColors();

}

It changes the Chest variable so it needs to apply body parts too, changing FemChest to normal Chest.

Quote
package drop
{
 function servercmdDropTool(%client,%slot)
 {
  if(!isObject(%client.player.tool[%slot])) return;
  if(%client.player.tool[%slot].getName() $= "ItemName")
  {
   messageall('',"Message");
  }
 }
};activatePackage(drop);

To code fixers:
- Yes, there is a neater way to use ItemName::onThrow, but the arguments are in my BL0002 folder and it would take time to get there.
- It would be neater to check whether %client.player exists first, but since undefined variables are "" it won't glitch up if I reference a nonexistant object's variables. It would take extra checking and be 0.001% slower.
« Last Edit: October 06, 2007, 03:00:16 PM by Space Guy »

Again, could I put that coding anywhere in the weapon .cs?

Yes, you can. Generally it is put at the bottom after all the datablocks have been defined, though.

Also, I know I have done this before, but I forgot...

but how do you make it say, for example:

<Blockland Name Here> has been pwned!

to everyone?

Code: [Select]
function ServerCmdIgotpwned(%client)
{
messageall("",%client.name @ " got pwned!");
}

Should do it.

I believe he means how do you make it so you can say someone else has been pwned, in that case it would be:

Code: [Select]
function serverCmdpwned(%client, %name)
{
    messageAll("","\c6" @ %name @ " \c3got pwned!");
}

You put /pwned <name> (without the <>'s) and it says "(white)<name> (yellow)got pwned!"

Actually, I wanted Aloshi's way...but thanks anyway!

Also, even though this is slightly off topic from the other coding...and I do not think it is simple...but how do you make the mini-game respawn timer higher than 30?
« Last Edit: October 08, 2007, 08:56:13 PM by Black Panther »

Code: [Select]
function ServerCmdIgotpwned(%client)
{
messageall("",%client.name @ " got pwned!");
}

Should do it.

eh, i'm not trying to hijack the thread or any of the like but i'm stuck:

Code: [Select]
function ServerCmdcrimetag(%client, %crime, %reward)
{
messageall( %client.name, " is wanted for ", %crime.name @ " for a reward of", %reward.name);
}

i want it to make it so when you say /crimetag zack stealing 300 it says:

zack is wanted for stealing for a reward of 300

but when i do it all i get is "is wanted for"

Code: [Select]
function serverCmdCrimeTag(%client, %crime, %reward)
{
   messageAll(%client.name @ " is wanted for " @ %crime @ " for a reward of " @ %reward);
}

Code: [Select]
function serverCmdCrimeTag(%client, %crime, %reward)
{
   messageAll(%client.name @ " is wanted for " @ %crime @ " for a reward of " @ %reward);
}

now it doesint even wana work :/

Code: [Select]
function ServerCmdcrimetag(%client, %name, %crime, %reward)
{
 %cl = findClientByName(%name);
 messageall( %cl.name, " is wanted for " @ %crime  @ " for a reward of" @ %reward);
}