Cuberite Forum
/give [player] - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: /give [player] (/thread-50.html)



/give [player] - distroyed123 - 03-03-2011

how would you go about doing this in Lua, ive messed around with some of the other Lua files understanding the concepts of player, otherlayer, and splits but i cant get it right, be in the format of /give [player] [item id] [amount] i think i saw someone ask this a while back, and i dont remember who, but they said it was pointless, at that current point in time. if im hosting a server, i dont want just anyone to be able to use it other than setting permissions which is to general, this lua file, you type in /kit it gives you a fiew items to start off, how would you make it able to give it to a target? or is that not possible yet?


RE: /give [player] - FakeTruth - 03-03-2011

Give the player name along with /kit or /give, find it by using StringSplit and using the correct index of the split. Then use cWorld:GetPlayer( PlayerName ) and use THAT player to give items to instead of the Player parameter from KitCommand()


RE: /give [player] - distroyed123 - 03-03-2011

tyBig Grin ^_^, perhaps a quick example so i can get the context correctly


RE: /give [player] - FakeTruth - 03-03-2011

You could look at the /tp command in the Core plugin, as it takes a player name as its first argument (/tp [playername])

Code:
function HandleTPCommand( Split, Player )
    if( not Player:HasPermission( "core.teleport" ) ) then
        return false
    end
    
    local Server = cRoot:Get():GetServer()
    if( #Split ~= 2 ) then
        Server:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName]", Player )
        return true
    end
    local World = cRoot:Get():GetWorld()
    local OtherPlayer = World:GetPlayer( Split[2] )
    if( OtherPlayer == nil ) then
        Server:SendMessage( cChatColor.Green .. "Can't find player " .. Split[2], Player )
    elseif( OtherPlayer == Player ) then
        Server:SendMessage( cChatColor.Green .. "Already there :)", Player )
    else
        Player:TeleportTo( OtherPlayer )
        Server:SendMessage( cChatColor.Green .. "You teleported to "..OtherPlayer:GetName().."!", Player )
        Server:SendMessage( cChatColor.Green .. Player:GetName().." teleported to you!", OtherPlayer )
    end
    return true
end



RE: /give [player] - distroyed123 - 03-03-2011

i see i see, alright thanks. good luck with -r174