Author Topic: Messaging in a package?  (Read 611 times)

Here is my code. Whats wrong with it?

Code: [Select]
package NewPackage
{
function paintProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
%c = %this.player.client;
commandtoclient(%c,'centerprint',"Hey!",2);
Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
};
activatePackage(NewPackage);
« Last Edit: July 15, 2010, 12:39:35 PM by tyler0 »

commandtoclient(%c,'centerprint',"HEy!",2);

Never defined %c.

commandtoclient(%c,'centerprint',"HEy!",2);

Never defined %c.
this
you should add something like

%c = %this.player.client;

so it would be:

Code: [Select]
%c = %this.player.client;

package NewPackage
{
function paintProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
commandtoclient(%c,'centerprint',"HEy!",2);
Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
};
activatePackage(NewPackage);

:/ didn't work

No put the %c = * part in the function, silly.


this is my code now, but not working still...

Server.cs

Code: [Select]
package NewPackage
{
function paintProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
%c = %this.player.client;
commandtoclient(%c,'centerprint',"Hey!",2);
Parent::onCollision(%this,%obj,%col,%fade,%pos,%normal);
}
};
activatePackage(NewPackage);

Wait is paintProjectile::onCollision when you paint a brick?

No. The projectile is the projectile. And the collision is modded so the color of %col is set to the player's current color.

Try naming your package something else.

projectile::onCollision is called when a projectile collides with any object.

%col is set to the player's current color.
%col is the object that the projectile collides with.

%this is this function refers to paintProjectile, either the datablock, or the physical projectile whose collision called onCollision, not sure which.
Change %c = %this.player.client; to %c = %obj.client; for the person who shot the paint can (I think) or %c = %col.client; for the person who it was hit by.
Though for the second, you'd want to use an if(isObject(%c)) before the centerprint.
« Last Edit: July 15, 2010, 01:05:06 AM by Headcrab Zombie »

%col is the object that the projectile collides with.
yeah.

that's what i meant. if the object is class fxDTSBrick, the color is changed to the player's current color.