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.

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

[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)