TyChi Posted December 31, 2014 Share Posted December 31, 2014 Anyone know a simpler way to use console commands on another player? I realize that c_find("wilson").components.health:SetPercent(1) works, but is there a better way? For example, if there are two or more Wilsons, then they all have to make sure the one you are trying the change is the one nearest. Is there anyway to identify a player by steam name in the console perhaps? It would make things much easier. Secondly, is there a way that I can make my own mod to have shortcuts to these console commands? I did read some of the code and if i am correct, you identify yourself as ThePlayer in console. That or ConsoleCommandPlayer(). So is there a way I could make a mod or edit the lua files to create more individual player classes that would identify friends in my server? If so, which file should I be editing? Or would I have to make a new file? Also I really only play with the same handful amount of people so having preset player files corresponding to them instead of creating it when a player joins makes more sense and seems easier to me. I don't need this to work on a server where randoms join, just a private server of 5 people. Any ideas? Thanks in advance! Link to comment https://forums.kleientertainment.com/forums/topic/48025-console-commands/ Share on other sites More sharing options...
rezecib Posted December 31, 2014 Share Posted December 31, 2014 What I do is add custom console commands to consolecommands.lua, but I suppose you could do the same thing by having a modmain containing nothing but stuff like this (the reason I do it in consolecommands is so I can leave out all the GLOBALs, but putting stuff there means that it gets overwritten in the periodic patches):GLOBAL.c_heal_everyone = function() for k,v in pairs(GLOBAL.AllPlayers) do v.components.health:SetPercent(1) endendBut as for finding specific players when you've got multiple of the same character.... not easily. The players are stored in AllPlayers, but their order is not necessarily the same as the order on the scoreboard (which pulls from TheNet:GetClientTable(), which doesn't refer to the actual player objects). You could use the combination of the two to write a script to get the nth player on the scoreboard like this, I guess:GLOBAL.NthPlayer = function(n) local userid = GLOBAL.TheNet:GetClientTable()[n].userid for k,v in pairs(AllPlayers) do if v.userid == userid then return v end endend Link to comment https://forums.kleientertainment.com/forums/topic/48025-console-commands/#findComment-595117 Share on other sites More sharing options...
TyChi Posted January 7, 2015 Author Share Posted January 7, 2015 @rezecibThanks for your reply again! So I took your code and changed it up a bit. I used this function in order to obtain their player objects using their userid. friend = function() local userid = 'KU_blahblah' for k,v in pairs(AllPlayers) do if v.userid == userid then return v end endend Then I slightly edited the commands that already work for me. function resfriend() if friend():HasTag("playerghost") then friend():PushEvent("respawnfromghost") friend().components.health:SetPercent(1) friend().components.hunger:SetPercent(1) friend().components.sanity:SetPercent(1) print("Reviving",friend().name,"from ghost.") endend Thanks for the help! On a side note, how did you get those fancy lines for your code? I'm new to forum posting in general. Link to comment https://forums.kleientertainment.com/forums/topic/48025-console-commands/#findComment-598388 Share on other sites More sharing options...
rezecib Posted January 7, 2015 Share Posted January 7, 2015 On a side note, how did you get those fancy lines for your code? I'm new to forum posting in general. It's one of the buttons at the top of the editor, the one that looks like "< >". And to tag people in your posts (like I did), you can select a little bit of their text and a button to "mention" (and also quote) will come up. Link to comment https://forums.kleientertainment.com/forums/topic/48025-console-commands/#findComment-598400 Share on other sites More sharing options...
TyChi Posted January 15, 2015 Author Share Posted January 15, 2015 thanks @rezecib!beepboopbeep Link to comment https://forums.kleientertainment.com/forums/topic/48025-console-commands/#findComment-602258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.