04-03-2009, 07:02 PM | #1 |
QUAD ROCKET
Server Owner
Fortress Forever Staff Join Date: Jul 2007
Class/Position: Soldier Gametype: Rocket Jumping Affiliations: -g1 ]qS[ -eC- :e0: [ESAD] Posts Rated Helpful 11 Times
|
Logging custom message on entity touch
Is there a way for me to log a custom message when a player touches an entity?
|
|
04-04-2009, 09:51 AM | #2 |
internet user
Fortress Forever Staff
Join Date: Jun 2007
Posts Rated Helpful 42 Times
|
Sure.. easiest and quickest way I can think of is
Code:
some_thing = info_ff_script:new( { -- your stuff here w/e blah touchflags = {AllowFlags.kOnlyPlayers,AllowFlags.kBlue, AllowFlags.kRed, AllowFlags.kYellow, AllowFlags.kGreen} }) function some_thing:touch( touch_ent ) if IsPlayer( touch_ent ) then ConsoleToAll("A player touched my info script!") end end
__________________
9:17 PM - DEXTER: can you teach me how to play o 9:17 PM - squeek.: you jump a lot 9:18 PM - squeek.: and do sweet moves 8:55 PM - FDA: fart in you fridge and blame it on wild animals |
|
04-04-2009, 10:17 AM | #3 | |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
I think he means server logs.
Plus, ConsoleToAll() only sends the message to the server's console. You're looking for LogLuaEvent() Quote:
Code:
LogLuaEvent(player:GetId(), 0, "flag_dropped", "flag_name", flag:GetName(), "player_origin", (string.format("%0.2f",player:GetOrigin().x) .. ", " .. string.format("%0.2f",player:GetOrigin().y) .. ", " .. string.format("%0.1f",player:GetOrigin().z) ));
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
|
04-04-2009, 11:11 AM | #4 |
internet user
Fortress Forever Staff
Join Date: Jun 2007
Posts Rated Helpful 42 Times
|
ohhh. I'm retarded. Very nice and easy
__________________
9:17 PM - DEXTER: can you teach me how to play o 9:17 PM - squeek.: you jump a lot 9:18 PM - squeek.: and do sweet moves 8:55 PM - FDA: fart in you fridge and blame it on wild animals |
|
04-04-2009, 05:51 PM | #5 | |
QUAD ROCKET
Server Owner
Fortress Forever Staff Join Date: Jul 2007
Class/Position: Soldier Gametype: Rocket Jumping Affiliations: -g1 ]qS[ -eC- :e0: [ESAD] Posts Rated Helpful 11 Times
|
Alright, thanks
Also, how does the LUA know what entity in the map to use? Quote:
|
|
|
04-05-2009, 01:49 AM | #6 |
D&A Member
Wiki Team Fortress Forever Staff Join Date: Apr 2007
Posts Rated Helpful 31 Times
|
It's a hook. The entity has to be in the map already so that players can interact with it. These are usuallyan info_ff_script or trigger_ff_script, but any named trigger can be used.
|
|
04-06-2009, 07:03 AM | #7 |
QUAD ROCKET
Server Owner
Fortress Forever Staff Join Date: Jul 2007
Class/Position: Soldier Gametype: Rocket Jumping Affiliations: -g1 ]qS[ -eC- :e0: [ESAD] Posts Rated Helpful 11 Times
|
I might be missing something but I'm still confused on how to specify which entity to hook
|
|
04-06-2009, 07:33 AM | #8 | |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Quote:
Code:
some_thing = info_ff_script:new({}) EDIT: What exactly are you trying to do?
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
|
04-06-2009, 06:23 PM | #9 |
QUAD ROCKET
Server Owner
Fortress Forever Staff Join Date: Jul 2007
Class/Position: Soldier Gametype: Rocket Jumping Affiliations: -g1 ]qS[ -eC- :e0: [ESAD] Posts Rated Helpful 11 Times
|
I was thinking 'some_thing' was a variable but I guess that really doesn't make sense when I look at the prototype :S
I'm making a speed run plugin for skill maps and need to detect when a player touches the start/end timers. Currently SourceMod can't hook touches for FF so I decided to use a hackish method and use LUA to log when a player touches the entity so I can hook the log in SourceMod (I'll eventually need to figure out how to add a delay between client touches so it doesn't spam the log too.) Last edited by hlstriker; 04-06-2009 at 06:50 PM. |
|
04-09-2009, 07:18 AM | #10 |
QUAD ROCKET
Server Owner
Fortress Forever Staff Join Date: Jul 2007
Class/Position: Soldier Gametype: Rocket Jumping Affiliations: -g1 ]qS[ -eC- :e0: [ESAD] Posts Rated Helpful 11 Times
|
I got the entity touches working but now I'm having problems trying to create a delay between each touch.
You can see I'm just trying to use a simple bool array... - When player spawns set players array index to true. - When player touches ent, set array index to false, and AddSchedule. - AddSchedules function resets players array index to true. How can I do this? Code:
----------------------------------------------------------------------------- -- Delay for touching the timer so it doesn't constantly spam the player ----------------------------------------------------------------------------- local bCanTouchTimer[] -- How do I make an array? function sr_delay_reset(player) bCanTouchTimer[player] = true end function player_spawn(player) bCanTouchTimer[player] = true end ----------------------------------------------------------------------------- -- Start Timer ----------------------------------------------------------------------------- sr_start_timer = info_ff_script:new({ model = "models/items/ball/ball.mdl", touchflags = {AllowFlags.kOnlyPlayers, AllowFlags.kBlue, AllowFlags.kRed, AllowFlags.kYellow, AllowFlags.kGreen} }) function sr_start_timer:precache( ) PrecacheModel(self.model) end function sr_start_timer:touch(touch_entity) if IsPlayer(touch_entity) then local player = CastToPlayer(touch_entity) -- Check the delay if bCanTouchTimer[player] then RemoveHudItem(player, "touched_start") AddSchedule("sr_touch_delay", 2, sr_delay_reset, player) bCanTouchTimer[player] = false end end end |
|
04-09-2009, 07:28 AM | #11 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Try using player:GetId() for the index of the array.
And you make an array using: Code:
local bCanTouchTimer = {}
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington |
|
04-09-2009, 08:08 PM | #12 |
QUAD ROCKET
Server Owner
Fortress Forever Staff Join Date: Jul 2007
Class/Position: Soldier Gametype: Rocket Jumping Affiliations: -g1 ]qS[ -eC- :e0: [ESAD] Posts Rated Helpful 11 Times
|
Thanks it's working perfect now
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|