#Plugin
1 messages · Page 1 of 1 (latest)
Im trying to create one and thats my first example
theres a client and server plugin examples in the plugins folder in the adonis loader
I know this already im asking if my plugin would work or not
well you can always test it out yourself
if it errors in the console or output then it probably wont
also im pretty sure that will error
no that wont even run im pretty sure
because of the first line
Can i have a look into the server example plugin i dont have my pc
sure
--[[
SERVER PLUGINS' NAMES MUST START WITH "Server:" OR "Server-"
CLIENT PLUGINS' NAMES MUST START WITH "Client:" OR "Client-"
Plugins have full access to the server/client tables and most variables.
You can use the MakePluginEvent to use the script instead of setting up an event.
PlayerChatted will get chats from the custom chat and nil players.
PlayerJoined will fire after the player finishes initial loading
CharacterAdded will also fire after the player is loaded, it does not use the CharacterAdded event.
service.Events.PlayerChatted(function(plr, msg)
print(`{msg} from {plr.Name} Example Plugin`)
end)
service.Events.PlayerAdded(function(p)
print(`{p.Name} Joined! Example Plugin`)
end)
service.Events.CharacterAdded(function(p)
server.RunCommand('name', plr.Name, 'BobTest Example Plugin')
end)
--]]
return function(Vargs)
local server, service = Vargs.Server, Vargs.Service
server.Commands.ExampleCommand = {
Prefix = server.Settings.Prefix; -- Prefix to use for command
Commands = {"example"}; -- Commands
Args = {"arg1"}; -- Command arguments
Description = "Example command"; -- Command Description
Hidden = true; -- Is it hidden from the command list?
Fun = false; -- Is it fun?
AdminLevel = "Players"; -- Admin level; If using settings.CustomRanks set this to the custom rank name (eg. "Baristas")
Function = function(plr,args) -- Function to run for command
print("HELLO WORLD FROM AN EXAMPLE COMMAND :)")
print(`Player supplied args[1] {args[1]}`)
end
}
end
Thank you
Would this one work ? ``` return function(Vargs)
local server, service = Vargs.Server, Vargs.Service
server.Commands.Kill = {
Prefix = server.Settings.Prefix,
Commands = {"kill"},
Args = {"player"},
Description = "Kill a player",
AdminLevel = "Moderators",
Function = function(plr, args)
local target = service.Players:FindFirstChild(args[1])
if target then
target.Character:BreakJoints()
return true, "Player killed."
else
return false, "Player not found."
end
end
}
end ```
im not sure if it would as there is an adonis command with the name "kill" already
also you should add a check if they forget a player argument
here as an example a command i made
and the local target isnt the best way to do it
for _, selectedplr in ipairs(service.GetPlayers(plr, args[1])) do
I also changed the command name
Deleted it from accident
local server, service = Vargs.Server, Vargs.Service
server.Commands.Kill = {
Prefix = server.Settings.Prefix,
Commands = {"69"},
Args = {"player"},
Description = "Kill a player",
AdminLevel = "Moderators",
Function = function(plr, args)
if #args < 1 then
return false, "Please provide a player to kill."
end
local players = service.GetPlayers(plr, args[1])
if #players > 0 then
for _, selectedplr in ipairs(players) do
selectedplr.Character:BreakJoints()
end
return true, "Player(s) killed."
else
return false, "Player not found."
end
end
}
end ```
repost it
this also has to be changed
this is a very bad way of checking if the player argument is not existent
and this is useless if you have the check for a player argument
use assert() for this
so like
assert(args[1], "Player Argument Missing");
if the player doesnt exist it will throw up an error
and replace these with uh
Alright
actually do you just want me to
write the command for you and you can learn from it as an example
Well actually I wanted it to learn myself but I’m not that good coder, and it was just an example to make so i can make an useful plugin in the feature but I should ask you
ok
return function(Vargs)
local server = Vargs.Server
local service = Vargs.Service
local Admin = server.Admin
local Commands = server.Commands
local Settings = server.Settings
local Functions = server.Functions
local Players = service.Players
Commands.CommandNameHere = {
Prefix = Settings.Prefix,
Commands = {"CommandNameHere";"CommandAlias1Here";"CommandAlias2Here"}, --// and so on, you can put infinite here
Args = {"player"},
Description = "Kill a player",
AdminLevel = "Moderators",
Function = function(plr,args) -- Function to run for command
assert(args[1], "You must select a player")
for _, selectedplr in ipairs(service.GetPlayers(plr, args[1])) do
selectedplr.Character:BreakJoints()
Functions.Hint(`Killed {selectedplr.Name}`, {plr})
end
end
}
end
remember this