I can't create any commands.
#1
I tried to create a command but it gave an error. Then, I tried to use the example code in the documentation but it did the same. Here is the code and the error.

function Initialize(Plugin)
	Plugin:SetName("DerpyPluginThatBlowsPeopleUp")
	Plugin:SetVersion(9001)

	cPluginManager.BindCommand("/explode", "derpyplugin.explode", Explode, " ~ Explode a player");

	cPluginManager:AddHook(cPluginManager.HOOK_COLLECTING_PICKUP, OnCollectingPickup)

	LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
	return true
end

function Explode(Split, Player)
	if (#Split ~= 2) then
		-- There was more or less than one argument (excluding the "/explode" bit)
		-- Send the proper usage to the player and exit
		SendMessage(Player, "Usage: /explode [playername]")
		return true
	end

	-- Create a callback ExplodePlayer with parameter Explodee, which MCS calls for every player on the server
	local HasExploded = false
	local ExplodePlayer = function(Explodee)
		-- If the player we are currently at is the one we specified as the parameter
		if (Explodee:GetName() == Split[2]) then
			-- Create an explosion at the same position as they are; see API docs for further details of this function
			Player:GetWorld():DoExplosionAt(Explodee:GetPosX(), Explodee:GetPosY(), Explodee:GetPosZ(), false, esPlugin)
			SendMessageSuccess(Player, Split[2] .. " was successfully exploded")
			HasExploded = true;
			return true -- Signalize to MCS that we do not need to call this callback for any more players
		end
	end
	
	-- Tell MCS to loop through all players and call the callback above with the Player object it has found
	cRoot:Get():FindAndDoWithPlayer(Split[2], ExplodePlayer)
	
	if not(HasExploded) then
		-- We have not broken out so far, therefore, the player must not exist, send failure
		SendMessageFailure(Player, Split[2] .. " was not found")
	end
	
	return true
end

function OnCollectingPickup(Player, Pickup) -- Again, see the API docs for parameters of all hooks. In this case, it is a Player and Pickup object
	if (Player:GetClientHandle():GetPing() > 100) then -- Get ping of player, in milliseconds
		return true -- Discriminate against high latency - you don\'t get dropsBig Grin
	else
		return false -- You do get the drops! Yay~
	end
end

[Image: zUxd82d.png]
Reply
Thanks given by:


Messages In This Thread
I can't create any commands. - by Guandor - 09-06-2014, 12:09 PM
RE: I can't create any commands. - by Seadragon91 - 09-06-2014, 02:42 PM
RE: I can't create any commands. - by xoft - 09-06-2014, 06:49 PM
RE: I can't create any commands. - by Guandor - 09-07-2014, 04:42 AM
RE: I can't create any commands. - by Lo_Pan - 09-12-2014, 03:49 AM
RE: I can't create any commands. - by NiLSPACE - 09-12-2014, 03:55 AM
RE: I can't create any commands. - by Lo_Pan - 09-12-2014, 03:58 AM
RE: I can't create any commands. - by Seadragon91 - 09-12-2014, 04:47 AM
RE: I can't create any commands. - by Lo_Pan - 09-12-2014, 05:04 AM
RE: I can't create any commands. - by LO1ZB - 09-12-2014, 05:59 AM
RE: I can't create any commands. - by Lo_Pan - 09-12-2014, 07:15 AM
RE: I can't create any commands. - by LO1ZB - 09-12-2014, 07:36 AM
RE: I can't create any commands. - by Lo_Pan - 09-12-2014, 08:24 AM
RE: I can't create any commands. - by LO1ZB - 09-12-2014, 08:34 AM
RE: I can't create any commands. - by Lo_Pan - 09-12-2014, 08:52 AM
RE: I can't create any commands. - by LO1ZB - 09-12-2014, 09:25 AM
RE: I can't create any commands. - by Seadragon91 - 09-12-2014, 06:22 AM
RE: I can't create any commands. - by xoft - 09-12-2014, 07:37 PM
RE: I can't create any commands. - by xoft - 09-12-2014, 07:39 PM
RE: I can't create any commands. - by xoft - 09-12-2014, 07:45 PM
RE: I can't create any commands. - by Lo_Pan - 09-13-2014, 12:16 AM



Users browsing this thread: 1 Guest(s)