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 drops
else
return false -- You do get the drops! Yay~
end
end

