There is also a script attached to a triggerzone.
made By cybernescence.
-- Blocks player from entering the area covered by the trigger zone this script is attached to
-- Attach script to a trigger zone and extend the zone to the full area to be blocked to the player
-- Also needs an entity to be added to the map with its known entity number set in script below (also set entity to not spawn at start)
-----------------------------------------------------------------
-- IMPORTANT: The entity must have its 'IfUsed' properties field set to exactly the same as its 'Name' field
-- AND 'Spawn At Start' property must be set to 'No'
-----------------------------------------------------------------
-- Tested with the 'Gates' entity
-- By cybernescence. Free to use for any purpose.
local blocking_entity_e = 19 -- set to the entity you are using to block the player (this is displayed on status bar once entity placed), also set this entity to not spawn at start
local blocking_message = "You can't go on this way!" -- change to whatever message you'd like to display when player is blocked
local i_state = {}
local itemdist = -50
local initialY = {}
local initialX = {}
local initialZ = {}
function blockingzoneout_init(e)
i_state[e] = "check"
end
function blockingzoneout_main(e)
if g_Entity[e]['plrinzone'] == 1 then
if i_state[e] == "check" then
if g_Entity[blocking_entity_e] == nil then
Prompt("Error - this entity does not exist - check documentation in blocking_zone script!")
return
end
Hide(blocking_entity_e)
i_state[e] = "start"
end
if i_state[e] == "start" then
initialY[e] = g_PlayerPosY
initialX[e] = g_PlayerPosX
initialZ[e] = g_PlayerPosZ
i_state[e] = "block"
return
end
if i_state[e] == "block" then
PromptDuration(blocking_message, 3000)
GravityOff(blocking_entity_e)
CollisionOff(blocking_entity_e)
itemx=initialX[e]
itemz=initialZ[e]
itemy=initialY[e]
itemx = itemx+math.sin(math.rad(g_PlayerAngY))*itemdist
itemz = itemz+math.cos(math.rad(g_PlayerAngY))*itemdist
SetPosition(blocking_entity_e,itemx,itemy,itemz)
SetRotation(blocking_entity_e,0,g_PlayerAngY,0)
TransportToIfUsed(blocking_entity_e)
end
else
initialY[e] = g_PlayerPosY
initialX[e] = g_PlayerPosX
initialZ[e] = g_PlayerPosZ
i_state[e] = "start"
end
end
Harry
Harry
When nothing goes right, go left