![]() |
#1 |
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.
|
![]() |
![]() |
![]() |
#2 |
Newb
|
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"}) |
![]() |
![]() |
![]() |
#3 |
Join Date: Sep 2007
Posts Rated Helpful 0 Times
|
i will mess with it tonight. thanks
|
![]() |
![]() |
![]() |
#4 | |
Join Date: Mar 2007
Posts Rated Helpful 0 Times
|
Quote:
|
|
![]() |
![]() |
![]() |
#5 |
Newb
|
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. |
![]() |
![]() |
![]() |
#6 |
Join Date: Mar 2007
Posts Rated Helpful 0 Times
|
i was thinking of using my code with steamid
![]() ![]() |
![]() |
![]() |
![]() |
#7 | |
Nutcracker
|
Quote:
|
|
![]() |
![]() |
![]() |
#8 |
Newb
|
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. |
![]() |
![]() |
![]() |
#9 |
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
![]() |
![]() |
![]() |
![]() |
#10 |
Newb
|
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
|
![]() |
![]() |
![]() |
#11 |
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 ..
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|