Cuberite Forum
Please Create a Plugin For SpawnAnimal - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Requests (https://forum.cuberite.org/forum-3.html)
+--- Thread: Please Create a Plugin For SpawnAnimal (/thread-1384.html)



Please Create a Plugin For SpawnAnimal - louisgg - 02-20-2014

help please Huh


RE: Please Create a Plugin For SpawnAnimal - NiLSPACE - 02-20-2014

Please be more precise.


RE: Please Create a Plugin For SpawnAnimal - louisgg - 02-20-2014

spawn a creeper
a cow
a entity
........


RE: Please Create a Plugin For SpawnAnimal - NiLSPACE - 02-20-2014

Commands? Parameters? Config?


RE: Please Create a Plugin For SpawnAnimal - louisgg - 02-20-2014

I don't know
maybye a copy of
essential plugin ? this command is /spawnmob

help ?????


RE: Please Create a Plugin For SpawnAnimal - NiLSPACE - 02-20-2014

Try this code:
PLUGIN = nil

function Initialize(Plugin)
	PLUGIN = Plugin
	Plugin:SetName("SpawnMob")
	Plugin:SetVersion(1)
	
	local PluginManager = cPluginManager:Get()
	PluginManager:BindCommand("/spawnmob", "spawnmob.spawnmob", HandleSpawnMobCommand, " ~ [MobType] Spawns a mob at the place you're looking at.")
	
	return true
end

function HandleSpawnMobCommand(Split, Player)
	if Split[2] == nil then
		Player:SendMessage(cChatColor.Rose .. "Usage: /spawnmob [Mob]")
		return true
	end
	
	local MobType = StringToMobType(Split[2])
	if MobType == cMonster.mtInvalidType then
		Player:SendMessage(cChatColor.Rose .. "Invalid mob type.")
		return true
	end
	
	local BlockX, BlockY, BlockZ
	local World = Player:GetWorld()
	
	local Callbacks = {
	OnNextBlock = function(X, Y, Z, BlockType, BlockMeta)
		if BlockType ~= E_BLOCK_AIR then
			BlockX, BlockY, BlockZ = X, Y, Z
			return true
		end
	end
	};
	
	local EyePos = Player:GetEyePosition()
	local LookVector = Player:GetLookVector()
	LookVector:Normalize()
	local Start = EyePos
	local End = EyePos + LookVector * 150

	cLineBlockTracer.Trace(World, Callbacks, Start.x, Start.y, Start.z, End.x, End.y, End.z)
	
	World:SpawnMob(BlockX, BlockY, BlockZ, MobType
	Player:SendMessage(cChatColor.LightGreen .. "A " .. Split[2] .. " was spawned at " .. BlockX .. " " .. BlockY .. " " .. BlockZ)
	return true
end

I have not tested this so it might not work!


(02-20-2014, 05:25 AM)louisgg Wrote: help ?????

Woooow calm down. It's not like we snap our fingers and the code just magically appears.