Config a private msg for people comming in


(ThaMasta) #1

Hi, I want to know how to create a config that will sent a message privately to the person who would connect to my server.

You know a website where I could find interesting to add more config to my server?

Thank you!

ThaMasta :cool:


(Darkix) #2

What mod are you running?


(ThaMasta) #3

2.60b nq 1.2.7


(valkyr) #4

It should be pretty easy to do with LUA - something along the lines of :


function [et_ClientBegin()](http://wolfwiki.anime.net/index.php/ETPro:Lua_Mod_API#client_management)
	et.trap_SendServerCommand( -1, "m \"Welcome to server\"" )
end


(crapshoot) #5

et_ClientConnect is another option for LUA. the ability to know if it is a first time connection may be useful here.


(ThaMasta) #6

I am not clever at all with the Lua thing, in fact I have never work with lua …

Where i should put this command?

the same time, someone could tell me how to do a rotation of 20 maps please? Or tell me where I can find a tutorial? I dont want to open 30 post for all of my question loll !!

Thanks

ThaMasta


(valkyr) #7

Here’s a 10 map objective cycle example config

It does the following

[ul]
[li]Cycles through 10 maps (adding more just means looking at the ā€œd01ā€ ā€œd02ā€ variables and increasing them accordingly)
[/li][li]Sets a ā€˜.Nextmap’ CVAR which can be seen in server browsers
[/li][li]Shows a ā€œnext mapā€ banner on every map
[/li][li]Sets the hostname (the name of the server) and MOTD - the info that shows up in the bottom right box when connecting to the server / changing maps
[/li][/ul]

The banner CVAR is probably different for NQ, so if you want the banners you’ll need to change b_banner to whatever NQ uses.

To run the cycle you’d do :


exec cycle_RTCW_objective

from e.g., your server.cfg.


(valkyr) #8

[QUOTE=ThaMasta;227506]I am not clever at all with the Lua thing, in fact I have never work with lua …

Where i should put this command?[/QUOTE]

OK, this should work :


--Called when a client enters the game
function et_ClientBegin(clientNum)
	--Get client's name
	pers_netname = et.gentity_get(clientNum, "pers.netname")
	--Greeting
	greeting = "\"HELLO\""
	--Console command
	conCommand = "msg " .. pers_netname .. greeting
	--Send command
	et.trap_SendConsoleCommand(et.EXEC_NOW, conCommand)
end

Change HELLO to whatever you want the message to be.

Put that in a file called ā€œprivate-greeting.luaā€ (for example) then add it to the list of LUA modules to be loaded in your NQ config.


(ThaMasta) #9

this is exactly what i have now and why i want to change for maprotation… but normaly we cant have more than 10 map in maprotation i think… i want to make a 20 rotation map , but in maprotation

i want maprotation, not objectivecycle… i want to see all Button + map name in the ā€œcamp_map.tgaā€ you know what i mean ? and see the list of map rotation in the camp_side.tga

sorry for my bad english lol

Ohhh cool thanks Valkyr !!!


(valkyr) #10

Ah right. So you need 2 x 10 map campaigns.

There’s plenty of threads about making campaigns, like this one : http://www.splashdamage.com/forums/showthread.php?t=18833

Basically you need :

[ul]
[li]A campaign cycle cfg. (4 campaign example).
[/li][li].campaign file(s) with the campaign definitions (example) (these go in the /scripts folder of a PK3 file)
[/li][/ul]


(hellreturn) #11

[QUOTE=valkyr;227523]OK, this should work :
[/QUOTE]

Can you expand your LUA if possible so that it PM’s user who are connecting from 2.55 ?


(valkyr) #12

Alright…

That just means checking the cg_etVersion key value in the userinfo string for ā€œ2.55ā€ before sending the message…


--Called when a client enters the game
function et_ClientBegin(clientNum)
	--Get client's name
	pers_netname = et.gentity_get(clientNum, "pers.netname")
[B]	--Get client's game version
	userinfo = et.trap_GetUserinfo(clientNum)
	etVersionValue = et.Info_ValueForKey(userinfo, "cg_etVersion")[/B]
	--Greeting
	greeting = "\"HELLO\""
	--Console command
	conCommand = "msg " .. pers_netname .. greeting
	--Send command if version matches
[B]	if string.find(etVersionValue, "2.55") ~= nil
		then[/B] et.trap_SendConsoleCommand(et.EXEC_NOW, conCommand)
	end
end


(valkyr) #13

I couldn’t get that to work for some reason…

The only downside of et_ClientBegin is that it happens at the end of warm-up and also on shuffles too I think.


(crapshoot) #14

hmm, wonder if it’s different in ETPro. this quick test works for me in the current NQ (1.2.8 beta)

function et_ClientConnect( clientNum, firstTime, isBot )
	-- welcome them on initial connection
	if firstTime == 1 then
		et.trap_SendServerCommand(clientNum, "cpm \"" .. "Welcome to the server" )
	end

	return nil
end

(valkyr) #15

Ah right… et.trap_SendConsoleCommand doesn’t seem to work at all in the et_ClientConnect callback function. Maybe it gets sent before the client can receive it and gets lost or something, I dunno. Anyway, et.trap_SendServerCommand does work, but doesn’t let you send private messages, so some other type of message has to be used.

So here’s an updated version of the original script :


--Configuration :

--Where to print the message to
printCommand = "b 8"
--Greeting
greeting = "HELLO"

--Called when a client enters the game
function et_ClientConnect(clientNum, firstTime, isBot)
	--Construct command
	conCommand = printCommand .. " " .. "\"" .. greeting .. "\""
	--Send command if first time
	if firstTime == 1
		then et.trap_SendServerCommand(clientNum, conCommand)
	end
end

…and with the 2.55 version check :


--Configuration :

--Where to print the message to
printCommand = "b 8 "
--Greeting
greeting = "HELLO"

--Called when a client enters the game
function et_ClientConnect(clientNum, firstTime, isBot)
	--Get client's name
	pers_netname = et.gentity_get(clientNum, "pers.netname")
	--Get client's game protocol
	userinfo = et.trap_GetUserinfo(clientNum)
	protocolValue = et.Info_ValueForKey(userinfo, "protocol")
	--Construct command
	conCommand = printCommand .. " " .. pers_netname .. "\"" .. greeting .. "\""
	--Send command if protocol matches 82 (2.55) and is first time
	if string.find(protocolValue, "82") ~= nil and firstTime == 1
		then et.trap_SendServerCommand(clientNum, conCommand)
	end
end

The type of message can be customised by changing :


printCommand = "b 8"

To one of the printing types.


(valkyr) #16

Version can’t actually be checked for on et.ClientConnect, since cg_etVersion isn’t present in the userinfo string until ClientBegin, so now it checks for protocol 82 (which is version 2.55)


(UJERebel) #17

[QUOTE=crapshoot;227739]hmm, wonder if it’s different in ETPro. this quick test works for me in the current NQ (1.2.8 beta)

function et_ClientConnect( clientNum, firstTime, isBot )
	-- welcome them on initial connection
	if firstTime == 1 then
		et.trap_SendServerCommand(clientNum, "cpm \"" .. "Welcome to the server" )
	end

	return nil
end

[/QUOTE]

Nice one =)

But when i looked at the code, i saw that you get ā€˜IsBot’ as a argument to…
Wouldn’t it be usefull if you didn’t send this messages to bots to? or will the check be more demanding then sending the message… ?


(crapshoot) #18

for NQ, it’s a bit more challenging than that as niether cg_etVersion or protocol appear in the userinfo string. i don’t think NQ allows older versions to connect anyway, so it’s probably not necessary.

yeah, good point. updated:

function et_ClientConnect( clientNum, firstTime, isBot )
	if firstTime == 0 or isBot == 1
		then return nil
	end

	et.trap_SendServerCommand(clientNum, "cpm \"" .. "Welcome to the server " .. et.Info_ValueForKey( et.trap_GetUserinfo( clientNum ), "name" ))

	return nil
end

(IRATA) #19

et_ClientConnect isn’t an optimal solution solution in my eyes. On many first connects the player has to dowload maps or custom pk3s. I’m not sure if cpm is displayed if the client triggers a download …


(crapshoot) #20

uhh, the only other option that i can see is client begin and unless you’re going to store some external vars for tracking whether or not a client has been welcomed or not, its going to send it every time a level loads or team is switched. it’s a welcome message, i can’t see anything ā€œoptimalā€ about creating some overly complicated script to deliver it. use server_motd# vars if you want to guarantee some text for the client when they connect.

p.s. DIE! :slight_smile: