ULX

Author Topic: Restriticing  (Read 1525 times)

0 Members and 1 Guest are viewing this topic.

Offline Redemption_2000

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Restriticing
« on: December 24, 2017, 09:35:25 AM »
Okay so basically what I want to know how would I restrict ULX Commands to a set DarkRP team say i want to make the script below only to be used by TEAM_EP & TEAM_SOD
Code: [Select]
local CATEGORY_NAME = "Apple's Creations"


function ulx.giveweapon( calling_ply, target_plys, weapon )


local affected_plys = {}
for i=1, #target_plys do
local v = target_plys[ i ]

if not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is dead", true )

else
v:Give(weapon)
table.insert( affected_plys, v )
end
end
ulx.fancyLogAdmin( calling_ply, "#A gave #T weapon #s", affected_plys, weapon )
end


local giveweapon = ulx.command( CATEGORY_NAME, "ulx giveweapon", ulx.giveweapon, "!giveweapon" )
giveweapon:addParam{ type=ULib.cmds.PlayersArg }
giveweapon:addParam{ type=ULib.cmds.StringArg, hint="weapon name" }
giveweapon:defaultAccess( ULib.ACCESS_ADMIN )
giveweapon:help( "Give a player a weapon - !giveweapon" )



function ulx.sgiveweapon( calling_ply, target_plys, weapon )


local affected_plys = {}
for i=1, #target_plys do
local v = target_plys[ i ]

if not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is dead", true )

else
v:Give(weapon)
table.insert( affected_plys, v )
end
end
end


local sgiveweapon = ulx.command( CATEGORY_NAME, "ulx sgiveweapon", ulx.sgiveweapon )
sgiveweapon:addParam{ type=ULib.cmds.PlayersArg }
sgiveweapon:addParam{ type=ULib.cmds.StringArg, hint="weapon name" }
sgiveweapon:defaultAccess( ULib.ACCESS_ADMIN )
sgiveweapon:help( "Give a player a weapon silently" )

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Restriticing
« Reply #1 on: December 24, 2017, 02:20:13 PM »
ULX has little to do with teams, so it's not ULX code.
You'd need to add team checks

Player:Team
team.GetName

Though the below should work, it's untested, and doesn't include ANY nice logging or notification to the person trying to run it why it didn't work.
It would need to be added in the beginning of the function.

Code: [Select]
calling_ply_team = calling_ply:Team() -- get team index number
calling_ply_teamname = team.GetName( calling_ply_team ) -- get name of team index number
if calling_ply_teamname ~= "TEAM_EP" or calling_ply_teamname ~= "TEAM_SOD" then return -- if name isn't EP or SOD, return out of function doing nothing.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming