• custom teleport command help
    20 replies, posted
local command = {}; command.help = "Go to the admin room."; command.command = "sit"; command.arguments = {"player"}; command.permissions = "Sit"; command.bDisallowConsole = true; command.bSingleTarget = true; command.immunity = SERVERGUARD.IMMUNITY.ANY; command.aliases = {"adminroom"}; adminroom = ( Vector( 2681, -4465, -139 ) ); function command:OnPlayerExecute(player, adminroom; local position = serverguard:playerSend(player, SetPos(adminroom) , true); if (position) then if (serverguard.player:HasPermission(player, "sit")) then player:SetPos(adminnroom); return true; return true; end; end; end; function command:OnNotify(player) return SGPF("command_goto", serverguard.player:GetName(player), util.GetNotifyListForTargets(targets)); end; function command:ContextMenu(player, menu, rankData) local option = menu:AddOption("sit", function() serverguard.command.Run("sit", false, player:Name()); end); option:SetImage("icon16/wand.png"); end;
??? plz halp meh
Are there any errors? What have you tried so far? function command:OnPlayerExecute(player, adminroom; So far, I see this as wrong. It should be something along the lines of: function command:Execute(player, silent, arguments)
You are returning true twice in a single if statement. if (serverguard.player:HasPermission(player, "sit")) then player:SetPos(adminnroom); return true end Thats all I could really see, but I haven't experimented with serverguard yet.
Please, don't add ; to lua...Please
What do you mean?
Semicolons ( ; ) are optional in Lua, you don't HAVE to have them, but ultimately its up to you.
the whole config and commands with serverguard are set with semicolans. Thats why we used it :P Also does that script work? Any errors with it?
This does not work, however, there are no errors. We did !sit and it still didnt work local command = {}; command.help                = "Go to the admin room."; command.command             = "sit"; command.arguments            = {"player"}; command.permissions            = "Sit"; command.bDisallowConsole    = true; command.bSingleTarget        = true; command.immunity             = SERVERGUARD.IMMUNITY.ANY; command.aliases                = {"adminroom"};  adminroom = ( Vector( 2681, -4465, -139 ) );   function command:Execute(player, silent, arguments)local position = serverguard:playerSend(player, SetPos(adminroom) , true);     if (serverguard.player:HasPermission(player, "sit")) then             player:SetPos(adminnroom);                  returntrueend          =  returntrue;         end;     end; function command:OnNotify(player)return SGPF("command_goto", serverguard.player:GetName(player), util.GetNotifyListForTargets(targets)); end; function command:ContextMenu(player, menu, rankData)local option = menu:AddOption("sit", function()         serverguard.command.Run("sit", false, player:Name());     end);     option:SetImage("icon16/wand.png"); end;
why did you create new variable that call position and you don't using with him ? take this to fix your code : local command = {}; command.help                = "Go to the admin room."; command.command             = "sit"; command.arguments          = {"player"}; command.permissions         = "Sit"; command.bDisallowConsole    = true; command.bSingleTarget       = true; command.immunity            = SERVERGUARD.IMMUNITY.ANY; command.aliases             = {"adminroom"};   function command:OnPlayerExecute(player, target) local adminroom = ( Vector( 2681, -4465, -139 ) );          if (serverguard.player:HasPermission(player, "sit")) then         target:SetPos(adminroom);     end end; function command:OnNotify(player) return SGPF("command_goto", serverguard.player:GetName(player), util.GetNotifyListForTargets(targets)); end; function command:ContextMenu(player, menu, rankData) local option = menu:AddOption("sit", function()         serverguard.command.Run("sit", false, player:Name());     end);     option:SetImage("icon16/wand.png"); end; serverguard.command:Add(command); and now you can use the command on another players by the command !sit <name> or only !sit for teleport your self.
1. 2.It made most of my commands not work either. [ERROR] addons/serverguard/lua/tools/sh_commands.lua:2295: '=' expected near ';' 1. unknown - addons/serverguard/lua/tools/sh_commands.lua:0
i check my code that i post before and it's work good. idk how you copy the code
I coped it fine. Did you check it actually in serverguard?
yeah sure, take it form pastebin - link
still broke. [ERROR] addons/serverguard/lua/tools/sh_commands.lua:2294: '=' expected near ';'   1. unknown - addons/serverguard/lua/tools/sh_commands.lua:0
tell me the line that have the error in my code
oh, it works now lol. Thank you so much man!
i told you that my code fine , but what happed ? why did you get error ?
I dont know. i just copied it from your pastebin it worked. forums might've added a space. Thats the only reason i can think
change here for "sit" to "Sit" and you done ! Before: if (serverguard.player:HasPermission(player, "sit")) then target:SetPos(adminroom); end After: if (serverguard.player:HasPermission(player, "Sit")) then target:SetPos(adminroom); end
Yes. it worked thank you!
Sorry, you need to Log In to post a reply to this thread.