Hey folks,
I have this Table on the Serverside:
[IMG]http://i.imgur.com/XhFJ02C.png[/IMG]
It is sent to the Player via net:
[LUA]
function SendNPCS( ply )
if not table.HasValue(NPC_Instances) then
net.Start("CSSendNPCS")
net.WriteTable(NPC_Instances)
net.Send(ply)
end
end
[/LUA]
Then i will print it to the console and this appears:
[IMG]http://i.imgur.com/kVGng3b.png[/IMG]
So it's "destroyed" and every Key/Value is mixxed...What is wrong? :suicide:
//And there is a Error showing "Couldn't write type 6" in the Server-Console
I am not sure what this line is supposed to do: "if not table.HasValue(NPC_Instances) then", but your problem is that you try to send a FUNCTION over the net library, which is impossible.
Yeah, Functions cannot be sent. Wish it was though
[QUOTE=Kicks38;42885802]Yeah, Functions cannot be sent. Wish it was though[/QUOTE]
In theory it should be possible (as long as the function would not use libraries that did not exist on the state it was being ran on).
[QUOTE=Robotboy655;42885758]I am not sure what this line is supposed to do: "if not table.HasValue(NPC_Instances) then", but your problem is that you try to send a FUNCTION over the net library, which is impossible.[/QUOTE]
Oh, i hate Lua's "not" :<
Thanks, removing the function solved it :)
[QUOTE=dingusnin;42885875]In theory it should be possible (as long as the function would not use libraries that did not exist on the state it was being ran on).[/QUOTE]
If it was, I would love to see how to do so
[QUOTE=johnnyaka;42886600]Oh, i hate Lua's "not" :<
Thanks, removing the function solved it :)[/QUOTE]
You can use ! instead of not in GMod lua. It's just you call table.HasValue and don't supply a value to check for. That if-then is completely useless.
[QUOTE=zerothefallen;42886611]If it was, I would love to see how to do so[/QUOTE]
I would probably use Byte Code to transfer the function. I would have to figure out a way of indexing functions, and how to transform functions into byte code.
Easier said than done. I will post something on monday.
[QUOTE=dingusnin;42886771]I would probably use Byte Code to transfer the function. I would have to figure out a way of indexing functions, and how to transform functions into byte code.
Easier said than done. I will post something on monday.[/QUOTE]
Bytecode is blocked in GMod.
[QUOTE=Robotboy655;42886963]Bytecode is blocked in GMod.[/QUOTE]
I don't mean by running it directly, I mean sending the function as a sequence of instructions.
Why would you even want to send a function? Just declare it both on server and client if you need it shared or clientside.
[QUOTE=Robotboy655;42886963]Bytecode is blocked in GMod.[/QUOTE]
no its not, string.byte works, and then you just RunString it
[editline]17th November 2013[/editline]
[QUOTE=Robotboy655;42887046]Why would you even want to send a function? Just declare it both on server and client if you need it shared or clientside.[/QUOTE]
anti-cheat purposes. If you could send a func to a client, it would allow detecting detours 10x easier.
[QUOTE=zerothefallen;42887114]no its not, string.byte works, and then you just RunString it[/QUOTE]
Show an example.
dobyte.lua
[lua]if (!file.Exists("byte/", "DATA")) then
file.CreateDir("byte")
end
if (!file.Exists("byte/byte.txt", "DATA") || !file.Exists("byte/lua.txt", "DATA")) then
file.Write("byte/byte.txt", "")
file.Write("byte/lua.txt", "")
end
local dat = file.Read("byte/lua.txt", "DATA")
local ret = ""
for _, b in pairs({string.byte(dat, 1, string.len(dat))}) do
ret = ret .. "\\" .. b
end
file.Write("byte/byte.txt", ret)[/lua]
unbyte.lua
[lua]if (!file.Exists("byte/", "DATA")) then
file.CreateDir("byte")
end
if (!file.Exists("byte/byte.txt", "DATA") || !file.Exists("byte/lua.txt", "DATA")) then
file.Write("byte/byte.txt", "")
file.Write("byte/lua.txt", "")
end
local dat = file.Read("byte/byte.txt", "DATA")
local ret = ""
for b in string.gmatch(dat, "%d+") do
ret = ret .. string.char(b)
end
file.Write("byte/lua.txt", ret)[/lua]
RunString("THE BYTED TEXT YOU GOT")
I use it myself.
[QUOTE=zerothefallen;42887114]
anti-cheat purposes. If you could send a func to a client, it would allow detecting detours 10x easier.[/QUOTE]
Not really. You would be relying on dependencies that could potentially (almost always) be detoured functions.
When you talk about sending a function to a client, it is impossible, you can only send the instructions of the function, and even then you have to do indexing of functions to use. Knowing client and server are different you are not able to do that on the server.
Think of assembly. You can't run windows compiled assembly on linux because of the difference in libraries and instructions.
[QUOTE=dingusnin;42887190]Not really. You would be relying on dependencies that could potentially (almost always) be detoured functions.
When you talk about sending a function to a client, it is impossible, you can only send the instructions of the function, and even then you have to do indexing of functions to use. Knowing client and server are different you are not able to do that on the server.
Think of assembly. You can't run windows compiled assembly on linux because of the difference in libraries and instructions.[/QUOTE]
i dont think you get what i mean
[QUOTE=zerothefallen;42887173]nonsense[/quote]
Are you kidding me?
Sorry, you need to Log In to post a reply to this thread.