31
Modification Help / Example: Spawning Vehicles
« on: August 26, 2009, 06:28:25 PM »
I wrote this small script not too long ago while having fun in my server, due to people praising it and asking "how did you do it" among other things, I have decided to post it here as a resource.
There is really no need for me to do this, however I always appreciate it when others share their work so I can read it and learn from it, now, I am returning the favor.
This script was made quite quickly, originally it was made entirely in the console.
There is really no need for me to do this, however I always appreciate it when others share their work so I can read it and learn from it, now, I am returning the favor.
Code: [Select]
// This script is Copyright bobandrob.org, 2009
// This script is Licenced under the BSD Licence found at http://opensource.org/licenses/bsd-license.php
// Normally I would add code to enforce that the jeep and time bomb vehicle datablocks exist,
// however since this is just an example, I will not. Feel free to use your own vehicles instead.
function serverCmdRainBombs(%client, %amount) {
if(!%client.isSuperAdmin)
return;
if(%amount <= 0) {
messageClient(%client, '', "\c2Please specify a valid amount of time bombs.");
return;
}
for(%i = 0; %i < %amount; %i++)
newTimeBomb();
}
function newTimeBomb() {
%obj = new WheeledVehicle(rainBomb) {
dataBlock = "TimeBombCol";
};
rainBomb.setTransform(getRandom(-90, 85) SPC getRandom(-70, 100) SPC "100" SPC getRandom(0, 10) / 10 SPC getRandom(0, 10) / 10 SPC getRandom(0, 10) / 10 SPC getRandom(0, 10) / 10);
// The vales used above in getRandom() are just as they are due to the size of the "Afghanistan DM" build which is included in any default installation of Blockland.
rainBomb.setVelocity("0 0 -10");
rainBomb.istimebomb = 1;
rainBomb.Defusehealth = 1;
rainBomb.setShapeNameColor("1 0 0");
TimeBombTimer(%obj, 0, 0, ( $Pref::TimeBomb::TimeBombTime + 5 ) * 2);
return %obj;
}
function serverCmdScheduleRain(%client) {
if(!%client.isSuperAdmin)
return;
announce("[\c1Weather Man\c3]\c6: Oh no! Take cover cause it looks like it'll start raining \c2time bombs\c6!");
rainBomb();
}
function serverCmdCancelRain(%client) {
if(!%client.isSuperAdmin)
return;
announce("[\c1Weather Man\c3]\c6: It looks like the sky has cleared up.");
if(isEventPending($rainSch))
cancel($rainSch);
}
function rainBomb() {
if(isEventPending($rainSch))
cancel($rainSch);
newTimeBomb();
$rainSch = schedule(getRandom(2000, 5000), 0, rainBomb);
}
function serverCmdClearBombs(%client) {
if(!%client.isSuperAdmin)
return;
while(isObject(rainBomb))
rainBomb.delete();
}
function newjeep() {
%obj = new WheeledVehicle(rainjeep) {
dataBlock = "JeepVehicle";
};
rainjeep.setTransform(getRandom(-90, 85) SPC getRandom(-70, 100) SPC "100" SPC getRandom(0, 10) / 10 SPC getRandom(0, 10) / 10 SPC getRandom(0, 10) / 10 SPC getRandom(0, 10) / 10);
// The vales used above in getRandom() are just as they are due to the size of the "Afghanistan DM" build which is included in any default installation of Blockland. (Same as with the time bombs.)
rainjeep.setVelocity("0 0 -10");
rainjeep.isjeep = 1;
rainjeep.Defusehealth = 1;
rainjeep.setShapeNameColor("1 0 0");
jeepTimer(%obj, 0, 0, ( $Pref::jeep::jeepTime + 5 ) * 2);
return %obj;
}
function serverCmdRainjeeps(%client, %amount) {
if(!%client.isSuperAdmin)
return;
if(%amount <= 0) {
messageClient(%client, '', "\c2Please specify a valid amount of time jeeps.");
return;
}
for(%i = 0; %i < %amount; %i++)
newjeep();
}
function serverCmdClearJeeps(%client) {
if(!%client.isSuperAdmin)
return;
while(isObject(rainjeep))
rainjeep.delete();
}
This script was made quite quickly, originally it was made entirely in the console.