• Restrict Weapons to team
    5 replies, posted
Hello I am wanting to make a DarkRP module that can restrict weapons for a certain class, now I have this code: [LUA]-- MADE BY WHOLEGAMER {STEAM_0:1:36346089} // To block weapons by the job, copy this and replace where it says "Citizen" and put the job name. EG: Hobo local TEAM_CITIZEN = { "weapon_shotgun" } function WeaponRestricting(ply, wep) local pickup = wep:GetClass() local cjob = ply:Team() if table.HasValue( cjob , pickup ) then // Checks if the the player of a certain job is picking up a certain weapon return false else return true end end hook.Add("PlayerCanPickupWeapon", "WeaponPickup", WeaponRestricting)[/LUA] And I get this error: [url]https://dl.dropboxusercontent.com/u/88717145/Public%20Photos/Error%203.JPG[/url] Also when a player spawns, they have no weapons at all. What have I done wrong?
Thats not how table.HasValue works.
Oh damn. Is there anyway that I can do that? Check if there is a table with the name of their job / team, and that it contains the weapon being attempted to be picked up, and if it does return false?
[code]-- MADE BY NOT WHOLEGAMER {STEAM_0:1:337} // To block weapons by the job, copy this and replace where it says "Citizen" and put the job name. EG: Hobo local BlockedTeamWeps = {} BlockedTeamWeps[ TEAM_CITIZEN ] = { "weapon_shotgun" } function WeaponRestricting(ply, wep) local pickup = wep:GetClass() local cjob = ply:Team() if table.HasValue( BlockedTeamWeps[cjob] , pickup ) then // Checks if the the player of a certain job is picking up a certain weapon return false else return true end end hook.Add("PlayerCanPickupWeapon", "WeaponPickup", WeaponRestricting)[/code]
Many thanks, and I appreciate your humor. Haha :) [editline]24th October 2013[/editline] But now when players change to a job other than Citizen they have no weapons at all, not even a Physgun? [editline]24th October 2013[/editline] New error is: [url]https://dl.dropboxusercontent.com/u/88717145/Public%20Photos/Error4.JPG[/url]
Did you add the other jobs and weapons to the table?
Sorry, you need to Log In to post a reply to this thread.