Blockland Forums > Modification Help
Looping a Schedule/ Obtaining Health of a Vehicle [Fixed]
KuriousGeorge:
Ok, so I'm trying to make a schedule loop. However I'm completely baffled on how to do this. I've thought and thought but I'm just too much of a beginner.
--- Code: ---function armor::onMount(%this,%obj,%col,%slot)
{
%driver = %obj;
%driver_client = %obj.client;
%vehicle = %col; //FIND VEHICLE
%vehicledb = %col.getDatablock(); //FIND THE DATABLOCK OF THE VEHICLE (Like the Jeep datablock), gotta find function variables
schedule(2000,0,commandToClient,%driver_client,'bottomPrint', "Vehicle Health:" SPC %vehicledb.maxDamage - %vehicle.getDamageLevel());
}
--- End code ---
How can I make this repeat itself so that the bottom print constantly renews every second?
Uristqwerty:
The best way is to create a function that reschedules itself.
The IOCCC(Contest where people who write the most unreadable C code, with extreme size restrictions as well) way would be to write a quine function and schedule an eval that incorperates it to "loop" itself.
You should use the first solution.
KuriousGeorge:
Right, that made a load of sense. I'm not quite getting you here.
Chrono:
This shouldn't be on a schedule, but instead tell the vehicle health to all the players in the vehicle when it gets damaged or healed.
KuriousGeorge:
I tried but Vehicle::Damage isn't a call, I was looking for it using .dump(); too. But I couldn't find an onVehicleDamaged or anything. I had to have a friend give me the current call.
Excuse me if call isn't the right term. Call, function... they all mean the same thing to me right now.