Grinjr Posted August 3, 2015 Share Posted August 3, 2015 Hello, I'm completely new to creating mods on Don't Starve, and I already have a character created however I want to make it so that only I can play as my character. I'm trying to figure out a way to retrieve some sort of ID that is unique to my steam ID or account or something, or some way to get the player name, all on the server side for whoever just chose my character as their character to play.I already have a way to despawn the player from the server side, and it does work with 1 player, but if say player 2 chooses my character as their character to play, it despawns player 1 currently. I need to find some way to retrieve some way to identify if the player choosing the character is me or someone else using some sort of unique identifier like maybe the player name or something, and then despawn only that player. Currently, I looked into the consolecommands.lua for some examples and found out that I can use the ConsoleCommandPlayer() function to return the player name, and then I can just dolocal player = ConsoleCommandPlayer()c_despawn(player)to despawn the player. Any help with this would be muchly appreciated, and if this makes no sense then feel free to ask for clarification because I do not necessarily feel very comfortable in my wording being correct as I am fairly new to this. Thanks! Link to comment Share on other sites More sharing options...
whatsmynameagain Posted August 3, 2015 Share Posted August 3, 2015 (edited) In the console, print(ThePlayer.userid) or print(AllPlayers[(your user number)].userid) will give you yours. It's basically OU_(your steam id). Edited August 3, 2015 by whatsmynameagain Link to comment Share on other sites More sharing options...
DarkXero Posted August 3, 2015 Share Posted August 3, 2015 @Grinjr, find out your userid by doing what @whatsmynameagain said. Then use something like:local function isPlayerMe(player) return player.userid == "KU_VA456e0"end local meonly = { wilson = true,} AddPlayerPostInit(function(inst) if GLOBAL.TheWorld.ismastersim then inst:DoTaskInTime(0, function() if meonly[inst.prefab] and not isPlayerMe(inst) then inst:DoTaskInTime(1, function() inst.components.talker:Say("Picked special character.") end) inst:DoTaskInTime(3, function() inst.components.talker:Say("Despawning...") end) inst:DoTaskInTime(5, function() GLOBAL.c_despawn(inst) end) end end) endend) 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