• Print

Author Topic: How can i add a admin message to the server when a ulx command is proformed?  (Read 7672 times)

0 Members and 1 Guest are viewing this topic.

Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
ok. with mani i have notice when you say, gimp someone, thin it says in grey writing "Admin gimped %player%, Everyone point and laugh at the gimp."

is there anyway which i can make ulx do this aswell, all i need is one example then i can go on and do it with other commands if it is possible.

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Open ulx_fun and find this:
Code: Lua
  1. function cc_ulxGimp( userid, args, argv, argc )
  2.         local target = getUser( userid, argv[ 1 ] )
  3.         if target == nil then
  4.                 return
  5.         end
  6.                
  7.         ulx_gimp( _PlayerInfo( target, "networkid" ) )
  8.  
  9.         ulx_log( "Admin " .. ulx_playerString( userid ) .. " gimped player " .. ulx_playerString( target ) )
  10.  
  11. end
replace with this:
Code: Lua
  1. function cc_ulxGimp( userid, args, argv, argc )
  2.         local target = getUser( userid, argv[ 1 ] )
  3.         if target == nil then
  4.                 return
  5.         end
  6.                
  7.         ulx_gimp( _PlayerInfo( target, "networkid" ) )
  8.  
  9.         ulx_log( "Admin " .. ulx_playerString( userid ) .. " gimped player " .. ulx_playerString( target ) )
  10.  
  11.         local gimpname = _PlayerInfo( target, "name" )
  12.         _PrintMessageAll(HUD_PRINTTALK, "Admin gimped "..gimpname..", Everyone point and laugh at the gimp."
  13. end


Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
thankyou so much :), if i manage to do that with all the commands, do you recon i could make a topic somewhere for other people to download, giving all the crdit to you?



#Edit: arf, something is wrong. i know a red wiggly line is bad.... when i laoded up my server and gimped myself nothing happened, and no text. i also did the thing with slay, it slayed me but no message....
« Last Edit: June 11, 2006, 11:48:36 am by Griff »

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
You can do what you like with it, what was the error it gave in console?


Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
error on line 259: ')' expected ( to close ')' at line 258) near END

not sure what thats sposed 2 mean

#Edit: fixed. but the message still doesnt show up. in blua the "HUD" command thing shows up with a yellow squiggly line...
« Last Edit: June 11, 2006, 02:06:17 pm by Griff »

Offline Golden-Death

  • Hero Member
  • *****
  • Posts: 751
  • Karma: 0
  • Honored Lua Scripter
    • BlueFire
Sorry, I forgot a parenthesis. I just tried and it works for me.

function cc_ulxGimp( userid, args, argv, argc )
   local target = getUser( userid, argv[ 1 ] )
   if target == nil then
      return
   end
      
   ulx_gimp( _PlayerInfo( target, "networkid" ) )

   ulx_log( "Admin " .. ulx_playerString( userid ) .. " gimped player " .. ulx_playerString( target ) )

   local gimpname = _PlayerInfo( target, "name" )
   _PrintMessageAll(HUD_PRINTTALK, "Admin gimped "..gimpname..", Everyone point and laugh at the gimp.")
end


Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
i pasted exactly that in and still nothing....

this is the whole of the ulx gimp code
Code: [Select]
gimps = {}
sayText = ""
gss = 1

function ulx_gimp( steamid )
gimps[steamid] = true
end

function ulx_ungimp( steamid )
gimps[steamid] = nil
end

function GimpSay()
gstr = table.getn(gimp_say)
gss = math.random( 1, gstr )
return gimp_say[gss];
end

function gimpCallback( userid, strText )
if isGimped( userid ) then
local player_name = _PlayerInfo( userid, "name" )
local sayText = GimpSay()
return player_name .. ": " .. sayText
else
return strText
end
end

function isGimped( userid )
local steamid = _PlayerInfo( userid, "networkid" )
if ( gimps[steamid] == true ) then
return true;
else
return false;
end
end

addMessageHook( gimpCallback )

-- Gimp Messages --
gimp_say = {}
table.insert( gimp_say, "Liek Oh, mai, GAWD!!! taht is soooo seks3!" )
table.insert( gimp_say, "ohh, ahhh, oohhh, ahhhhhh" )
table.insert( gimp_say, "I like to be a mingebag" )
table.insert( gimp_say, "" )

function cc_ulxGimp( userid, args, argv, argc )
   local target = getUser( userid, argv[ 1 ] )
   if target == nil then
      return
   end
     
   ulx_gimp( _PlayerInfo( target, "networkid" ) )

   ulx_log( "Admin " .. ulx_playerString( userid ) .. " gimped player " .. ulx_playerString( target ) )

   local gimpname = _PlayerInfo( target, "name" )
   _PrintMessageAll(HUD_PRINTTALK, "Admin gimped "..gimpname..", Everyone point and laugh at the gimp.")
end

ULX_CONCOMMAND( "ulx_gimp", cc_ulxGimp, ACCESS_SLAY, "<user> - gimps the specified player", 1, "gimp" )

function cc_ulxUngimp( userid, args, argv, argc )
local target = getUser( userid, argv[ 1 ] )
if target == nil then
return
end

ulx_ungimp( _PlayerInfo( target, "networkid" ) )
ulx_log( "Admin " .. ulx_playerString( userid ) .. " ungimped player " .. ulx_playerString( target ) )
end

ULX_CONCOMMAND( "ulx_ungimp", cc_ulxUngimp, ACCESS_SLAY, "<user> - ungimps the specified player", 1, "ungimp" )

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Why not just change ulx_log to print to the screen? All the admin commands use the log.
Experiencing God's grace one day at a time.

Offline Griff

  • Newbie
  • *
  • Posts: 40
  • Karma: 3
well, i dont have a clue how to do that..... the only lanhuage i know is a little vb...

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Step by step...
To try to keep things simple, restore your ulx_fun.lua to default either by the backup you made (you DID make one, right? :P), or by extracting from the downloaded ulx from this site.
1)Then, go into ulx_fun.lua.
2)Find function cc_ulxgimp section,
3) In that function, after where the LUA tests if target == nil,
Right after 'end' 2nd lines down (ending the if test)
3) on a 3rd line below that, place
_PrintMessageAll(HUD_PRINTTALK, "Admin gimped "..gimpname..", Everyone point and laugh at the gimp.")
there.


Do same for ulx_ungimp, but change the text in the _PrintMessageAll to more appropriate for what you wish to say.

Hope that helps a bit more, step by step.
If there is some other way any of us can help you understand, please say so. :)
« Last Edit: July 12, 2006, 12:36:03 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print