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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 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<img src="https://forum.cuberite.org/images/smilies/biggrin.png" alt="Big Grin" title="Big Grin" class="smilie smilie_4"> else return false -- You do get the drops! Yay~ end end |