[QUOTE=MasterKenneth;45501402]How do i do that[/QUOTE]
[QUOTE=AnonTakesOver;45494367]I think you should learn more Lua before continuing, you seem to be asking allot of help for simple things.[/QUOTE]
-snip-
[QUOTE=EvacX;45494492]You're wrong, all values stored "in a player" can be retrieved. The thing about players is that even though they act like tables, they aren't. This is why iterators don't work on them.
They're userdata, which can be assigned a metatable, which means you can make [I]__index[/I] and [I]__newindex[/I] methods for said userdata (these also allow for inheritance). These metamethods direct you to a proxy table when you're storing or reading from a player object. A consequence of this is that Lua needs to be aware of this proxy table, or in other words it has to exist somewhere within Lua.
The proper way of doing this in C/C++ is storing a [url=http://pgl.yoyo.org/luai/i/luaL_ref]reference[/url] to it, which is typically placed in the registry which you can retrieve with [I]debug.getregistry()[/I] and which is exactly what Garry has done. You can find said proxy table by placing a dummy value in it (not very elegant, I know) and scanning the registry, like so:
[lua]
local ply = LocalPlayer()
local tbl
ply.Dummy = 1337 -- this should actually be an empty table (read below)
for i, v in ipairs(debug.getregistry()) do
if istable(v) and v.Dummy == ply.Dummy then
tbl = v
break
end
end
PrintTable(tbl)
[/lua]
The value of the dummy in this case is just for clarity, in fact you'd want to make an empty table (or a [I]newproxy()[/I] which makes an empty userdata) because a table can only ever be equal to itself with no metamethods applied.[/QUOTE]
This is exactly what I was looking for, thank you.
Is there a way to find the currently equpped weapon's icon and use it's path for surface.GetTexureID?
What I was thinking is something along the lines of:
[CODE]client:GetActiveWeapon().Icon[/CODE]
well.. seems I was right. achieved results wanted with this:
[CODE]local icon = client:GetActiveWeapon().Icon
if icon then
surface.SetTexture(surface.GetTextureID( icon ))
end[/CODE]
This is not strictly gmod related but I'm planning on writing a server backend for some gmod stuff I'm working on in lua/moonscript with something like [URL="http://leafo.net/lapis/"]lapis[/URL].
Now since I'd like to use steam's openid service, does anyone know a lua implementation of [URL="http://openid.net/"]openid[/URL]?
Google only gives me [URL="https://github.com/luaforge/luaopenid"]this[/URL] which is heavily outdated.
[QUOTE=HumbleTH;45496988]I haven't worked with effects before, but maybe self.Data:Remove() ?[/QUOTE]
No It doesn't work, There's no function called Remove() in C Object of CEffectData. Also It seems to be that the util.Effect Get's address of vector from CEffectData, setting it to self:GetPos() makes it to change on entity pos change, or to any other user made vector. Is there any other replacement for CEffectData or any 3D Nice looking smoke effects that has functions for hiding/removing?
[QUOTE=HumbleTH;45497696]You could use http.fetch, pretty sure someone did that, let me find you a link.
You could also use system.GetCountry clientside
EDIT: There you go [url]http://facepunch.com/showthread.php?t=1408656&p=45360800&viewfull=1#post45360800[/url]
Next post shows system.GetCountry[/QUOTE]
would like to point out system locale changes your country.
I am a japanese player according 2 gmod
Possible to alert the player clientside even if they are alt-tabbed? An actual pop-up window? Currently I'm just making the client make a beeping noise but that's only useful if you want to listen to all the ambient sounds on GM.
Is there any way to make the panel that appears when you get kicked to support having more text in it?
[QUOTE=Handsome Matt;45505000]so what? most people aren't weeboos and actually have their system locale set to their actual locale.[/QUOTE]
It's like the 3rd time has has explicitly mentioned that his system locale is set to Japanese
[QUOTE=Loures;45504684]Is there any way to make the panel that appears when you get kicked to support having more text in it?[/QUOTE]
It should extend itself, a lot of text should be able to be entered.
Another thing you could do is when you kick a player, instead of kicking them right away use ply:KillSilent( ), a hook on PlayerDeathThink to return false if they are kicked, and open a vgui window that can't be closed which shows why they have been kicked from the server.
You can limit chat, and all game-functionality very easily by preventing them from spawning and preventing chats from working / going through.
When they click Ok then they disconnect, or you can have it happen after a set time.
I have a question too... No matter what I try, I can't get a ClientsideModel to accept SetColor, material $color2 mat-proxy changes, etc... It won't take the same color as player. I'm not sure if this is because of SetRenderOrigin, SetRenderAngles, SetupBones, etc...
[code]// Modified to shorten, not how set up..
_ent = _ent || ClientsideModel( _p:GetModel( ), RENDERGROUP_OPAQUE );
local _mats, _clothing = _ent:GetClothing( ); -- custom function, basically GetTextures with sorting... .body is the player_sheet.
local _proxy = matproxy.ActiveList[ "PlayerColor" .. _clothing.body ];
print( _proxy );
_ent:SetMaterial( _proxy.Material )
_ent:SetColor( _color );
_ent:SetKeyValue( "$color2", "255 0 0" )
_ent:SetColor( COLOR_RED )
_proxy.Material:SetVector("$color2", Vector( 0, 0, 1 ) );[/code]
So I tried using even the proxy material, tried replacing the material on the csm with the proxy material, etc etc. Doesn't seem to be working...
print _proxy shows:
[code]Grabbing Clothing for models/player/breen.mdl
[Material] = MATERIAL:
GetColor( x = 0, y = 0 ) Color( 0, 0, 0, 255 )
GetName models/breen/players_sheet
GetShader VertexLitGeneric_DX8
Height 1024
Width 1024
IsError false
[Values]
[resultvar] = $color2
[0.34999999403954] = 0.40989997982979
[default] = 0.22999998927116
[bind] = function: 0x280685b0
[init] = function: 0x27d98ba8
[name] = PlayerColor
[ResultTo] = $color2
[/code]
Since func( "Hi" ) is the same as func"Hi", would func "Hi" still work?
[sp]I'm unable to test anything until August 3rd[/sp]
ye
[QUOTE=HumbleTH;45506505]I'm unable to test anything until August 3rd[/QUOTE]
[url=http://www.lua.org/demo.html]No you're not.[/url]
I'm trying to create a cvar that clients will be aware of as soon as they load, any way to do this without using the net library?
CreateConVar("ttt_lan_mode", "0", FCVAR_REPLICATED)
Adding to server only means only server can see the setting, it doesn't exist on the client.
Adding to shared means the client initially sees the default value whenever the map changes..
Is it somehow possible to query binary data using mysqloo ?
[lua]
local something = util.Compress(something)
local query = database:query("INSERT INTO tbl(column) VALUES("..sql.SQLStr(something)..");")
query:start()
[/lua]
When I do that, all the binary data is removed and the column is empty. Doing the same query from phpMyAdmin works.
[code]if (playervar !== 0) then[/code]
this line in my shared.lua, it exists. nothing looks wrong, right? well, [i]this[/i]:
[code]unexpected symbol near '='[/code]
i spent about an hour wondering what was wrong, until it hit me and nearly knocked me out:
I defined that variable in init.lua and in init.lua I also used it as "ply.playervar"... uh oh.
So how do I access it in the shared.lua, while still maintaining it's use as ply.playervar in init.lua?
it's !=
How can I use self in a usermessage hook?
Probably a pointless argument but start using net.
What do you mean by self? (like of what object)
I need to use usermessage though, for reasons.
I've probably got it. Nevermind.
EDIT: Also related, how can I restrict a usermessage / net to just one entity?
EDIT2: What is a good way to network a table between client and server?
For user-messages I believe you need to use RecipientFilter. For net, you can use net.Send( ply ) or net.Send( { ply, ply2 } );
[QUOTE=Acecool;45509296]For user-messages I believe you need to use RecipientFilter. For net, you can use net.Send( ply ) or net.Send( { ply, ply2 } );[/QUOTE]
Acecool, I know how to get one player to receive the usermessage. I mean say I have two crates and a usermessage is broadcast, how can I get so that only the crate that broadcasted it recieved it? Or does it automagically do that already? Using net is fine.
You can't send messages directly to entities, only players as far as I know. If you need to update a variable contained within an entity and all players need to know, then broadcast the change, target the entity and update the variable in the net.Receive.
One more question: How can I use self in net library messages, or at least only send to one entity?
EDIT: I need to check if the entity receiving the net library message is the name as the entity that sent it.
How could I do this?
Is there a way to check if a material is a transparent just from it's string name?
I'm fetching a physobj's material through a physics collision and wanting to check if it's transparent. Not sure if it's possible.
[QUOTE=coolcat99;45509891]One more question: How can I use self in net library messages, or at least only send to one entity?
EDIT: I need to check if the entity receiving the net library message is the name as the entity that sent it.
How could I do this?[/QUOTE]
Again, players would be the sender ( to server ) and server would be the sender ( to clients ). You could WriteEntity and transfer it from server to client and target a specific entity...
You could basically from a SWEP or something ( other ways and better ways for this example ) but on PrimaryAttack send data to server ( if CLIENT ) then on server, rebound it / broadcast it and the weapon that was sent to server then gets sent to all clients. ( since it is shared, this wouldn't be practical ) That would be one way...
[QUOTE=Instant Mix;45510000]Is there a way to check if a material is a transparent just from it's string name?
I'm fetching a physobj's material through a physics collision and wanting to check if it's transparent. Not sure if it's possible.[/QUOTE]
From string, not that I know of. You should have no trouble getting the active material from an entity or player. These are some of the outputs:
[code][Material] = MATERIAL:
GetColor( x = 0, y = 0 ) Color( 0, 0, 0, 255 )
GetName models/breen/players_sheet
GetShader VertexLitGeneric_DX8
Height 1024
Width 1024
IsError false[/code]
So, mat:GetColor( ) should provide you with what you're looking for.
[QUOTE=Acecool;45510139]Again, players would be the sender ( to server ) and server would be the sender ( to clients ). You could WriteEntity and transfer it from server to client and target a specific entity...
You could basically from a SWEP or something ( other ways and better ways for this example ) but on PrimaryAttack send data to server ( if CLIENT ) then on server, rebound it / broadcast it and the weapon that was sent to server then gets sent to all clients. ( since it is shared, this wouldn't be practical ) That would be one way...
[/QUOTE]
I understand that I can WriteEntity, but how can I check that the entity received in the user-message is equal to the same one? Also, I don't understand what you mean by target a specfic entity.
When you net.ReadEntity( ), it should have no trouble producing a valid ent. In the event your character hasn't gone close enough to it then it may appear as NULL. You can send the EntIndex of the entity, then on the client check to see if Entity( net.ReadX( ) ) == net.ReadEntity( ) ... store the reads as values though.
What do you mean by net.ReadX()? All I really get from your examples is checking if the EntityID that is sent is equal to the Entity that sent it.
Serverside: Broadcasts tables and entity
Clientside: Reads tables.
I want the client to only store the tables IF the clients entityID is equal to that of the entity.
However, since it is in a hook, it cannot simply use self.EntityID or anything like that.
Sorry, you need to Log In to post a reply to this thread.