Need Help! How to make the muder spawn with certain weapons depending on rank (Murder)

Hey Guys!

I am a noob lua coder, i am looking to code a function on my server where if your a admin, mod, vip, or donater etc… you would spawn with a different knife as murder (making stuff more intresting).

E.g if i was a superadmin, i spawn as murder with a katana insted of a knife… if i was donator i spawn with a karambit (a fancy knife) insted of a regular one.

i have not started, i dont not want to skrew up my server with lua errors. I do not have a private server to test stuff.

If someone could help me out, by maybe posting what my code should look like. Help me out with some hooks. That would be GREATLY appreciated!

Thanks guys!

Singleplayer.

[lua]WeaponEquip – When weapon is equipped (so it’ll swap it) [/lua]

Create the weapon entities (just copy the knifes code but change the weapons model and holdtype, as well as sound)

And basically if you’re using ulx then

[lua]if ply:IsUsergroup(“superdooperpay4admin”) then
ply:Give(“superleetkatana”)
end[/lua]

Ty soo much! ill test it and get back to you! :wink:

[editline]14th March 2014[/editline]

wait, sorry again. where does this go? :smiley:

Serverside.

lol… i might seem like a total noob, but what exact file name? ;D

He didn’t give you exact code. You’ll have to find where in the code murderers are given weapons, and from there, add the if statement he provided.

ok, ty! helped out alot :wink:

[editline]15th March 2014[/editline]

http://puu.sh/7vYGx.png

Thats my code. I tried it, nothing showed up! no new katana slot, or anything just the knife. Please help!

Thank you :wink:

Try this



function GM:PlayerLoadout(ply)

	ply:Give("weapon_rp_hands")
	--ply:Give("weapon_fists")
	
	if ply:GetMurderer() and ply:IsUserGroup("superadmin") then
		ply:Give("katana")

	elseif ply:GetMurderer() and ply:IsUserGroup("donator") then
		ply:Give("karambit")

	elseif ply:GetMurderer() then
		ply:Give("weapon_mu_knife")

	end
end


Let’s stop being bad coders for a minute and follow some basic standards of not overwriting gamemode functions.

[lua]hook.Add(“PlayerLoadout”, “CustomMurderWeapons”, function(ply)
ply:Give(“weapon_rp_hands”)

if ply:GetMurderer() and ply:IsUserGroup("superadmin") then
	ply:Give("katana")
elseif ply:GetMurderer() and ply:IsUserGroup("donator") then
	ply:Give("karambit")
elseif ply:GetMurderer() then
	ply:Give("weapon_mu_knife")
end

return true

end)[/lua]

Now OP, this will go in lua/autorun/server/vinh.lua

Make sure you have your weapons installed correctly too, and that you’re actually using the correct entity names for them.

thanks alot! ^^

[editline]15th March 2014[/editline]

Will try and get back to you on if it works

Do you have a weapon with the name “katana” or do you just have a model?

http://puu.sh/7wlMq.png

would i use the “v_katana”? or how exacly do i find the name?

You only have the model files, you need an actual swep.

yea, like i have one from the workshop

http://puu.sh/7wmcs.png

http://puu.sh/7wmdG.png

[editline]15th March 2014[/editline]

http://puu.sh/7wmkM.png

[editline]15th March 2014[/editline]

http://puu.sh/7wnZW.png

i have named folders in both the same name as the “mu_knife” but i changed the name to “mu_katana” i copied the stuff from the knife files and changed the files and names to the katana.
i am working on the entities.

[editline]15th March 2014[/editline]

soo, im super admin and i get the Katana!!. but users dont get a knife please help!

I Changed the code back to the regular one and they still dont get a knife!

I dont understand the picture

It’s a knife?

ok, cut out the pic… my problem is. super admins get the katana. but if a user is murder they dont get a knife at all

Is “weapon_mu_knife” a valid knife SWEP?

^^ yup! its the defult knife!

[editline]15th March 2014[/editline]

Also another problem is when you throw the katana as a superadmin, when you pick it back up its a defult knife

  1. Who doesn’t get a weapon as a murderer? Admins? Donators? Normal users.
  2. That’s an issue with the script using knife ammo for the katana.

do i use katana ammo?? :smiley: and normal users dont get the knife