Categories > Coding > C# >

Using string in sending lua script (WRD API)

i6x

Bozo

Posts: 2

Threads: 1

Joined: Sep, 2021

Reputation: 0

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

 

 

  • 0

Sometimes I just wanna get on TV and just let loose.
-- @stubbsio on instagram

-- ur mom?

Posts: 257

Threads: 112

Joined: Jun, 2018

Reputation: 5

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)

  • 0

Exploits I own: Synapse, Electron

Scripts I've made: Aimbot GUI, Draco Admin

Scripts I'm working on: More game ESPs

Posts: 2099

Threads: 10

Joined: Sep, 2020

Reputation: 62

Replied

api.SendLuaScript($"print(game.Players['{ username here }'].Stats.Power.Value)"); 

  • 0

Discord : Doctor Doom#0550

Posts: 0

Threads: 0

Joined: ?

Reputation:

Replied

@JohnnyDoe Just use the $ prefix to perform string interpolation. Like what 0x777 did.

  • 0

TERIHAX

i say im gay as a joke 🙀

Posts: 2240

Threads: 102

Joined: Jul, 2020

Reputation: 32

Replied

@i6x

 

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

  • 0

i6x

Bozo

Posts: 2

Threads: 1

Joined: Sep, 2021

Reputation: 0

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.

  • 0

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 )