Message
Message
====================================================================
F L E X I B L E R I D I N G S Y S T E M (v5.7 - Bug Fix)
====================================================================
*/
if (options.useMob) {
const spawnPos = api.getPosition(playerId);
if (spawnPos) {
const mobId = api.attemptSpawnMob(options.mobType, spawnPos[0],
spawnPos[1], spawnPos[2]);
if (mobId) {
riddenMobId = mobId;
if (!options.isHostile) {
api.setMobSetting(mobId, "attackDamage", 0);
api.setMobSetting(mobId, "attackRadius", 0);
api.setMobSetting(mobId, "hostilityRadius", 0);
}
api.sendMessage(playerId, "You are now controlling the " +
options.mobType + "! Crouch to dismount.", { color: "lime" });
} else {
api.sendMessage(playerId, "Failed to spawn mob.", { color:
"red" });
forceDismount();
}
}
} else {
api.sendMessage(playerId, "You are now in driving mode! Crouch to exit.", {
color: "cyan" });
}
}
function cleanupAfterDespawn() {
resetPlayerStats(ridingPlayerId);
if (ridingPlayerId && api.playerIsInGame(ridingPlayerId)) {
api.setPlayerOpacity(ridingPlayerId, 1);
api.sendMessage(ridingPlayerId, "Dismounted.", { color: "yellow" });
}
ridingPlayerId = null;
riddenMobId = null;
}
function forceDismount() {
resetPlayerStats(ridingPlayerId);
if (ridingPlayerId && api.playerIsInGame(ridingPlayerId)) {
api.setPlayerOpacity(ridingPlayerId, 1);
api.sendMessage(ridingPlayerId, "Dismounted.", { color: "yellow" });
}
if (riddenMobId && api.isAlive(riddenMobId)) {
api.despawnMob(riddenMobId);
}
ridingPlayerId = null;
riddenMobId = null;
}