• Print

Author Topic: Need help, again.  (Read 11095 times)

0 Members and 1 Guest are viewing this topic.

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #15 on: July 30, 2016, 04:04:56 pm »
I'm not sure if fancyLogAdmin accepts color, but you could try something like this:

Code: Lua
  1. --- ROLE ---
  2. function ulx.role( calling_ply, target_ply )
  3.     if target_ply:GetRole() == ROLE_TRAITOR then
  4.         ulx.fancyLogAdmin( calling_ply, "#T is a ", Color( 200, 25, 25 ), "Traitor!", target_ply, true, true )
  5.     elseif target_ply:GetRole() == ROLE_INNOCENT then
  6.         ulx.fancyLogAdmin( {calling_ply}, "#T is an ", Color( 25, 200, 25 ), "Innocent!", target_ply, true, true )
  7.     elseif target_ply:GetRole() == ROLE_DETECTIVE then
  8.         ulx.fancyLogAdmin( {calling_ply}, "#T is a ", Color( 25, 25, 200 ), "Detective!", target_ply, true, true )
  9.     end
  10. end
  11. local role = ulx.command( "TTT Utility", "ulx role", ulx.role, "!role" )
  12. role:addParam{ type=ULib.cmds.PlayerArg }
  13. role:defaultAccess( ULib.ACCESS_SUPERADMIN )
  14. role:help( "Show's the role of the targeted player." )


Again, not sure if ulx.fancyLogAdmin supports color, but if it does that's how you would use it.


EDIT: If this doesn't work, you'd have to use ULib.tsayColor (I believe) which I don't know if it supports #T targetting.

The other code (without colour) works, i don't know if it's just because of me using it on myself but it says "You is an innocent!" which bugs me (grammarnazi). I will test the colour code and report back.

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #16 on: July 30, 2016, 04:36:02 pm »
It seems that fancyLogAdmin doesn't support colour. But the function itself does work. May I have some help with my ranks displaying function?

Code: Lua
  1. --- RANKS ---
  2. function ulx.ranks( calling_ply )
  3.                 ply:PrintMessage([[1 hour = Player
  4.                 5 hour = Member
  5.                 24 hour = Regular
  6.                 72 hour = Respected
  7.                 168 hour = Highly Respected
  8.                 336 hour = Expert]])
  9. end
  10. local ranks = ulx.command( "TTT Utility" , "ulx ranks", ulx.ranks, "!ranks" )
  11. ranks:defaultAccess( ULib.ACCESS_ALL )
  12. ranks:help( "Show all time-based ranks." )
  13.  

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Need help, again.
« Reply #17 on: July 30, 2016, 06:40:27 pm »
In the case of your ranks, if you have "calling_ply" as a variable, the game will not understand "ply" as it is not defined. Check the PrintMessage section on the Wiki to figure out how it works, as you don't have it right.

Try that, and get back to me if you need some more help :)
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #18 on: July 30, 2016, 06:43:42 pm »
I do not understand a thing.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Need help, again.
« Reply #19 on: July 30, 2016, 06:55:26 pm »
I do not understand a thing.
In lua, functions can be passed variables, that contain information.
In a ulx command, the first variable passed, no matter how you specify it in the first line of your function setup, happens to be the calling player, the person that executed the command.
Code: [Select]
function ulx.ranks( calling_ply )
                ply:PrintMessage
So, with your function setup, your passing the calling player to your function variable "calling_ply". That's fine, easy to see.
However, you're then trying to use "ply" in print message. That's not going to work. You're getting, or should be getting an error stating ply is null.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #20 on: July 30, 2016, 07:11:04 pm »
-snip

From what I saw in my server logs, i got nothing, before and after trying the command. So, how would I go about fixing it? I'm a noob.

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #21 on: July 30, 2016, 07:31:15 pm »
And going back to my other Awarn TK thing, how would I check if a traitor killed a traitor, but with a c4?

Code: Lua
  1. local TKreason = "TeamKill" --The reason
  2.  
  3. function tttTeamKill( victim, inflictor, attacker )
  4.  if attacker:IsUserGroup( "superadmin" ) then return end --exempt
  5.     if GAMEMODE.round_state == ROUND_ACTIVE then
  6.         if attacker:GetRole() == ROLE_INNOCENT then
  7.             if victim:GetRole() == ROLE_INNOCENT or victim:GetRole() == ROLE_DETECTIVE then
  8.                 awarn_warnplayer( nil, attacker, TKreason )
  9.             end
  10.         end
  11.     end
  12. end
  13. hook.Add( "PlayerDeath", "Warn On TK", tttTeamKill )
  14.  

I don't really know where to add what.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Need help, again.
« Reply #22 on: July 30, 2016, 07:39:20 pm »
Is that code working exactly right? I made it at about 2 in the morning so I'm not sure it's completely right.

local TKreason = "TeamKill" --The reason
Code: Lua
  1. function tttTeamKill( victim, inflictor, attacker )
  2.  if attacker:IsUserGroup( "superadmin" ) then return end --exempt
  3.     if GAMEMODE.round_state == ROUND_ACTIVE then
  4.         if attacker:GetRole() == ROLE_TRAITOR then
  5.             if victim:GetRole() == ROLE_TRAITOR then
  6.                 if inflictor:GetName() == "weapon_ttt_c4" then
  7.                     awarn_warnplayer( nil, attacker, TKreason )
  8.                 end
  9.             end
  10.         end
  11.     end
  12. end
  13. hook.Add( "PlayerDeath", "Warn On TK", tttTeamKill )

I believe that should work.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #23 on: July 30, 2016, 08:19:45 pm »
Is that code working exactly right? I made it at about 2 in the morning so I'm not sure it's completely right.
 -code

Yes, afaik it is working as intended.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Need help, again.
« Reply #24 on: July 31, 2016, 01:50:17 am »
From what I saw in my server logs, i got nothing, before and after trying the command. So, how would I go about fixing it? I'm a noob.

iViscosity and JamminR explained your exact problem, but just to spell it out even more:

Replace ply in
Code: Lua
  1. ply:PrintMessage
with calling_ply, so you end up with
Code: Lua
  1. calling_ply:PrintMessage
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline .gdraw

  • Newbie
  • *
  • Posts: 27
  • Karma: 1
    • Steam
Re: Need help, again.
« Reply #25 on: July 31, 2016, 10:43:57 am »
iViscosity and JamminR explained your exact problem, but just to spell it out even more:

Replace ply in
Code: Lua
  1. ply:PrintMessage
with calling_ply, so you end up with
Code: Lua
  1. calling_ply:PrintMessage

This was already solved, but thank you for your help.

  • Print