7 months ago

ralsei smp backup 18

[v2.0]

peacefull mode

no dead counters or kill counters]


// ==================== CUSTOM SHOP ITEMS ====================

const customShopItems = {

"Minigun": { apiName: "Minigun", buyPrice: 200000000, sellPrice: 1000000 },

"Diamond Axe": { apiName: "Diamond Axe", buyPrice: 5000, sellPrice: 2500 },

"Diamond Pickaxe": { apiName: "Diamond Pickaxe", buyPrice: 5000, sellPrice: 2500 },

"Diamond Sword": { apiName: "Diamond Sword", buyPrice: 2500, sellPrice: 1250 },

"Diamond Hoe": { apiName: "Diamond Hoe", buyPrice: 1250, sellPrice: 1125 },

"Diamond glider": { apiName: "Diamond Hang Glider", buyPrice: 1250, sellPrice: 1125 },

"Diamond Hang Glider": { apiName: "Diamond Hang Glider", buyPrice: 1250, sellPrice: 1125 },

"Diamond Block": { apiName: "Diamond Hoe", buyPrice: 360, sellPrice: 180 },

"Kill Spikes": { apiName: "Kill Spikes", buyPrice: 50000000, sellPrice: 250000 },

"Wood Spikes": { apiName: "Wood Spikes", buyPrice: 5, sellPrice: 2.5 },

"Stone Spikes": { apiName: "Stone Spikes", buyPrice: 20, sellPrice: 10 },

"Iron Spikes": { apiName: "Iron Spikes", buyPrice: 80, sellPrice: 40 },

"Diamond Spikes": { apiName: "Diamond Spikes", buyPrice: 250000, sellPrice: 12500 },

"Code Block": { apiName: "Code Block", buyPrice: 99999999000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000, sellPrice: 999999999999999999999999999999999999999999999999999999999999999999999999999999992000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000 },

"Bedrock": { apiName: "Bedrock", buyPrice: 200000000000000000000000000000000000000000000000000000000000000000000000000000, sellPrice: 2999999999999999999999999992000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000 },

"Grass Block": { apiName: "Grass Block", buyPrice: 1, sellPrice: 0 },

"Dirt": { apiName: "Dirt", buyPrice: 1, sellPrice: 0 },

"Log": { apiName: "Maple Log", buyPrice: 2, sellPrice: 1 },

"Coal": { apiName: "Coal", buyPrice: 20, sellPrice: 7.5 },

"Messy Stone": { apiName: "Messy Stone", buyPrice: 3, sellPrice: 1.5 },

"Stone": { apiName: "Stone", buyPrice: 10, sellPrice: 5 },

"Iron Bar": { apiName: "Iron Bar", buyPrice: 40, sellPrice: 25 },

"Gold Bar": { apiName: "Gold Bar", buyPrice: 70, sellPrice: 25 },

"Diamond": { apiName: "Diamond", buyPrice: 175, sellPrice: 125 },

"Moonstone": { apiName: "Moonstone", buyPrice: 250, sellPrice: 175 },

"Gold Coin": { apiName: "Gold Coin", buyPrice: 750, sellPrice: 350 },

"Aura XP Orb": { apiName: "Aura XP Orb", buyPrice: 450, sellPrice: 20 },

"Raw Porkchop": { apiName: "Raw Porkchop", buyPrice: 5, sellPrice: 4 },

"Rotten Flesh": { apiName: "Rotten Flesh", buyPrice: 4, sellPrice: 2 },

"Fur": { apiName: "Fur", buyPrice: 5500, sellPrice: 4000 },

"Bone": { apiName: "Bone", buyPrice: 3775, sellPrice: 575 },

"Glass": { apiName: "Bone", buyPrice: 15, sellPrice: 12.5 },

"Frost Zombie Spawner Block": { apiName: "Frost Zombie Spawner Block", buyPrice: 550, sellPrice: 460 },

"Cotton": { apiName: "Cotton", buyPrice: 10, sellPrice: 5 },

"Aura XP Potion II": { apiName: "Aura XP Potion II", buyPrice: 80, sellPrice: 25 },

"XP pot 2": { apiName: "Aura XP Potion II", buyPrice: 80, sellPrice: 25 },

"xppot2": { apiName: "Aura XP Potion II", buyPrice: 80, sellPrice: 25 },

"Bouncy mush": { apiName: "Fat Red Mushroom", buyPrice: 25, sellPrice: 12 },

"Fat Red mush": { apiName: "Fat Red Mushroom", buyPrice: 25, sellPrice: 8 },

"a life": { apiName: "Bedrock", buyPrice: 20000000, sellPrice: 20 }

};

// ===== Add Concrete Variants =====

const concreteColors = ["White","Black","Green","Red","Blue","Yellow"];

for (const color of concreteColors) {

customShopItems[`${color} Concrete`] = { apiName: `${color} Concrete`, buyPrice: 15, sellPrice: 7 };

}

// ==================== PLAYER / WORKER DATA ====================

let playerPlaytimeUpdateTracker = {};

let tickCounter = 0;

let hiredWorkers = {};

// ==================== SAFE API WRAPPER ====================

function safeAPI(func, ...args) {

try { return func && typeof func === "function" ? func(...args) : null; }

catch (e) { console.error("API call error:", e); return null; }

}

// ==================== PLAYER STATS ====================

function initializePlayerStats(playerId) {

const slot = safeAPI(api.getMoonstoneChestItemSlot, playerId, 0);

if (!slot || !slot.attributes || !slot.attributes.customAttributes) {

safeAPI(api.setMoonstoneChestItemSlot, playerId, 0, "Dirt", 1, { customAttributes: { money:0, kills:0, deaths:0, playtime:0 }});

}

}

function getPlayerStats(playerId) {

const slot = safeAPI(api.getMoonstoneChestItemSlot, playerId, 0);

const attrs = slot?.attributes?.customAttributes || {};

return { money:Number(attrs.money)||0, kills:Number(attrs.kills)||0, deaths:Number(attrs.deaths)||0, playtime:Number(attrs.playtime)||0 };

}

function setPlayerStats(playerId, stats) {

const safeStats = { money:Number(stats?.money)||0, kills:Number(stats?.kills)||0, deaths:Number(stats?.deaths)||0, playtime:Number(stats?.playtime)||0 };

safeAPI(api.setMoonstoneChestItemSlot, playerId, 0, "Dirt", 1, { customAttributes:safeStats });

}

function enforceStatsIntegrity(playerId) {

const slot = safeAPI(api.getMoonstoneChestItemSlot, playerId, 0);

if (!slot || slot.itemName !== "Dirt" || slot.amount !== 1 || !slot.attributes?.customAttributes) {

initializePlayerStats(playerId);

}

}

// ==================== CHAT COMMANDS ====================

function processPlayerChatCommand(playerId, msg) {

msg = msg.trim();

enforceStatsIntegrity(playerId);

const stats = getPlayerStats(playerId);

// ---------- !srvmsg Command ----------

if (msg.toLowerCase().startsWith("!srvmsg")) {

const playerName = (safeAPI(api.getPlayerName, playerId) || "").trim().toLowerCase();

if (playerName !== "_ralsei") return;

const allowedColors = ["white","black","red","green","blue","yellow","orange","purple","pink","cyan","magenta"];

const parts = msg.split(" ");

let color = "#FFFFFF"; // default white

let messageStartIndex = 1;

if (parts.length > 1) {

let potentialColor = parts[1];

// Expand short hex (#RGB) to full hex (#RRGGBB)

if (/^#[0-9A-Fa-f]{3}$/.test(potentialColor)) {

potentialColor = "#" + potentialColor[1]+potentialColor[1] + potentialColor[2]+potentialColor[2] + potentialColor[3]+potentialColor[3];

}

// Full hex (#RRGGBB)

if (/^#[0-9A-Fa-f]{6}$/.test(potentialColor)) {

color = potentialColor;

messageStartIndex = 2;

}

// Named color

else if (allowedColors.includes(potentialColor.toLowerCase())) {

color = potentialColor.toLowerCase();

messageStartIndex = 2;

}

}

const message = parts.slice(messageStartIndex).join(" ").trim();

if (!message) return;

const onlinePlayers = safeAPI(api.getPlayerIds) || [];

for (const pId of onlinePlayers) {

if (safeAPI(api.playerIsInGame, pId)) {

safeAPI(api.sendMessage, pId, message, { color });

}

}

return;

}

if (msg === "!rtp") {

return safeAPI(() => {

const minX = -9999, maxX = 9999; // safer range

const minZ = -9990, maxZ = 9999;

const startY = 25;

const randX = Math.floor(Math.random() * (maxX - minX + 1)) + minX;

const randZ = Math.floor(Math.random() * (maxZ - minZ + 1)) + minZ;

let y = startY;

while (y > 0) {

const block = api.getBlock([randX, y, randZ]);

if (block && block.solid) break;

y--;

}

const groundY = y + 8;

safeAPI(() => api.setPosition(playerId, [randX, groundY, randZ]));

safeAPI(() => api.setGamemode(playerId, "survival"));

return safeAPI(api.sendMessage, playerId, `Teleported to [${randX}, ${groundY}, ${randZ}]`, { color: "#00FFFF" });

});

}

if (msg === "!help") return safeAPI(api.sendMessage, playerId,

"Commands: !bal !shop !buy <item> !sell <item> !pay <player> <amount> !kills !deaths !kdr !hire <player> <amount>, !rtp \n \n !rtp will randomly teleport u around the world,\n !bal lets u check the balance fo u and others,\n !buy will let u buy specific items (listed in !shop),\n !shop will show u what itmes u can buy and sell whit commands,\n !sell will sell items that are in !shop,\n !pay will pay a player an amount of ur money,\n !hire will pay a player an amount of money from u every 5 min.\n \n any more questons? \n ask the admins. \n creater: _ralsei \n \n do !info for credits and more info",

{ color: "#00FFFF" }

);

if (msg === "!info") return safeAPI(api.sendMessage, playerId,

"info: sevrver was created in december 2025 \n credits: \n _ralsei, created the world and modified the code \nRecklessBloxd, for the original code and inspiration of his smp's \n more info will be added soon \nversion= 1.17.2 ",

{ color: "#ababee" }

);

if (msg === "!bal") return safeAPI(api.sendMessage, playerId, `Your balance: ${stats.money}`, { color: "#00FF00" });

if (msg === "!shop") {

let text = "πŸ›’ The Shop Items πŸ›’:\n";

for (const itemName in customShopItems) {

const item = customShopItems[itemName];

text += `- ${itemName}: Buy ${item.buyPrice} | Sell ${item.sellPrice}\n`;

}

return safeAPI(api.sendMessage, playerId, text, { color: "#0ADD08" });

}

if (msg.startsWith("!buy") || msg.startsWith("!sell") || msg.startsWith("!pay")) {

handleShopCommands(playerId, stats, msg);

}

if (msg.startsWith("!hire")) {

const parts = msg.split(" ");

if (parts.length < 3) return safeAPI(api.sendMessage, playerId, "Usage: !hire <player> <amount>", { color: "red" });

const targetName = parts[1];

const amount = parseInt(parts[2]);

if (isNaN(amount)||amount<=0) return safeAPI(api.sendMessage, playerId, "Invalid amount",{color:"red"});

const targetId = safeAPI(api.getPlayerId,targetName);

if(!targetId||targetId===playerId) return safeAPI(api.sendMessage,playerId,"Invalid player",{color:"red"});

hiredWorkers[targetId]={employerId:playerId,amount:amount,lastPaid:Date.now()};

safeAPI(api.sendMessage,playerId,`You hired ${targetName} for ${amount} every 5 minutes.`,{color:"#00FF00"});

safeAPI(api.sendMessage,targetId,`You have been hired by ${safeAPI(api.getPlayerName,playerId)} for ${amount} every 5 minutes.`,{color:"#00FFAA"});

}

}

// ---------- Shop Commands ----------

function handleShopCommands(playerId, stats, msg) {

const parts = msg.split(" ");

const cmd = parts.shift();

if(cmd==="!buy"||cmd==="!sell") {

let quantity=parseInt(parts[0]); if(isNaN(quantity)) quantity=1; else parts.shift();

const itemName=parts.join(" "); const item=customShopItems[itemName];

if(!item) return safeAPI(api.sendMessage,playerId,`"${itemName}" not in shop.`,{color:"red"});

if(cmd==="!buy") {

const cost=item.buyPrice*quantity;

if(stats.money<cost) return safeAPI(api.sendMessage,playerId,`Not enough money! Need ${cost}`,{color:"red"});

if(itemName === "Pro Diamond Set") {

const enchants = ["Protection III", "Health Regeneration III"];

safeAPI(api.giveItem, playerId, "Diamond Helmet", 1, { enchants });

safeAPI(api.giveItem, playerId, "Diamond Chestplate", 1, { enchants });

safeAPI(api.giveItem, playerId, "Diamond Leggings", 1, { enchants });

safeAPI(api.giveItem, playerId, "Diamond Boots", 1, { enchants });

stats.money -= cost;

setPlayerStats(playerId, stats);

return safeAPI(api.sendMessage, playerId, `You purchased the Pro Diamond Set!`, { color:"#00FF00" });

}

safeAPI(api.giveItem,playerId,item.apiName,quantity);

stats.money -= cost;

setPlayerStats(playerId,stats);

return safeAPI(api.sendMessage,playerId,`Bought ${quantity}x ${itemName} for ${cost}.`,{color:"#00FF00"});

}

const owned=safeAPI(api.getInventoryItemAmount,playerId,item.apiName)||0;

if(owned<quantity) return safeAPI(api.sendMessage,playerId,`You only have ${owned}x ${itemName}`,{color:"red"});

safeAPI(api.removeItemName,playerId,item.apiName,quantity);

stats.money+=item.sellPrice*quantity;

setPlayerStats(playerId,stats);

return safeAPI(api.sendMessage,playerId,`Sold ${quantity}x ${itemName} for ${item.sellPrice*quantity}.`,{color:"#00FF00"});

}

if(cmd==="!pay"){

if(parts.length<2) return safeAPI(api.sendMessage,playerId,"Usage: !pay <player> <amount>",{color:"red"});

const targetId=safeAPI(api.getPlayerId,parts[0]);

const amount=parseInt(parts[1]);

if(!targetId||!targetId===playerId||isNaN(amount)||amount<=0) return safeAPI(api.sendMessage,playerId,"Invalid player or amount",{color:"red"});

const senderStats=getPlayerStats(playerId);

const receiverStats=getPlayerStats(targetId);

if(senderStats.money<amount) return safeAPI(api.sendMessage,playerId,"Not enough money",{color:"red"});

senderStats.money-=amount;

receiverStats.money+=amount;

setPlayerStats(playerId,senderStats);

setPlayerStats(targetId,receiverStats);

const senderName=safeAPI(api.getPlayerName,playerId)||"Someone";

const receiverName=safeAPI(api.getPlayerName,targetId)||parts[0]||"Player";

safeAPI(api.sendMessage,playerId,`Paid ${amount} to ${receiverName}`,{color:"#00FF00"});

safeAPI(api.sendMessage,targetId,`Received ${amount} from ${senderName}`,{color:"#00FFAA"});

}

}

// ---------- Player Events ----------

function onPlayerJoin(playerId){ initializePlayerStats(playerId); registerCustomRecipes(playerId); }

function onPlayerChat(playerId,msg){ processPlayerChatCommand(playerId,msg); }

function onEntityKilled(killerId,victimId){ if(!killerId||!victimId||killerId===victimId) return; const killerStats=getPlayerStats(killerId); const victimStats=getPlayerStats(victimId); killerStats.kills=(killerStats.kills||0)+1; victimStats.deaths=(victimStats.deaths||0)+1; setPlayerStats(killerId,killerStats); setPlayerStats(victimId,victimStats);}

function onPlayerKilled(playerId,killerId){ onEntityKilled(killerId,playerId); }

// ---------- Tick Function ----------

function tick(){

tickCounter++; if(tickCounter<4) return; tickCounter=0;

const now=Date.now(); const onlinePlayers=safeAPI(api.getPlayerIds)||[]; const onlineCount=onlinePlayers.filter(p=>safeAPI(api.playerIsInGame,p)).length;

for(const workerId in hiredWorkers){ const hire=hiredWorkers[workerId]; if(now-hire.lastPaid>=300000){ const workerStats=getPlayerStats(workerId); workerStats.money+=hire.amount; setPlayerStats(workerId,workerStats); hire.lastPaid=now; const employerName=safeAPI(api.getPlayerName,hire.employerId)||"Someone"; safeAPI(api.sendMessage,workerId,`You received ${hire.amount} from ${employerName}.`,{color:"#00FFAA"}); } }

for(const player of onlinePlayers){ if(!safeAPI(api.playerIsInGame,player)) continue; enforceStatsIntegrity(player); const stats=getPlayerStats(player); const sidebar=[ { str:" Ralsei SMP \n ", style:{ color:"#FFAA00", fontWeight:"bold", fontSize:"20px" } }, { str:`πŸ’Έ π™Όπš˜πš—πšŽπš’: ${stats.money}\n`, style:{ color:"#00FF00", fontSize:"18px"} }, { str:`πŸ”ͺ π™Ίπš’πš•πš•s: ${stats.kills}\n`, style:{ color:"#FF5555", fontSize:"18px"} }, { str:`☠️ π™³πšŽaths: ${stats.deaths}\n`, style:{ color:"#FFAA00", fontSize:"18px"} }, { str:`πŸ‘₯ Players Online: ${onlineCount}\n`, style:{ color:"#0000FF", fontSize:"18px"} }, { str:"Type !help to get started!\n!help will show u commands and admin info \n!info will give u more info", style:{ color:"#AAAAFF", fontSize:"15px"}} ]; safeAPI(api.setClientOption,player,"RightInfoText",sidebar);}

}

// ---------- Recipes ----------

function registerCustomRecipes(playerId){

safeAPI(api.editItemCraftingRecipes,playerId,"Gold Coin",[ {requires:[{items:["Moonstone"],amt:3}],produces:1,station:"Workbench"} ]);

safeAPI(api.editItemCraftingRecipes,playerId,"Moonstone",[ {requires:[{items:["Gold Coin"],amt:1}],produces:3,station:"Workbench"}, {requires:[{items:["Block of Moonstone"],amt:1}],produces:9,station:"Workbench"} ]);

safeAPI(api.editItemCraftingRecipes,playerId,"Cornbread",[ {requires:[{items:["Bread"],amt:5},{items:["Corn"],amt:5}],produces:3,station:"Workbench"} ]);

}



0 comments

Loading...

Next up

well not what i wanted [i purposely made my hp infinite so u could see the attack

T H A T S S T I L L B A D -

insane lag test [itds purposely lagging to tets how well it handles lag]

rating: 6/10 just enough to notice a differance between yes and no deltatime

but not enough tpo call it smooth

i m l o n g

[also modding the attack level to show what she has]

well i think attack level 3 and 5 are a lil overkill

ill slightly reduce the limit on them

and for 3 ill make her change direction less ofthen

i still love when this happens

WELL UR COOKED

only neead fix soul movement when its the players turn and slightly speed up the motion speed

and then delta time is done