Now hold on.
I've used that before and got some major issues, but when I use
schedule(0,%brick,delete);
It worked a ton better.
I was telling him the function to use, not giving him code to directly implement. Regardless, the reason you're having an issue is because you're deleting the brick before it's been fully initialized, there are no problems unless you call it inside of a function like onPlant where the brick has been literally just made. So in a way you're right, he should use that, but it's pointless to use that in every scenario when it's only important inside ::onPlant.
I'm not a master coder, or anything like that, I'm just going off of my past experience.
It's "," by the way, whenever I would use just "%brick.delete();" if the brick was planted on or next to anything besides the ground plane it would crash my server, but when replaced by "schedule(0,%brick,delete);" it would not.
Commas delimitate arguments, periods signify a method. Schedule is the function, zero is the first argument, the brick is the second, and delete is the third. So, "%brick,delete();" would cause a syntax error, and "schedule(0.%brick.delete);" would also cause a syntax error.
Wtf guys it's %brick.schedule(0,delete);
Both work equally well. There's absolutely zero reason to use one over the other, it's entirely preference. Actually, schedule() has less overhead, so technically it's more efficient and should be used over ::schedule.
How on earth would that work for anyone? Schedule on its own calls a function, not a method. The object reference in the middle is just an object the schedule is tied to; if it's deleted the schedule cancels.
Also, you never got the client's temp brick. You're testing the brick that was actually planted.
Schedule is laid out like this:
schedule(time, object, method, args, args, ...)
If you replace object with a null value like "" or 0 it will call a global function, if you fill in object with something it will call that function as a method on the object. For example,
schedule(1000, findClientByName(Jetz), delete); would wait a second before deleting you.
Just loaded up single player, planted a brick, got its ID, and entered schedule(0, 13315, delete);. The brick was still there. You are wrong.
You did it wrong. You are wrong. That is how schedule works, if you don't believe me go type
schedule(); in console and watch Torque tell you that you are wrong.
%client = %brick.client;
will fix it right?
Yes, along with
%brick.getGroup().client; if you wanted to do that, but do it your way because that way just protects for if a client reconnects.
package drugDupeCheck {
function fxDTSBrick::onPlant(%brick)
{
%client = %brick.client;
%tb = %client.player.tempBrick;
if((%tb.duplicationBrick || %tb.dupStartBrick) && %tb.getDatablock().isDrug)
{
messageClient(%client, '', "\c0Do not duplicate your drugs.");
schedule(0, %brick, delete); //forget you Jetz
return;
}
parent::onPlant(%brick);
}
};
activatePackage(drugDupeCheck);