[CODE]local list2 = {
"string1",
"string2",
"string3",
"string4",
"string5"
}
local weapon = ents.Create(table.Random(list2))
weapon:SetPos(self:GetPos())
weapon:Spawn()[/CODE]
How would I go about making the table.random result be stored in a variable as a string format?
[code]
local var = table.Random(table)
[/code]
???
Im talking about getting the result from local weapon = ents.Create(table.Random(list2)) So I can put it then later in a sendlua where it says in the chat the result of that table.Random
[QUOTE=Zer0nix;52633630]Im talking about getting the result from local weapon = ents.Create(table.Random(list2)) So I can put it then later in a sendlua where it says in the chat the result of that table.Random[/QUOTE]
You would store it before creating the weapon.
[lua]
local myVar_ = table.Random(list2)
local weapon = ents.Create(myVar_)
SendToPlayerRoutine(myVar_)
[/lua]
Also if I could just urge you not to use sendlua to network the result, but instead use the net library. In this case, if you are sending a static variable then it would be fine, but you don't want to get into the habit because it's very easy to accidentally open an exploit.
[QUOTE=James xX;52633634]You would store it before creating the weapon.
[lua]
local myVar_ = table.Random(list2)
local weapon = ents.Create(myVar_)
SendToPlayerRoutine(myVar_)
[/lua]
Also if I could just urge you not to use sendlua to network the result, but instead use the net library. In this case, if you are sending a static variable then it would be fine, but you don't want to get into the habit because it's very easy to accidentally open an exploit.[/QUOTE]
Thanks a lot, I'm using it now just to send a static variable since yes it's very exploitable. Thanks again!
Sorry, you need to Log In to post a reply to this thread.