Categories > Coding > C# >
Using string in sending lua script (WRD API)
Posted
Using C# and the API provided by WRD. If I use:
string username = textBox1.Text;
api.SendLuaScript("print(game.Players['I want the string username here'].Stats.Power.Value)");
Also, if i have a text label on my C# form, would I be able to get that value from above to change text value.
So something like -- label1 = value of above, the game.Players[USER].Stats.Power.Value - so i would not have to open the developer console to preview the stat?
Anything would be appreciated! :)
edit:
I tried:
api.SendLuaScript("print(game.Players['{0}'].Stats.Power.Value)", username); -- but it doesnt accept 2 arguments, it gives an error
Severity Code Description Project File Line Suppression State
Error CS1501 No overload for method 'SendLuaScript' takes 2 arguments
Sometimes I just wanna get on TV and just let loose.
-- @stubbsio on instagram
-- ur mom?
Replied
api.SendLuaScript("print(game.Players['" + username + "'].Stats.Power.Value)");
just concatenate it
by the way, the two argument error is because SendLuaScript only uses one argument and since you formatted SendLuaScript.
so, (iirc) string.format would be the correct one.
string.format("print(game.Players['{0}'].Stats.Power.Value)", username)
would be the correct one you're doing (if this is the right function, if not its probably string.concat)
Cancel
Post
Exploits I own:Â Synapse, Electron
Scripts I've made: Aimbot GUI, Draco Admin
Scripts I'm working on: More game ESPs
Replied
api.SendLuaScript($"print(game.Players['{ username here }'].Stats.Power.Value)");
Cancel
Post
Discord : Doctor Doom#0550
Replied
@JohnnyDoe Just use the $ prefix to perform string interpolation. Like what 0x777 did.
Cancel
Post
Replied
If u want it to be on the localplayer, there are a few ways:
1. using the players.localplayer
string username = textBox1.Text; // Unnecessary
api.SendLuaScript("print(game:GetService('Players').LocalPlayer.Stats.Power.Value)");
2. using the localplayer name
string username = textBox1.Text; // Unnecessary
api.SendLuaScript("print(game:GetService('Players')[game:GetService('Players').LocalPlayer.Name].Stats.Power.Value)");
or, if u want to use the textbox1.text, there are a few more ways:
1. using {username} thingy
string username = textBox1.Text; // Unnecessary
api.SendLuaScript($"print(game:GetService('Players')['{username}'].Stats.Power.Value)");
2. the way you tried to use {0} [use string.Format()]
string username = textBox1.Text; // Unnecessary
api.SendLuaScript(string.Format("print(game:GetService('Players')['{0}'].Stats.Power.Value)", username));
I'm trash at lua but i tried to make the lua part work
Cancel
Post
Replied
Thank you all for the help it worked fine, is there any way to add text to print and the game.Players; So: Power: (value) as everytime i tried it prints "--" in yellow.
Cancel
Post
Sometimes I just wanna get on TV and just let loose.
-- @stubbsio on instagram
-- ur mom?
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post