SERVER SIDE:
local play=FindMetaTable("Player")
play.abc=1
i want to send a number to client,so i write these code,i hope i can get ply.abc in client side but i fail.
i get confused . do i have to use net.send or something?
does there any chance to accomplish by my way? thank you
Well, using the net library would be the easiest way rather than trying to do metatable stuff like you're doing - [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]there's a tutorial here that might help[/URL]
[QUOTE=MPan1;50079575]Well, using the net library would be the easiest way rather than trying to do metatable stuff like you're doing - [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]there's a tutorial here that might help[/URL][/QUOTE]
Couldn't you just do this? [CODE]BroadcastLua( [[abc = 1]] )[/CODE]
Can someone tell me why this isn't true (Looking at the amount of disagrees I have)?
[QUOTE=MPan1;50079575]Well, using the net library would be the easiest way rather than trying to do metatable stuff like you're doing - [URL="https://wiki.garrysmod.com/page/Net_Library_Usage"]there's a tutorial here that might help[/URL][/QUOTE]
first of all, thank you for replying. here is a question,i want to create a random number in server side , and this number stand for which team should player join in. i hope it sign to player.team .and i hope both server and client side can get this number by using player.team, can it be possible? or what is usual way to decide which team ?
[editline]6th April 2016[/editline]
[QUOTE=JasonMan34;50079593]Couldn't you just do this? [CODE]BroadcastLua( [[abc = 1]] )[/CODE][/QUOTE]
first of all, thank you for replying.
here is a question,i want to create a random number in server side , and this number stand for which team should player join in.
i hope it sign to player.team .
and i hope both server and client side can get this number by using player.team, can it be possible? or what is usual way to decide which team ?
Use Player:SetTeam( number ) on the server, and then Player:Team() on the client
Use network variables
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetNWInt]Entity:SetNWInt[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetNWInt]Entity:GetNWInt[/url]
[CODE]
if SERVER then
player.GetAll()[1]:SetNWInt("abc", 1)
else
print(player.GetAll()[1]:GetNWInt("abc", 0))
end
[/CODE]
Clientside should print 0 if abc does not exist and 1 or whatever value abc is.
[QUOTE=zzaacckk;50080996]Use Player:SetTeam( number ) on the server, and then Player:Team() on the client[/QUOTE]
that is helpful,i really appreciate it.
[editline]6th April 2016[/editline]
[QUOTE=Potatofactory;50083358]Use network variables
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetNWInt]Entity:SetNWInt[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetNWInt]Entity:GetNWInt[/url]
[CODE]
if SERVER then
player.GetAll()[1]:SetNWInt("abc", 1)
else
print(player.GetAll()[1]:GetNWInt("abc", 0))
end
[/CODE]
Clientside should print 0 if abc does not exist and 1 or whatever value abc is.[/QUOTE]
your code is really helpful to me , thank you a lot
Sorry, you need to Log In to post a reply to this thread.