Ok I'am making this gamemode but I could do with some help if any one is willing to help me. :)
Ok so I want to make a F2 menu for my gamemode to pick a class;
Sniper, Rife, and Patriot
How would i go about making this menu? All I can do is make the frame and add detail to it.
Well you'll have to be a little more specific about what you need help on. If it's about designing the derma itself you might want to look at other gamemodes for examples, if you need help about a particular function feel free to name it and if it's about making the menu show up F2 you can simply use the [url=http://wiki.garrysmod.com/?title=Gamemode.ShowTeam]ShowTeam hook[/url].
Thank you! I've been wanting that thank you :D but how do you make it another key like f3 or f4?
Take a look at the "See Also" at the bottom of the page ;)
then read them.
I tryed
Server Side:
function SchoolShow( ply )
ply:ConCommand( "SchoolMe" )
end
hook.Add("ShowTeam", "School", SchoolShow)
function Givesniper( ply )
give( "Barret .50 cal")
end
concommand.Add("sniper_class")
then Client side:
function SchoolShow( ply )
local classes = vgui.Create( "DFrame" )
classes:SetPos( 50,50 )
classes:SetSize( 100, 200 )
classes:SetTitle( "Pick Your Class" )
classes:SetVisible( true )
classes:SetDraggable( false )
classes:ShowCloseButton( true )
classes:MakePopup()
local DermaButton = vgui.Create( "DButton" )
sniper:SetParent( "classes" )
sniper:SetText( "Sniper" )
sniper:SetPos( 50, 10 )
sniper:SetSize( 80, 10 )
sniper.DoClick = function ()
RunConsoleCommand( "sniper_class" )
end
But it just ruins the gamemode? give me alittle help here? please.
This is a shot out of the dark, but try make client side and server side in different LUAs?
How so?
[QUOTE=jamie009;16540650]function SchoolShow( ply )
ply:ConCommand( "SchoolMe" )
end[/QUOTE]
If you want this to be called when the F2 menu is pressed, you could just do:
[lua]function GM:ShowTeam( pl )
pl:SendLua( "FunctionName()" ) --Alternative to ConCommand
end[/lua]
That's an alternative, I've never used the hook for it as I'm not sure it works the same way as the actual function.
As for:
[lua]function Givesniper( ply )
give( "Barret .50 cal")
end[/lua]
That wont work. The weapon name is what the folder containing the lua files for the weapon is named, something like weapon_barret ( Example ). You're using the give function wrong, or forgetting something.
[lua]function SniperGive( pl )
pl:Give( "weapon_sniper" )
end[/lua]
So this should work? Should i not use the hook?
function SchoolShow( ply )
pl:SendLua( "FunctionName()" )
end
hook.Add("ShowTeam", "School", SchoolShow)
function SniperGive( pl )
pl:Give( "weapon_sniper" )
end
concommand.Add("sniper_class")
I've doen it all gamemodes working but the menu comes back with
Warning: Unhandled usermessage 'SchoolMe'
Fixed it all but now i get
Unknowncommand:sniper_class
and there buttons will not follow the menu and when pressing f2 they will appear behide the menu its self
function SchoolShow( ply )
local classes = vgui.Create( "DFrame" )
classes:SetPos( 400, 300 )
classes:SetSize( 250, 200 )
classes:SetTitle( "Pick Your Class" )
classes:SetVisible( true )
classes:SetDraggable( true )
classes:ShowCloseButton( true )
classes:MakePopup()
local sniper = vgui.Create( "DButton" )
sniper:SetParent( classes )
sniper:SetText( "Sniper" )
sniper:SetPos( 400, 300)
sniper:SetSize( 230, 20 )
sniper.DoClick = function ()
classes:Close()
RunConsoleCommand( "sniper_class" )
end
That's because you don't have a function Sniper_class >.>
please read the wiki! [url]http://wiki.garrysmod.com/?title=LUA:Gamemode_from_scratch[/url]
EDIT:
also PLEASE put your code in [ lua][ /lua] or [ code][ /code] tags!
Look before you post
[code]function SniperGive( ply )
ply:Give("weapon_sniper")
end
concommand.Add("sniper_class", SniperGive)[/code]
[QUOTE=jamie009;16580750]Look before you post
[code]function SniperGive( ply )
ply:Give("weapon_sniper")
end
concommand.Add("sniper_class", SniperGive)[/code][/QUOTE]
LAWL! FAIL! you changed it before you posted! In the original you forgot the second argument!!!! So technically I AM right and I DID read it. But now you say its still not working? I just woke up so ill take a look at it when im fully awake, as I dont see any errors at the moment
[editline]06:49AM[/editline]
[QUOTE=jamie009;16560814]So this should work? Should i not use the hook?
function SchoolShow( ply )
pl:SendLua( "FunctionName()" )
end
hook.Add("ShowTeam", "School", SchoolShow)
function SniperGive( pl )
pl:Give( "weapon_sniper" )
end
concommand.Add("sniper_class")[/QUOTE]
Heres the proof! :D
Yes but thats why i said i fixed it....
but i did have the function posted
For F3/F4 I think you can bind it to GMShowSpare2 and 3. (something like that)
And GMShowHelp for F1.
dude i've already done that i just get [code]Unknowncommand:sniper_class[/code] but thanks for replying
Post your code please
No worrys i have fixed it :) but i get this error back
[code]NULL Ent in GiveNamedItem![/code]
[code]function SniperClass(ply)
ply:Give("weapon_sniper")
return ""
end
AddChatCommand("/sniper", SniperClass)[/code]
[IMG]http://i245.photobucket.com/albums/gg49/Jamiez_Rascall/Ha1.png[/IMG]
[code]function SniperClass(ply)
ply:Give("sniper")
return ""
end
AddChatCommand("/sniper", SniperClass)[/code]
[code]
{TAB} Jamiez Rascall S.A.S. -> said "/sniper"
Attempted to create unknown entity type sniper!
NULL Ent in GiveNamedItem!
[/code]
do you have a init.lua, cl_init.lua, and a shared.lua in the folder?
This is where i say Go Read The Wiki!
If your having this bad of a problem to where we are creating the code FOR you because you are simply copy/pasting the code we give you, you do NOT know how to script.
Get off my back ffs I have read it and understood it, am going through the script to look why it will not do it its just the name is a bit mixed up OK and am not copying and pasting your code I fixed my menu by myself, you have not been any use what so ever. Its just this simple error I need to figure out and i thought some one on here would find out my problem before i do...
Make sure the weapon works first.
It does I ensure you.
With the error you're getting, either the name of the weapon is incorrect, or the weapon is broken.
Try it with the other weapons you have there, and see if they work. If so, its the sniper weapon thats broken.
Ok ill check it out see you guys inabit Thank you for helping me out
[QUOTE=jamie009;16588287]Get off my back ffs I have read it and understood it, am going through the script to look why it will not do it its just the name is a bit mixed up OK and am not copying and pasting your code I fixed my menu by myself, you have not been any use what so ever. Its just this simple error I need to figure out and i thought some one on here would find out my problem before i do...[/QUOTE]
I have been trying to help and you continually ignore me. Look at my last post! lol way to read.
If you DO know how to code then why are you simply copy pasting what we submit? The proof is all there. In every post I help you then slam you for your lack of common sense and reading abilities.
Oh and Crazy, Would have responded but I was too busy puking my brains out. :(
The kid has no scripting knowledge whatsoever. I am almost positive that the kid still has SchoolShow as his function name for the team select.
Dude your not helping.... and no I have been pasting some of it to see if it works but they all failed but am glad the people helped me. But of course I can't code cause I've just started out.... Its like when you learned to code, you could not code before hand any way, I do read but some of the TUTs on Garrysmod WIKI are not that user friendly I believe in my opinion. Please don't call me Kid cause if you want respect off me give me some respect and call me Jamie... Or don't address me at all and dont bring common sense into cause I think I would know where to place the weapon folders.
PS. Nobody in here told me to use [code]AddChatCommand[/code]
Thats all I have to say to you.
Sorry, you need to Log In to post a reply to this thread.