GhostMonster_it Posted June 4, 2022 Share Posted June 4, 2022 (edited) Hello everyone, have a nice day As the title says, I want to add a recipe that only admins or map creators can use or a keyboard shortcut that can only be added for individuals. local birds = AddRecipe("book_birds", {Ingredient("papyrus", 2),Ingredient("bird_egg", 2)},GLOBAL.RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, nil, "achivbookbuilder") --add recipe AddPlayerPostInit(function(inst) inst:AddTag("achivbookbuilder") -- add tag use recipe end) please help me with this problem, thank you very much Edited June 4, 2022 by GhostMonster_it Link to comment Share on other sites More sharing options...
Leonidas IV Posted June 7, 2022 Share Posted June 7, 2022 You can use TheNet:GetIsServerAdmin() for check it. Probably it will only work with keyboard shorcut, like: TheInput:AddKeyDownHandler(KEY_K, function() -- KEY_K is a number in contants.lua --Code end) Don't forget to use GLOBAL 1 Link to comment Share on other sites More sharing options...
GhostMonster_it Posted June 8, 2022 Author Share Posted June 8, 2022 (edited) On 6/8/2022 at 2:12 AM, Leonidas IV said: You can use TheNet:GetIsServerAdmin() for check it. Probably it will only work with keyboard shorcut, like: TheInput:AddKeyDownHandler(KEY_K, function() -- KEY_K is a number in contants.lua --Code end) Don't forget to use GLOBAL I tried this syntax but when I launch the mod, everyone in the map can get the recipe, not only admins have this recipe Do you have another way to do it? local _G = GLOBAL local bird = AddRecipe ( "book_birds" , { Ingredient ( "papyrus" , 2 ), Ingredient ( "bird_egg" , 2 )}, GLOBAL . RECIPETABS . MAGIC , TECH . NONE , nil , nil , nil , nil , "achivbookbuilder" ) AddPlayerPostInit ( function ( inst ) if (_G.TheNet:GetIsServerAdmin() and TheNet:GetIsServer()) then inst : AddTag ( "achivbookbuilder" ) end end ) Edited June 8, 2022 by GhostMonster_it Link to comment Share on other sites More sharing options...
Leonidas IV Posted June 9, 2022 Share Posted June 9, 2022 11 hours ago, GhostMonster_it said: I tried this syntax but when I launch the mod, everyone in the map can get the recipe, not only admins have this recipe Do you have another way to do it? First of all, this command to add crafts is outdated. With the menu update, it is done differently, see AddRecipe2 on modutil.lua. As I said, probably the TheNet:GetIsServerAdmin() function will not work inside the player's prefab, since it doesn't receive the entity (inst). It checks if the client (the player that is not hosting it) is admin, and this happens on the client side, not on the server, where crafts and tags are defined. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now