• Print

Author Topic: Prefix help  (Read 4562 times)

0 Members and 1 Guest are viewing this topic.

Offline IizStormViper

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Prefix help
« on: July 07, 2012, 04:29:20 pm »
Hey So I'm setting up ULX to add tags in front of names, but I'm new to lua, this is what I have I thought it would work but it doesn't, Unless I am putting it in the wrong.lua? Mostly I'm probably wrong about it :I. Please help though.

Code: [Select]
local function lOnPlayerChat( ply )
if ply:IsUserRank == "storm" then
    table.insert( tab, Color( team.GetColor( lTeam ) ) )
    table.insert( tab, "[Storm] " )
end

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Prefix help
« Reply #1 on: July 07, 2012, 07:02:19 pm »
"IsUserRank" isn't a valid function or variable. I think you're looking for the function IsUserGroup. The use would look something like the following (untested):

Code: Lua
  1. local function lOnPlayerChat(...)
  2.   if ply:IsUserGroup("storm") then
  3.     ...
  4.   end
  5. end
  6.  

I didn't look it up, but I'm pretty sure you don't have all the arguments for the player chat callback, nor are you actually hooking it, nor is your usage of "table.insert" correct or even seemingly related to anything at all...

Sorry, don't meant to be too down on you, but please check the console output for errors when loading scripts.
Experiencing God's grace one day at a time.

Offline Assault_Trooper

  • Newbie
  • *
  • Posts: 20
  • Karma: 1
    • Trooper's Gaming Servers
Re: Prefix help
« Reply #2 on: July 08, 2012, 02:54:08 pm »
"IsUserRank" isn't a valid function or variable. I think you're looking for the function IsUserGroup. The use would look something like the following (untested):

Code: Lua
  1. local function lOnPlayerChat(...)
  2.   if ply:IsUserGroup("storm") then
  3.     ...
  4.   end
  5. end
  6.  

I didn't look it up, but I'm pretty sure you don't have all the arguments for the player chat callback, nor are you actually hooking it, nor is your usage of "table.insert" correct or even seemingly related to anything at all...

Sorry, don't meant to be too down on you, but please check the console output for errors when loading scripts.

I think he's trying to use PlayerSay and chat.AddText.

This might not be what you're wanting to do, but you should atleast get the idea.

Code: [Select]
hook.Add( "PlayerSay", "RankTags", function( ply, msg, public )

local lau = string.format( "chat.AddText( team.GetColor( %i ), '[%s] %s', Color( 255, 255, 255 ), %q )", ply:Team(), ply:GetUserGroup(), ply:Name(), msg )

for k,v in pairs( player.GetAll() ) do

v:SendLua( lau )

end

return

end )

  • Print