/give [player]
#1
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?


Attached Files
.lua   Kit.lua (Size: 1.16 KB / Downloads: 184)
Reply
Thanks given by:
#2
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()
Reply
Thanks given by:
#3
tyBig Grin ^_^, perhaps a quick example so i can get the context correctly
Reply
Thanks given by:
#4
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
Reply
Thanks given by:
#5
i see i see, alright thanks. good luck with -r174
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)