Author Topic: How to autorun commands on groups  (Read 1903 times)

0 Members and 1 Guest are viewing this topic.

Offline Wimoweh

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
How to autorun commands on groups
« on: September 05, 2013, 04:24:24 PM »
Just for fun, I made a group called "punished" on my server to mess with one of my friends, where the chat tag and the rank would be "Dunce." But then this got me thinking, about having an actual punished rank where it would be better than slaying if they've been misbehaving too much. I was thinking of a lua file in autorun that would check for their group, and if they are punished, it would strip them if they have a weapon, gag them if they are ungagged, and the same for mute, so they can only be unpunished by asking through asay. How would I do this though? I don't know how to make the file check for things, I only know how to make it do things on a if then basis, like if punished, then ulx gag, etc. The checking would be so the server doesn't lag from running the code every second. This is where I am so far:

Code: [Select]
//Autorun for commands on certain groups

--No Weapons for Punished

function No_Weaps( calling_ply, target_plys )

local affected_plys = {}

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

(if v:IsUserGroup("punished")) and (if v:) then
v:ulx.strip
ULib.tsayError( calling_ply, v:Nick() .. " is not allowed to hold weapons!", true )
end
end
end

--No talking for Punished

function No_Talk( calling_ply, target_plys )

local affected_plys = {}

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

(if v:IsUserGroup("punished")) and (if v:) then
v:ulx.gag
ULib.tsayError( calling_ply, v:Nick() .. " is not allowed to talk!", true )
end
end
end

--No typing for Punished

function No_Type( calling_ply, target_plys )

local affected_plys = {}

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

(if v:IsUserGroup("punished")) and (if v:) then
v:ulx.mute
ULib.tsayError( calling_ply, v:Nick() .. " is not allowed to type!", true )
end
end
end

The second if v: in each function is for the checking, so it would check their group and their state.
« Last Edit: September 05, 2013, 04:27:09 PM by Wimoweh »

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: How to autorun commands on groups
« Reply #1 on: September 07, 2013, 05:48:41 AM »
For one you are calling the ulx functions wrong, they aren't in the players metatable.
You should look at ulx\modules\sh\chat.lua to see how to call it.

Secondly you don't seem to know how if statements work, it should look like this:
Code: [Select]
if v:IsUserGroup("punished") then(you should read this)

Thirdly your functions don't appear to be hooked to anything (unless you've done that in a part of the script you haven't posted)


I don't mean to be rude, but you really need to at least know the very basics of lua before you start trying to use it.