• What do you need help with? V3
    6,419 replies, posted
[QUOTE=Persious;37469040]So, I sent the data to the client. How would I match the SteamID's, and set the data afterwards?[/QUOTE] [lua]function myfunction(msg) local ID, Data = msg:ReadString(),msg:ReadString() for k,v in pairs(player.GetAll()) do if v:SteamID() == ID then v.Data = Data break end end end usermessage.Hook("mymessage", myfunction)[/lua]
[QUOTE=PencilOnDesk;37470996][lua]function myfunction(msg) local ID, Data = msg:ReadString(),msg:ReadString() for k,v in pairs(player.GetAll()) do if v:SteamID() == ID then v.Data = Data break end end end usermessage.Hook("mymessage", myfunction)[/lua][/QUOTE] Aha, I nearly got it right.
I have a problem with the derpinv i get this message everytime i try to open the inventory addons\derprp inv\lua\autorun\client\cl_drpinv.lua:116 Here is the code. local icon = vgui.Create("SpawnIcon", DPanel1) -line 116- icon:SetModel(info.model) icon:SetPos(5,5) icon:SetMouseInputEnabled(false) i added the the -line 116 so you guys could se whre it is.
Yeah, we'll need the full error.
[QUOTE=PencilOnDesk;37470996][lua]function myfunction(msg) local ID, Data = msg:ReadString(),msg:ReadString() for k,v in pairs(player.GetAll()) do if v:SteamID() == ID then v.Data = Data break end end end usermessage.Hook("mymessage", myfunction)[/lua][/QUOTE] Just checked it, it only adds the localplayer, no one else.
[QUOTE=Persious;37471697]Just checked it, it only adds the localplayer, no one else.[/QUOTE] Are you using bots? I could never get that method to work with bots. If it works on yourself that's proof of concept, it'll work in a multiplayer setting though; I've used the method numerous times.
I'd like to ask if anyone knows how to set an entity to not accept decals. Trying to create a kind of personal shield, Doesnt work well when you see bullet holes in the shield.
Nobody responded to mine? :(
[QUOTE=PencilOnDesk;37474539]Are you using bots? I could never get that method to work with bots. If it works on yourself that's proof of concept, it'll work in a multiplayer setting though; I've used the method numerous times.[/QUOTE] Uh, I tried it on multiplayer with a player, I might need to re-check the code.
@Divran,Drakehawke: Thx guys. ^_^ New noob question: I want my entity to be removed if the owner of it leaves the server. Here is what I've tried: [CODE]function RemoveDisconected( Player ) if ( owner == Player ) then self:Remove() end end hook.Add("PlayerDisconnected","RemoveThisEntity",RemoveDisconected)[/CODE] But this returns an error: "...\init.lua:92] attempt to index global 'self' <a nil value>". Q_Q
[QUOTE=Charrax;37458988]the plugin file to Permamute for Evolve doesn't seem to work. [B]No error. It wont even appear in the spellcheck like other addons do[/B] File: sh_permamute.lua [lua] local Plugin = {} Plugin.Title = "PermaMuter" Plugin.Description = "Permanently mute players." Plugin.Author = "Tom" Plugin.ChatCommand = "permamute" Plugin.Usage = "[players] [1/0]" Plugin.Privileges = { "PermaMute" } function Plugin:Call( ply, args ) if (not sql.TableExists( "permamuted_players" ) ) then query = "CREATE TABLE permamuted_players ( steamID varchar(255), isMuted int )" result = sql.Query(query) end if ( ply:EV_HasPrivilege( "PermaMute" )) then local enabled = ( tonumber( args[ #args ] ) or 1 ) > 0 local players = evolve:FindPlayer( args, ply, true ) for _, pl in ipairs( players ) do if ( enabled ) then query = "UPDATE permamuted_players SET isMuted = 1 WHERE steamID = '"..pl:SteamID().."'" sql.Query(query) evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has permanently muted ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) else query = "UPDATE permamuted_players SET isMuted = 0 WHERE steamID = '"..pl:SteamID().."'" sql.Query(query) evolve:Notify( evolve.colors.blue, ply:Nick(), evolve.colors.white, " has unmuted ", evolve.colors.red, evolve:CreatePlayerList( players ), evolve.colors.white, "." ) end end end end function Plugin:PlayerCanHearPlayersVoice( _, ply ) ID = sql.QueryValue( "SELECT isMuted from permamuted_players WHERE steamID = '"..ply:SteamID().."'" ) if ( ID == 1 or ply.EV_MUTED) then return false end end end function Plugin:Menu( arg, players ) if ( arg ) then table.insert( players, arg ) RunConsoleCommand( "ev", "permamute", unpack( players ) ) else return "Permanently Mute", evolve.category.punishment, { { "Enable", 1 }, { "Disable", 0 } } end end evolve:RegisterPlugin( Plugin ) [/lua][/QUOTE] You've got an extra 'end' after Plugin:PlayerCanHearPlayersVoice. You also really need to indent your code better. I have run it through an autoindenter and put it in the quote as an example. Perhaps you should try and editor such as [url=http://www.sublimetext.com/]Sublime Text[/url] which will automatically indent as you type?
Exist lua code for this? I have an animation: [CODE]self.Weapon:SendWeaponAnim(ACT_VM_IDLE) [/CODE] And i need to play sound from 16. frame this animation (sequence) like [CODE]if AnimFrame (16) = then //Number of frame self.Weapon:EmitSound("MySound.wav") //Play sound end [/CODE] And playing animation material [CODE]if AnimFrame (16) = then //Number of frame render.SetMaterial( "self.num_one ?") //Goddammit i dont know what set here end local Yaytexture = Material( "textures/mytexture" ) local num_one = Material( "textures/Modeldefaulttexture" ) num_one:SetMaterialTexture( "$basetexture", Yaytexture:GetMaterialTexture("$basetexture") ) //replace default texture with new texture [/CODE] Is there exist some code for this???
[QUOTE=predator cz;37479188]Exist lua code for this? I have an animation: [CODE]self.Weapon:SendWeaponAnim(ACT_VM_IDLE) [/CODE] And i need to play sound from 16. frame this animation (sequence) like [CODE]if AnimFrame (16) = then //Number of frame self.Weapon:EmitSound("MySound.wav") //Play sound end [/CODE] And playing animation material [CODE]if AnimFrame (16) = then //Number of frame render.SetMaterial( "self.num_one ?") //Goddammit i dont know what set here end local Yaytexture = Material( "textures/mytexture" ) local num_one = Material( "textures/Modeldefaulttexture" ) num_one:SetMaterialTexture( "$basetexture", Yaytexture:GetMaterialTexture("$basetexture") ) //replace default texture with new texture [/CODE] Is there exist some code for this???[/QUOTE] Checking I understand this correctly. You want to - Play an animation on a weapon - Wait 16 animation frames - Play a sound - Change the material on the weapon Right?
[QUOTE=Lexic;37479439]Checking I understand this correctly. You want to - Play an animation on a weapon - Wait 16 animation frames - Play a sound - Change the material on the weapon Right?[/QUOTE] Not that right I want: Play an animation On 16. animation frame play sound and change material. Thats all.
[QUOTE=Persious;37477832]Uh, I tried it on multiplayer with a player, I might need to re-check the code.[/QUOTE] Why sending 2 strings and looping through all players? Use umsg.Entity instead. [QUOTE=itkuitkzhji;37478678]@Divran,Drakehawke: Thx guys. ^_^ New noob question: I want my entity to be removed if the owner of it leaves the server. Here is what I've tried: [CODE]function RemoveDisconected( Player ) if ( owner == Player ) then self:Remove() end end hook.Add("PlayerDisconnected","RemoveThisEntity",RemoveDisconected)[/CODE] But this returns an error: "...\init.lua:92] attempt to index global 'self' <a nil value>". Q_Q[/QUOTE] [lua] function RemoveDisconected( Player ) for k,v in pairs(ents.GetAll()) do if ( v:GetOwner() == Player ) then v:Remove() end end end hook.Add("PlayerDisconnected","RemoveThisEntity",RemoveDisconected) [/lua]
Recently I realized, that with some scripted entites, if a player grabs them with the physgun and move it, the entity actually moves, but the physgun beam points to a completely different location. Why is that happening, and how to fix it? [editline]31st August 2012[/editline] So far my investigation shows, it has something to do with client, and serverside physics meshes
I was wondering is it possible to make a button that changes a rcon convar value. rcon sbox_noclip does not work because there should be no space there and I dont know how to put a space a different way.
How could I attach an effect above a entities head.
[lua] local pos = (ent:GetPos() + Vector(0, 0, 50)); local data = EffectData(); data:SetStart( pos ); data:SetOrigin( pos ); data:SetScale( 1 ); util.Effect("fx_name", data); [/lua]
[QUOTE=Undefined;37479742][lua] function RemoveDisconected( Player ) for k,v in pairs(ents.GetAll()) do if ( v:GetOwner() == Player ) then v:Remove() end end end hook.Add("PlayerDisconnected","RemoveThisEntity",RemoveDisconected) [/lua][/QUOTE] Thank you for this. I've tried to get it to work but again without success. :/ [CODE]function RemoveDisconected( Player ) for k,v in pairs(ents.GetAll()) do if (v:GetName() == "Entityname") then print(v:GetOwner()) v:Remove() end end end hook.Add("PlayerDisconnected","RemoveThisEntity",RemoveDisconected)[/CODE] However this works which I did for testing purpose. Interesting is the result for v:GetOwner() is "[NULL Entity]" instead of the owners name who left the server. Any more ideas? q_q Edit: This is solved. I made a noobish workaround. ^^
[QUOTE=PencilOnDesk;37474539]Are you using bots? I could never get that method to work with bots. If it works on yourself that's proof of concept, it'll work in a multiplayer setting though; I've used the method numerous times.[/QUOTE] [lua] -- SERVER function UpdateScoreboardItems( pl ) umsg.Start("SendUpdatedItems", pl) for k, v in pairs(player.GetAll()) do umsg.String(v:SteamID()) umsg.String(GModFloor.Classes[v.Class].Name) umsg.Long(v:GetMoney()) end umsg.End() end concommand.Add("gmodfloor_updatescoreboard", UpdateScoreboardItems) -- CLIENT function GetUpdatedItems(um) local ID, Class, Money = um:ReadString(), um:ReadString(), um:ReadLong() for k,v in pairs(player.GetAll()) do if v:SteamID() == ID then v.Class = Class v.Money = Money break end end end usermessage.Hook("SendUpdatedItems", GetUpdatedItems) [/lua]
Why are you using the SteamID? Use umsg.Entity with the actual player object?
[QUOTE=Drakehawke;37483401]Why are you using the SteamID? Use umsg.Entity with the actual player object?[/QUOTE] Hm, I could try that. I'm pretty new to usermessages, so I'm still learning.
Can someone give an example how to build a simple cube with meshes?
Grab the gmod12 implementation from here: [URL]http://glua.me/bin/?path=/lua/includes/extensions/mesh.lua[/URL]
[QUOTE=MDave;37483542]Grab the gmod12 implementation from here: [URL]http://glua.me/bin/?path=/lua/includes/extensions/mesh.lua[/URL][/QUOTE] Hmm.. Can i actually make a cube with physics using that code? Like to spawn in-game without making a SENT?
[QUOTE=Persious;37483411]Hm, I could try that. I'm pretty new to usermessages, so I'm still learning.[/QUOTE] There : [lua] -- SERVER function UpdateScoreboardItems( pl ) for k, v in pairs(player.GetAll()) do umsg.Start("SendUpdatedItems", pl) umsg.Entity(v) umsg.String(GModFloor.Classes[v.Class].Name) umsg.Long(v:GetMoney()) umsg.End() end end concommand.Add("gmodfloor_updatescoreboard", UpdateScoreboardItems) -- CLIENT function GetUpdatedItems(um) local ply, Class, Money = um:ReadEntity(), um:ReadString(), um:ReadLong() if ValidEntity(ply) then ply.Class = Class ply.Money = Money end end usermessage.Hook("SendUpdatedItems", GetUpdatedItems) [/lua]
[QUOTE=ollie;37483587]Hmm.. Can i actually make a cube with physics using that code? Like to spawn in-game without making a SENT?[/QUOTE] No, definitely not. You need to create an entity. Take a look at the Entity:PhysicsFromMesh documentation, and SENT creation. Also you will find the IMesh:Draw() function very useful.
How can I center a DModelPanels view so the model is like, directly on the model, if the model is a player model?
I'm very new to Lua, just picked it up a few days ago. I've got a init script I'm making, and I keep getting the following error: Hook 'OnPlayerConnect' Failed: [@init.lua:31] bad key to string index (number expected, got string) The script is below. [lua] function player_exists(name, address) local steamID = name:SteamID() local result = sql.Query("SELECT steam_id, money, rpname, experience, corporation FROM player_info WHERE steam_id = '"..steamID.."'") if(result) then sql_value_info(steamID, name) sql_value_inventory(steamID, name) else new_player(steamID, name) end end hook.Add("PlayerConnect", "OnPlayerConnect", player_exists) [/lua] Where did I go wrong?
Sorry, you need to Log In to post a reply to this thread.