Author Topic: Breaking onActivate  (Read 2279 times)

I used
Code: [Select]
function fxDTSBrick::onActivate(%obj, %player, %client, %pos, %vec)
{
%data = %obj.getDataBlock();

if(%data.getid() == SellBrickData.getId())
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
}

Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
and it breaks everything else using the same function. Please help D:
« Last Edit: November 08, 2011, 01:18:23 PM by jes00 »

I used
Code: [Select]
package test {
function fxDTSBrick::onActivate(%obj, %player, %client, %pos, %vec)
{
%data = %obj.getDataBlock();

if(%data.getid() == SellBrickData.getId())
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
}

Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
};activatepackage(test);
cough cough package it cough cough

cough cough package it cough cough
*cough* *cough* It's not in the same .cs as the brick *cough* *cough*

*cough* *cough* It's not in the same .cs as the brick *cough* *cough*
just test it ;_;

just test it ;_;
................... Thank you Cheese.

Though I did need to do this instead
Code: [Select]
package JunkTrunk
{
function fxDTSBrick::onActivate(%obj, %player, %client, %pos, %vec)
{
%data = %obj.getDataBlock();

if(%data.getid() == SellBrickData.getId())
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
}
else
{
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
}
};
activatePackage(JunkTrunk);

EDIT: ............ IT STOPPED WORKING D:
« Last Edit: November 08, 2011, 01:18:41 PM by jes00 »

Code: [Select]
package JunkTrunk
{
function fxDTSBrick::onActivate(%obj, %player, %client, %pos, %vec)
{
%data = %obj.getDataBlock();

if(%data.getid() == SellBrickData.getId())
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
}
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
};
activatePackage(JunkTrunk);

Since you're only doing this for one datablock it can be simplified significantly and wouldn't need to be packaged.
Code: [Select]
function SellBrickData::onActivate(%obj, %player, %client, %pos, %vec)
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}

Since you're only doing this for one datablock it can be simplified significantly and wouldn't need to be packaged.
Code: [Select]
function SellBrickData::onActivate(%obj, %player, %client, %pos, %vec)
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
true. :P

Since you're only doing this for one datablock it can be simplified significantly and wouldn't need to be packaged.
Code: [Select]
function SellBrickData::onActivate(%obj, %player, %client, %pos, %vec)
{
messageAll('', "\c2" @ %client.name @ " clicked the test brick!");
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
Thanks Amade!

Now how could I make a function that checks if %client.Ore is above one and if it is sells %client.Ore for one gold each and tells you how much it sold for? and if %client.Ore is below one it says "You do not have any ore to sell"?
« Last Edit: November 09, 2011, 07:12:34 AM by jes00 »

Thanks Amade!

Now how could I make a function that checks if %client.Ore is above one and if it is sells %client.Ore for one gold each and tells you how much it sold for? and if %client.Ore is below one it says "You do not have any ore to sell"?
I'm having trouble believing you're unable to do this. Have you tried to script this?

I'm having trouble believing you're unable to do this. Have you tried to script this?
Err, yes. I tried to have the onActivate function call another function that calls itself to sell the ore. but then it would give you a chat message every time it sells one ore : /

Code: [Select]
function SellBrickData::onActivate(%obj, %player, %client, %pos, %vec)
{
if(%client.ore <= 1)
{
%client.gold += %client.ore;
messageClient(%client'',"\c6You got \c3" @ %client.ore @ " \c6gold and you now have \c3" @ %client.gold @ "\c6 gold.");
%client.ore = 0;
}
messageClient(%client,'',"\c3You need more than 1 ore to sell ore.");
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}

Code: [Select]
function SellBrickData::onActivate(%obj, %player, %client, %pos, %vec)
{
if(%client.ore >= 1)
{
%client.gold += %client.ore;
messageClient(%client'',"\c6You got \c3" @ %client.ore @ " \c6gold and you now have \c3" @ %client.gold @ "\c6 gold.");
%client.ore = 0;
}
messageClient(%client,'',"\c3You need more than 1 ore to sell ore.");
Parent::OnActivate(%obj, %player, %client, %pos, %vec);
}
Does not work but also does not break onActivate event.
Code: [Select]
package sellBrickOnActivate
{
function SellBrickData::onActivate(%obj, %player, %client, %pos, %vec)
{
Parent::onActivate(%obj, %player, %client, %pos, %vec);

if(%client.ore <= 1)
{
%client.gold += %client.ore;
messageClient(%client,'',"\c6You sold your resources for  \c3" @ %client.ore @ " \c6gold.");
%client.ore = 0;
}
messageClient(%client,'',"\c3You do not have enough resources to sell.");
}
};
activatePackage(sellBrickOnActivate);
« Last Edit: November 20, 2011, 03:12:30 PM by jes00 »

Change if(%clien.tOre <= 1) to if(%client.Ore > 0)

Its pretty obvious, you should spend lest time having people write code for you, and more time reading torque script documents to learn the basics.

Change if(%client.Ore <= 1) to if(%client.Ore > 0)
It's pretty obvious, you should spend less time mashing, and more time spellchecking.