Fortress Forever

Go Back   Fortress Forever > Editing > Mapping

Reply
 
Thread Tools Display Modes
Old 10-10-2007, 02:39 PM   #1
public_slots_free
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
[LUA] I think a player states question

So, I want to have an area that a player can go into and once they leave that area, they cannot get back in. I am guessing it is player states but I don't really know how to do it (i did look at the damage example posted). Any help would be greatly appreciated.
public_slots_free is offline   Reply With Quote


Old 10-11-2007, 02:14 AM   #2
AltPluzF4
Newb
 
AltPluzF4's Avatar
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Send a message via ICQ to AltPluzF4 Send a message via AIM to AltPluzF4 Send a message via MSN to AltPluzF4 Send a message via Yahoo to AltPluzF4
Well, if you were to use a trigger_multiple and name it something, have that open a door on touch, and close on leave. Then, in lua, using the damage example I gave, have the trigger for the door check if the player has the proper state. Such as:
Code:
door_trigger = trigger_ff_script:new({})

function door_trigger:allowed(allowed_entity)
	local allowed = true
	if IsPlayer(allowed_entity) then
		local player = CastToPlayer(allowed_entity)
		for i in pairs(playerStateTable) do
			if playerStateTable[i][TPLAYER]:GetName() == player:GetName() then
				if playerStateTable[i][TSTATE] == self.blockstate then
					allowed = false
				break
			end
		end
	end
	return allowed
end

mydoor_trig = door_trigger:new({blockstate = "test1"})
Haven't tested that, but it should work. Assuming you actually have a reference to TSTATE that's being saved...
AltPluzF4 is offline   Reply With Quote


Old 10-11-2007, 09:35 PM   #3
public_slots_free
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
i will mess with it tonight. thanks
public_slots_free is offline   Reply With Quote


Old 10-12-2007, 10:42 AM   #4
stino
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
Quote:
Originally Posted by AltPluzF4
Well, if you were to use a trigger_multiple and name it something, have that open a door on touch, and close on leave. Then, in lua, using the damage example I gave, have the trigger for the door check if the player has the proper state. Such as:
Code:
door_trigger = trigger_ff_script:new({})

function door_trigger:allowed(allowed_entity)
	local allowed = true
	if IsPlayer(allowed_entity) then
		local player = CastToPlayer(allowed_entity)
		for i in pairs(playerStateTable) do
			if playerStateTable[i][TPLAYER]:GetName() == player:GetName() then
				if playerStateTable[i][TSTATE] == self.blockstate then
					allowed = false
				break
			end
		end
	end
	return allowed
end

mydoor_trig = door_trigger:new({blockstate = "test1"})
Haven't tested that, but it should work. Assuming you actually have a reference to TSTATE that's being saved...
why whould you use a for loop to go through the player table, just use player:GetId() for the i?
stino is offline   Reply With Quote


Old 10-12-2007, 09:48 PM   #5
AltPluzF4
Newb
 
AltPluzF4's Avatar
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Send a message via ICQ to AltPluzF4 Send a message via AIM to AltPluzF4 Send a message via MSN to AltPluzF4 Send a message via Yahoo to AltPluzF4
Because, I prefer to store players in order, that way you aren't limited by the ID. So, if they leave, you can save info for them until they return. (Have a timer, say 5 minutes? remove them if they aren't back.) This also stops players from getting someone else's progress if someone leaves and they join taking the player's ID.

Dunno, I just have a different way of using the table, that so far hasn't given me any problems at all.
AltPluzF4 is offline   Reply With Quote


Old 10-13-2007, 08:11 AM   #6
stino
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
i was thinking of using my code with steamid and store it in a file, but i have no idea if file I/O is available in ff's lua
stino is offline   Reply With Quote


Old 10-13-2007, 01:30 PM   #7
A1win
Nutcracker
 
A1win's Avatar
 
Join Date: Sep 2007
Location: Kuopio, Finland
Posts Rated Helpful 0 Times
Send a message via MSN to A1win
Quote:
Originally Posted by AltPluzF4
Because, I prefer to store players in order, that way you aren't limited by the ID. So, if they leave, you can save info for them until they return. (Have a timer, say 5 minutes? remove them if they aren't back.) This also stops players from getting someone else's progress if someone leaves and they join taking the player's ID.

Dunno, I just have a different way of using the table, that so far hasn't given me any problems at all.
Then you should compare their GetSteamID() instead of GetName() ?
A1win is offline   Reply With Quote


Old 10-13-2007, 09:42 PM   #8
AltPluzF4
Newb
 
AltPluzF4's Avatar
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Send a message via ICQ to AltPluzF4 Send a message via AIM to AltPluzF4 Send a message via MSN to AltPluzF4 Send a message via Yahoo to AltPluzF4
Well, I wrote that part before actually seeing the GetSteamID command, and previously tried GetSteamId, which failed due to the capitalized D. Either way, it's storing the player pointer, so when it checks name, that name will be exactly the same, since they are both pointers to the same player. I originally just compared if the player objects equaled, but that returned errors, and GetName was the first obvious thing since it was the exact same on both players. Also, GetSteamID was giving problems on LAN test, where two people had the same STEAM_ID_LAN

Anyway, once we are able to have a join and leave function for players, I'll probably rewrite the whole thing anyway.
AltPluzF4 is offline   Reply With Quote


Old 10-14-2007, 10:17 AM   #9
stino
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
yeah, your script has a little side effect, changing name will result in loosing the data
stino is offline   Reply With Quote


Old 10-14-2007, 10:47 AM   #10
AltPluzF4
Newb
 
AltPluzF4's Avatar
 
Join Date: Sep 2007
Posts Rated Helpful 0 Times
Send a message via ICQ to AltPluzF4 Send a message via AIM to AltPluzF4 Send a message via MSN to AltPluzF4 Send a message via Yahoo to AltPluzF4
I'm confused, what do you mean by that? "changing name will result in loosing the data" ? If you mean, the player changing their name, no that doesn't happen. Because when it checks the name, it's comparing the name of the player entity stored compared to the player entity being checked. If it's the same player, then the name is changed both places by the pointer. If you don't know what pointers are, then uh, not really sure how I can explain ;D
AltPluzF4 is offline   Reply With Quote


Old 10-14-2007, 02:48 PM   #11
stino
 
Join Date: Mar 2007
Posts Rated Helpful 0 Times
player:GetName how whould that get the name of the player if the name is not the nickname, wich a player can change if he wants ..
stino is offline   Reply With Quote


Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:33 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.