How do I make a class have god mode on it, I want to create a admin on duty class but dont know how to make it so that people cant kill that class. I know how to put on god mode in the ulx menu put I want it in the class.
[highlight](User was banned for this post ("Wrong section" - mahalis))[/highlight]
This goes in questions , not main lua
by class you mean in fretta?
i mean like police, citizen, cook, gangster
[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerShouldTakeDamage]Gamemode.PlayerShouldTakeDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
This should put you on the right track. Have a look at the examples.
Thank you thats exactly what I wanted, what file do i put that code in.(Im new to lua)
we put it into the init.lua and then the server went to base gamemode
You cant just, put it there and it works.
You need to learn some basic lua and get some common sence before attempting to do it.
[highlight](User was banned for this post ("This isn't helpful" - mahalis))[/highlight]
where do i put it in the file?, i was told to put it in the init.lua file so i did and it doesnt work
Listen to what we say.
An experienced lua scripter would know, you dont just copy and paste, you have to create the function, do some arguments and return something.
So if you want this done, learn lua and do it yourself, its not that hard.
how do i create a function though, im just going off other types of scripting which i know basics about like java. You go into the file and then you type your code so i typed what the function said on the wiki
We aint gonna help you with starting lua, we dont spoon feed.
Go read the lua pil then come back.
Ive read about the function and Ive put the code in and it works however it works for the admins whatever the class is, where as i wanted to try and get it so when there say in class Admin on Duty they have god mode
Well if that script does it for admins then you need to do as i said for the 3rd time. Learn lua and write a function for what you do want.
You cant take a function that makes people say something in chat, image it making them explode and it magically does it all by itself. You actually need to make it do it.
[QUOTE=Science;31987990]We aint gonna help you with starting lua, we dont spoon feed.
[b]Go read the lua pil then come back.[/b][/QUOTE]
So why are you still here then?
[highlight](User was banned for this post ("Derailing" - mahalis))[/highlight]
We didn't just grab a function and stick it in init.lua.
Read the [URL="http://www.lua.org/pil/"]Lua PIL[/URL], that should get you started with the basics of programming in Lua. If that's too complex for you (start out basic) then you are going to struggle.
Once you've done that, take a look at what other people have made, make small changes to get a feel for GM Lua.
Also, [b][url=http://wiki.garrysmod.com/?title=Player.GodEnable]Player.GodEnable [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[lua]function playershouldtakedamage(victim, attacker)
if (victim:IsAdmin() and victim:GetTeam("onduty")) then
return false
else
return true
end
end
hook.Add( "PlayerShouldTakeDamage", "playershouldtakedamage", playershouldtakedamage)[/lua]
Tadah. Put it in init.lua and hopefully it'll work. Change the 'onduty' bit to the method matching DarkRP, and the string to the class that you made, and it should go.
Ready for boxes.
Killer, ive tried that and it doesnt work, i came up with this one:
[CODE]hook.Add( "PlayerSpawn", "SPAWN:God", function( ply )
if( ply:Team( ) == TEAM_UNASSIGNED ) then
ply:GodEnable( )
end
end )[/CODE]
But that doesnt work either
Because i wasn't fully sure what you wanted me to do I made it so that when an Admin says /god it either God modes them or UnGodmodes them. There is probably a more effective and cheaper way to do this but this should work
In your init.lua Copy and past this anywhere after the first couple of lines
[CODE]
function GodChatCommmand( ply, text, public )
local godAdmins = {}
if ply:IsAdmin and text == "/god" then
for k,v in pairs(godAdmins) do
if v = ply then
ply:GodDisable()
elseif k = table.GetLastKey(godAdmins) then
godAdmins[ k + 1 ] = ply
ply:GodEnable()
end
end
end
end
hook.Add( "PlayerSay", "God Chat Command for Admins", GodChatCommand )
[/CODE]
am i right in putting this in the init.lua file in the darkrp folder.
[editline]29th August 2011[/editline]
Is there a way i can make it so that when they spawn as the admin on duty class it automatically says /god.
[QUOTE=selekton99;32001754]Because i wasn't fully sure what you wanted me to do I made it so that when an Admin says /god it either God modes them or UnGodmodes them. There is probably a more effective and cheaper way to do this but this should work
In your init.lua Copy and past this anywhere after the first couple of lines
[CODE]
function GodChatCommmand( ply, text, public )
local godAdmins = {}
if ply:IsAdmin and text == "/god" then
for k,v in pairs(GodAdmins) do
if v = ply then
ply:GodDisable()
elseif k = table.GetLastKey(godAdmins) then
godAdmins[ k + 1 ] = ply
ply:GodEnable
end
end
end
end
hook.Add( "PlayerSay", "God Chat Command for Admins", GodChatCommand )
[/CODE][/QUOTE]Theres so many mistakes in there, it wont work.
[QUOTE=Science;32002738]Theres so many mistakes in there, it wont work.[/QUOTE]
Why don't you be a nice fellah and tell him what mistakes he made (apart from the odd capitalization error)? I sure can't see any, and I'm sure he would appreciate the kind gesture.
Once again.
You try and spoon feed him.
Dont do it, let him learn the hard way.
[QUOTE=Science;32004734]Once again.
You try and spoon feed him.
Dont do it, let him learn the hard way.[/QUOTE]
That's not spoon feeding him; you can tell him what mistakes he made without providing the complete code.
[CODE]
function playershouldtakedamage(victim, attacker)
if (victim:IsAdmin() && victim.DarkRPVars.job != nil && victim.DarkRPVars.job == "Admin on duty") then
return false
else
return true
end
end
hook.Add( "PlayerShouldTakeDamage", "playershouldtakedamage", playershouldtakedamage)
[/CODE]
The above code should work for you. People apparently don't realize that your team is not your darkrp job.
[QUOTE=Scotty1207;32001568]i came up with this one[/QUOTE]
actually that's funny because I remember typing that on my phone for you and after like a week you still didn't listen to where I told you to put it.
he keeps putting things into random if statements and loops and honestly he isn't trying.
Sorry, you need to Log In to post a reply to this thread.