Author Topic: Using FxDTSBrick::onactivate?  (Read 1058 times)

Ok so i wanna learn how this thing works. I'm guessing it can works like the event "onActivate". I want to get the datablock of the obj the client clicks so that i can send a message to the client saying what id the datablock is. Here is a script i found/made:

Code: [Select]
package onActivate
{
        function FxDTSBrick::onactivate(%brick,%client,%loc,%rot)
        {
connectToClient(%client, 'centerPrint', %brick @ %client @ %loc @ %rot,3);
Parent::onactivate(%brick,%client,%loc,%rot);
        }
};
activatepackage(onActivate);

Also what does %loc and %rot mean?

From what i can see from the name it would mean location and rotation.
(loc = location, rot is rotation)

From what i can see from the name it would mean location and rotation.
(loc = location, rot is rotation)

Ok thanks. For some reason this script isn't working :(

Code: [Select]
package onActivate
{
        function FxDTSBrick::onactivate(%brick,%client,%loc,%rot)
        {
centerPrint("Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);
Parent::onactivate(%brick,%client,%loc,%rot);
        }
};
activatepackage(onActivate);

you're trying to centerprint nothing

what

When you want to know something better use "echo("Puttexthere");"
It displays the to be displayed text in the console! :D

you're trying to centerprint nothing

what

Heres how i did my centerPrint:

centerPrint(%client,"Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);

Its still messed up some how.

commandToClient(%client, 'centerPrint', ...

commandToClient(%client, 'centerPrint', ...

Ok so i fixed it but still nothing :/

Here is the function so far:

Code: [Select]
package onActivate
{
        function FxDTSBrick::onactivate(%brick,%client,%loc,%rot)
        {
echo("Hello i am an echo lol1");
commandToClient(%client, 'centerPrint',"Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);
echo("Hello i am an echo lol2");
Parent::onactivate(%brick,%client,%loc,%rot);
echo("Hello i am an echo lol3");
        }
};
activatepackage(onActivate);

All three echos are displayed in the command prompt
« Last Edit: June 06, 2011, 06:14:49 PM by tyler0 »

Could i get someone to look at the script above? I still haven't got it to work and seems like this should be a simple script. Weird that it isn't working....

Change this:
commandToClient(%client, 'centerPrint',"Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);

To this:
%client.centerPrint("Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);

Change this:
commandToClient(%client, 'centerPrint',"Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);

To this:
%client.centerPrint("Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);

Changed it and still didn't work :/ this is the current function:
Code: [Select]
package onActivate
{
        function FxDTSBrick::onactivate(%brick,%client,%loc,%rot)
        {
echo("Hello i am an echo lol1");
%client.centerPrint("Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);
echo("Hello i am an echo lol2");
Parent::onactivate(%brick,%client,%loc,%rot);
echo("Hello i am an echo lol3");
        }
};
activatepackage(onActivate);


Here's the result from the echos:
Code: [Select]
Hello i am an echo lol1
Add-Ons/Script_onActivate/server.cs (6): Unknown command centerPrint.
  Object (10074) Player -> Player -> ShapeBase -> ShapeBase -> GameBase -> Scene
Object -> NetObject -> SimObject
Hello i am an echo lol2
Hello i am an echo lol3
% ←←

Change %client to the last argument of the onActivate function, instead of the second. And put %player where client was.

Change %client to the last argument of the onActivate function, instead of the second. And put %player where client was.

Like this?
Code: [Select]
package onActivate
{
        function FxDTSBrick::onactivate(%brick,%player,%loc,%rot,%client)
        {
echo("Hello i am an echo lol1");
%client.centerPrint("Brick: " @ %brick @ ". Client: " @ %client @ ". Location: " @ %loc @ ". Rotation: " @ %rot,3);
echo("Hello i am an echo lol2");
Parent::onactivate(%brick,%player,%loc,%rot);
echo("Hello i am an echo lol3");
        }
};
activatepackage(onActivate);

changed it and it didn't work. Here is the result:
Code: [Select]
Hello i am an echo lol1
%
Add-Ons/Script_onActivate/server.cs (6): Unable to find object: '0.00572854 0.33
6028 -0.941835' attempting to call function 'centerPrint'
BackTrace: ->[PirateCannonPackage]Armor::onTrigger->[TankPackage]Armor::onTrigge
r->Armor::onTrigger->Player::ActivateStuff->[onActivate]fxDTSBrick::onActivate
%
Hello i am an echo lol2
Hello i am an echo lol3
%

Sorry, my mistake, you need to find the client using %player.client. Remove the %client part altogether.

I'd suggest you use centerPrint(%player.client,...); instead of the other ones, it's the shortest and it doesn't cause errors if the player has no client.

Sorry, my mistake, you need to find the client using %player.client. Remove the %client part altogether.

I'd suggest you use centerPrint(%player.client,...); instead of the other ones, it's the shortest and it doesn't cause errors if the player has no client.
Ahh it was centerPrint(client,message) of course! >_<