• How to choose avatar
    11 replies, posted
Hi, I am wondering is there any way to make an avatar choosing window like CS does? When people log on my server, they are asked to choose their avatar. Thanks for help!!
So you want a panel to popup when your players spawn so they can choose a player model?
You mean a playermodel? If by "CS" you mean Counter Strike: Source, then thats a playermodel. Although if you mean an avatar as in a headshot of the model, thats probably a spawn icon. I cant really tell because your post is written so poorly it makes it nearly impossible to read..
I think first is an automatic pop up window when people log on. The function of window is choosing the appearance of the avatar the player like. Just like what Counter Strike does.
Okay when you say "log on" do you mean join? And.. you need to make a derma panel that has the models you want them to choose. Just make it open when they loadout.
Thanks! However, which function can make the panel pop up automatically when join, instead of typing in console the command added by concommand.Add?
I dont think there is a function.. Do a usermessage so that they can't type in the command in console.
[lua]function GM:PlayerInitialSpawn( ply ) self.BaseClass:PlayerInitialSpawn( ply ) RunConsoleCommand( "put the command you made here" ) end[/lua]
So this function should be put in autorun/server? This what I did: I put the following code in Spwan.lua in folder lua\autorun\server as well as lua\autorun\client, and in GMod I choose "create multiplayer" and use gm_construct map. There is no response when the game start, but a blue sentence in console: "autorun/server/Spwan.lua:3: attempt to index global 'vgui' (a nil value)" This is my lua code: function setSenaris() --Create the frame local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself DermaPanel:SetPos( 50,50 ) -- Position on the players screen DermaPanel:SetSize( 500, 400 ) -- Size of the frame DermaPanel:SetTitle( "Please choose the senario" ) -- Title of the frame DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) -- Draggable by mouse? DermaPanel:ShowCloseButton( true ) -- Show the close button? DermaPanel:MakePopup() -- Show the frame function DermaPanel:Paint() surface.SetDrawColor( 0, 0, 0, 255 ) surface.DrawRect( 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall()) end end concommand.Add("setSenaris",setSenaris) hook.Add("PlayerInitialSpawn", "OpenMenu", function(ply) ply:ConCommand("setSenaris") end) I really wonder why vgui can not run here then, as I put the same code in autorun\client and type the command in console it runs quite well. Is it because it is in server folder? --PS: I change the setSenaris by: function setSenaris() Msg("hello world") end It really works, for in console it shows : hello worldRedownloading all lightmaps which indicate hook.Add works. And the following is also correct: function setSenaris() Msg("hello world") end concommand.Add("setSenaris",setSenaris) function RunningConCommand() RunConsoleCommand("setSenaris") end hook.Add("PlayerInitialSpawn", "OpenMenu", RunningConCommand) --ps2: How do you guys post those codes in the form of Notepad++???
[QUOTE=FAU78;20119507]So this function should be put in autorun/server? This what I did: I put the following code in Spwan.lua in folder lua\autorun\server as well as lua\autorun\client, and in GMod I choose "create multiplayer" and use gm_construct map. There is no response when the game start, but a blue sentence in console: "autorun/server/Spwan.lua[noparse]:3:[/noparse] attempt to index global 'vgui' (a nil value)" This is my lua code: -snip-[/QUOTE] The error is because vgui doesn't exist on the server. Try this in [B]lua/autorun/Spawn.lua[/B] [lua] if(CLIENT) then function setSenaris() --Create the frame local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself DermaPanel:SetPos( 50,50 ) -- Position on the players screen DermaPanel:SetSize( 500, 400 ) -- Size of the frame DermaPanel:SetTitle( "Please choose the senario" ) -- Title of the frame DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) -- Draggable by mouse? DermaPanel:ShowCloseButton( true ) -- Show the close button? DermaPanel:MakePopup() -- Show the frame function DermaPanel:Paint() surface.SetDrawColor( 0, 0, 0, 255 ) surface.DrawRect( 0, 0, DermaPanel:GetWide(), DermaPanel:GetTall()) end end concommand.Add("setSenaris",setSenaris) else hook.Add("PlayerInitialSpawn", "OpenMenu", function(ply) ply:ConCommand("setSenaris") end) end [/lua] You might need to add [b][url=wiki.garrysmod.com/?title=AddCSLuaFile]AddCSLuaFile [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] but I can't test it right now. [QUOTE=FAU78;20119507]How do you guys post those codes in the form of Notepad++???[/QUOTE] It's [noparse][lua]Code Here[/lua][/noparse]
It says: "Unknown Command: 'setSenaris'"....
Sorry, you need to Log In to post a reply to this thread.