Author Topic: Get client from player.  (Read 2416 times)

Any idea how to do this?


%player.client

Wait, what?
Really, that's it?
Gonna try it.

Code: [Select]
package lavadeath
{
function FxDTSBrick::onplayertouch(%brick,%player)
{
echo("t");
%client = %player.client;
if(%brick.type = "lava" && %client.lavasuit < 1)
{
%player.kill();
}
Parent::onplayertouch(%brick,%player);
}
};
deactivatepackage(lavakill);
activatepackage(lavakill);

This does not kill people, it does not work, any ideas why?

if(%brick.type = "lava" && %client.lavasuit < 1)
There's an issue here, %brick.type is being assigned "lava" on-the-fly. You should have two equal signs for comparison checks.
Now, a binary check of the incorrect code (assuming the client doesn't have a lavasuit):
if(0 && 1)
which is false.

So you need two equal signs.

So you need two equal signs.

You use a $= for string comparison.

if(%brick.type = "lava" && %client.lavasuit < 1)
There's an issue here, %brick.type is being assigned "lava" on-the-fly. You should have two equal signs for comparison checks.
Now, a binary check of the incorrect code (assuming the client doesn't have a lavasuit):
if(0 && 1)
which is false.

So you need two equal signs.

Here is my new code:
Code: [Select]
package lavadeath
{
function FxDTSBrick::onplayertouch(%brick,%player)
{
echo("t");
%client = %player.client;
if(%brick.type $= "lava")
{
if(%client.lavasuit < 1)
{
%player.kill();
}
}
Parent::onplayertouch(%brick,%player);
}
};
deactivatepackage(lavakill);
activatepackage(lavakill);

It didn't work.

I'm not going to read that poorly formatted code.

Code: [Select]
package lavadeath
{
function FxDTSBrick::onplayertouch(%brick,%player)
{
%client = %player.client;
if(%brick.type $= "lava")  //if the brick the player touched is lava
{
if(%client.lavasuit < 1) //and if the player is wearing a lava suit
{
%player.kill(); //kill the player
}
}
Parent::onplayertouch(%brick,%player); //continue as normal
}
};

deactivatepackage(lavakill);
activatepackage(lavakill);

Better?

fxDTSBrick::onPlayerTouch is only called for bricks which have got events applied to them - for performance enhancement.

fxDTSBrick::onPlayerTouch is only called for bricks which have got events applied to them - for performance enhancement.
I knew it!

fxDTSBrick::onPlayerTouch is only called for bricks which have got events applied to them - for performance enhancement.
Tyvm for this important bit of information.
Any ideas to get around this? :/

Make the lava a brick that starts pre-evented.

Make the lava a brick that starts pre-evented.
That's the only way?
How do I event a brick to have it check the client for a variable then kill it, and how do I insert such a script that though torquescript?

(granted I can do this kind of stuff with VCE and normal events, but this scripting events in is new to me)

That's the only way?
How do I event a brick to have it check the client for a variable then kill it, and how do I insert such a script that though torquescript?

(granted I can do this kind of stuff with VCE and normal events, but this scripting events in is new to me)
You could just have a simple setColor[Red] event and do the rest by script if you wanted, OR you could actually make this special thing an event of its own.