Jump to content

Custom commands and killing spree displays


Geo

Recommended Posts

I am learning the basics of the silent mod and I have encountered a couple of problems. I would like to create a custom command called !spec - which would work in the same way as the !spec command on jaymod. This is a feature that has been requested and I think it is quicker than finding the slot number and using /follow. However, i can't seem to get this command to work. I have no idea if i am right but i tried this:

 

[command]

command = spec

exec = follow (name|slot#)

desc = spectates the player

syntax =

levels = 3 4 5

 

I doubt that 'follow' function or the 'name/slot' part is correct and this is where i'd like some assistance. What do i need to exec in order to spectate a player, if it's possible of course. Other random custom cmds have been fine so far.

 

Also, is there a way to incorporate say the jaymod style killing sprees (or something similiar). The (animation?) green-coloured killing spree was quite a nice feature which players seem to want on the server too, but i don't know what format the sprees are in but in particular whether i can edit the killing spree display. Here's a picture of what I mean: http://i70.servimg.com/u/f70/15/00/85/90/94489211.jpg  It's default currently, just displaying the msgs in the console.

 

Forgot to add - could this be possible using lua?

 

Thanks.

Edited by Arcane
Link to comment
Share on other sites

  • Management

The !spec command is not possible through regular commands that the server can execute. I'm not sure if editing the sess.spectatorClient with http://mygamingtalk.com/wiki/index.php/Silent_Lua#gentity_set will work. You can try but there are risks when editing these fields so proper testing should be done before adding the script to your public server. Also, the sess.spectatorState must be set to the value 2 at the same time.

 

The second question, it is partly possible with Lua. In Jaymod, the announcements are announced to all the players, which is different form silEnT announcements. However, the animation is not possible. Only options are the usual chat line, popup, center print and the top of the screen.

Link to comment
Share on other sites

I'm not sure if editing the sess.spectatorClient with http://mygamingtalk.com/wiki/index.php/Silent_Lua#gentity_set will work. You can try but there are risks when editing these fields so proper testing should be done before adding the script to your public server. Also, the sess.spectatorState must be set to the value 2 at the same time.

 

Do you think you could explain a little bit more about sess.spectatorClient? I checked its function using the Lua wiki page but i'm still unsure of how I can edit this using gentity_set. I do understand that the value of sess.spectatorState has to be set to 2 but how does this coincide with the spectatorClient. Thanks

Link to comment
Share on other sites

  • Management

You must move the player in the specator team (!putteam should work fine), then using Lua to set sess.spectatorClient to be the slot number of the player he wants to spec. In the same function, the sess.spectatorState must be set to the value 2. I don't know if it will work.

 

You can ignore (pass any value you want) the last parameter in the gentity_set function as both of the edited values are integers. The new value is passed in the arrayindex.

Link to comment
Share on other sites

  • 4 weeks later...

Sorry to revive this but didn't see any point in creating a new topic. I have created a spec.lua that is a little rough around the edges currently but it is unfinished. It works fine but there are a couple of issues I would like help with.

Firstly, here is the code:

 

function et_ClientCommand(clientNum, command)
   if et.trap_Argv(0) == "spec" then
      if et.trap_Argc() == 2 then
         local targetClientNum = et.ClientNumberFromString(et.trap_Argv(1))
                         et.trap_SendConsoleCommand( et.EXEC_APPEND, "putteam" ..clientNum.. "s")
           et.gentity_set(clientNum, "sess.spectatorState", 2)   
                         et.gentity_set(clientNum, "sess.spectatorClient", targetClientNum)
                           
                else
         et.trap_SendServerCommand(clientNum, "print \"Error: Need two parameters!\"")
      end
      return 1
   end
   return 0
end
 

 

Line 5, Console command does not seem to be working. When I am a spectator I can spec anyone using name/slot, but when I join I team I can't spec anybody at all. I am not put into spec and it does nothing - where have I gone wrong in putting MYSELF (clientNum?) into spec. The following fields (spectatorState and spectatorClient) work fine from here.

 

The other issue is that the script does not return values for non-existent client numbers/names (11 slots listed eg, /spec 12 - this will spec the first available slot of the players on r/b). I was hoping to solve this by using the shortcut [1?] when I attempt to convert this to a custom command (!spec). Would this be sufficient or can I do this in the lua, if so, how?

 

Finally, I still do not understand how to get the spec.lua to run by executing a custom command. For example:

 

[command]

command = example

exec = ???? Can someone give an EXAMPLE of what I need to put here to run spec.lua - is it "lua spec [1?]" ?

desc = blablala

syntax =

levels = 5

 

Thanks.

Link to comment
Share on other sites

  • Management

In shrubbot.cfg

 

[command]
command  = spec
exec     = putteam [i] s; specplayer [i] "[1?]"
desc     = spec any player
syntax   = [name]
levels   = 0 1 2 3 4 5

 

In Lua:

function et_ConsoleCommand(command)
	if et.trap_Argv(0) == "specplayer" then
		if et.trap_Argc() == 3 then
			local clientNum = et.trap_Argv(1)
			local targetClientNum = et.ClientNumberFromString(et.trap_Argv(2))

			et.gentity_set(clientNum, "sess.spectatorState", 2)
			et.gentity_set(clientNum, "sess.spectatorClient", targetClientNum)
		end

		return 1
	end
	return 0
end

 

Notice that the Lua hook is now ConsoleCommand and not ClientCommand.

Link to comment
Share on other sites

I've made an updated version of this using the help you provided, also added in a couple of extra features. Would like to share the spec.lua with others but I don't know where to upload the file, for some reason couldn't upload the lua file on that downloads page

Link to comment
Share on other sites

  • Management

I've made an updated version of this using the help you provided, also added in a couple of extra features. Would like to share the spec.lua with others but I don't know where to upload the file, for some reason couldn't upload the lua file on that downloads page

 

Can you zip the file and upload it? 

 

Thanks

Link to comment
Share on other sites

Can you zip the file and upload it?

 

Thanks

 

It worked as a .zip file, thanks :) I tested it on 2 servers yesterday and it worked flawlessly, but you may want to test it first just in case.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...