GoldenEye: Source Forums

Debriefing => Questions, Help, & How To's => Topic started by: Doc.NO on March 13, 2009, 12:54:46 pm

Title: LUA coding question
Post by: Doc.NO on March 13, 2009, 12:54:46 pm
I have a map sending a server command on some events, using point_server_command. Wondering if there's a way to use that server command in a LUA coded gameplay? After checking the CB list, my hopes are low, but still wanted to ask.
Title: Re: LUA coding question
Post by: Mark [lodle] on March 13, 2009, 01:46:33 pm
hmmm, the ony way i think you can hax it is make a cvar and check its value in the onthink function
Title: Re: LUA coding question
Post by: Doc.NO on March 15, 2009, 12:42:21 pm
thanks. I think the cvar trick will do it.
Title: Re: LUA coding question
Post by: Doc.NO on March 17, 2009, 07:59:27 pm
Well I did it, and works great. If someone is interested, I used a trigger with a point_servercommand entity on the map

(http://img27.imageshack.us/img27/4964/dayt.jpg)
(bb_command is the point_servercommand)

And then, in the think() LUA CB:

Code: [Select]
	if(GetCVar("bb_mi6_score") == "1" and (GetTime() >= g_mi6_timer)) then
g_mi6_timer = GetTime() + 2;
-- any command you'd like goes here:
AddToTeamScore(TEAM_MI6,1);
elseif(GetCVar("bb_mi6_score") == "0") then
g_mi6_timer = 0;
end

I'm sure there is a better way to code that, but actually it works, and its all I want :P The only downside of this is the chat area spam on CVAR change.
Title: Re: LUA coding question
Post by: Mark [lodle] on March 17, 2009, 09:35:17 pm
Ill add a flag to create cvar which will remove the spam on change but its good to see you got it working.
Title: Re: LUA coding question
Post by: killermonkey on March 18, 2009, 02:02:53 pm
You can capture the chat spam with the OnPlayerSay(..) Lua function and use LUA to regexp the chat to find the string that is for changing a CVar and just deny the printing... PHEW
Title: Re: LUA coding question
Post by: Mark [lodle] on March 18, 2009, 02:44:24 pm
you high again monkey?