Author Topic: Getting a projectile's source item's user's client  (Read 2247 times)

In the ProjectileData::onDamage function, there's an argument for the projectile's object. I want to get this object's user's client. I know it'll be something like:
Code: [Select]
%obj.sourceObject.getImage().getUser().getClient()
but obviously that is not actual code. How would I go about doing this?

Do you want the client (GameConnection) that fired the projectile? (isObject(%obj.sourceClient) ? %obj.sourceClient : %obj.client)

Do projectiles have a sourceClient variable? I didn't know that.

I think so (I can't remember tbh).


Using %obj.sourceClient doesn't result in a syntax error but does not allow me to send a messageClient. Is it a game connection or just client number or something?

Using %obj.sourceClient doesn't result in a syntax error but does not allow me to send a messageClient. Is it a game connection or just client number or something?
Well it's technically both. Are you doing this?
Code: [Select]
messageClient(%obj.sourceClient, '', "text");


Could you post the whole relevant script?

I thought it was %obj.sourceobject.client ...

I thought it was %obj.sourceobject.client ...
That will work but %obj.sourceClient is usually defined as well.

Here's all it is right now.
Code: [Select]
ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
messageClient(%obj.sourceClient,' ',"Bla Bla Bla Test");
Parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}
This is contained in a package I activate.
« Last Edit: October 09, 2011, 10:58:09 PM by Unicide »


function ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
messageClient(%obj.sourceClient,' ',"Bla Bla Bla Test");
Parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}

It's there in the actual thing. I wrote that from memory.

Here's all it is right now.
Code: [Select]
ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal)
{
messageClient(%obj.sourceClient,' ',"Bla Bla Bla Test");
Parent::damage(%this,%obj,%col,%fade,%pos,%normal);
}
This is contained in a package I activate.
I tested this and it works fine.