Server functions
These hooks are in the unlocked file bridge/functions/server.lua. Put your own code inside them. They run after the script has updated the player's safezone state.
The zone argument contains id, name, settings and polyzone.
Server Functions
1. OnPlayerEnterZone(playerId, zone)
Runs on the server when a player enters a safezone.
Source file:
bridge/functions/server.lua
Arguments:
playerId- server ID of the playerzone- table containing the current safezone data
Example:
lua
function FSBridge.Functions.OnPlayerEnterZone(playerId, zone)
print(('Player %s entered safezone %s'):format(playerId, zone and zone.name or 'unknown'))
end2. OnPlayerLeaveZone(playerId, zone)
Runs on the server when a player leaves a safezone.
Source file:
bridge/functions/server.lua
Arguments:
playerId- server ID of the playerzone- table containing the last safezone data
Example:
lua
function FSBridge.Functions.OnPlayerLeaveZone(playerId, zone)
print(('Player %s left safezone %s'):format(playerId, zone and zone.name or 'unknown'))
end3. PlayerInsideZone(playerId, zone)
Runs on the server about once per second while a player remains inside a safezone. Keep it light.
Source file:
bridge/functions/server.lua
Arguments:
playerId- server ID of the playerzone- table containing the current safezone data
Example:
lua
function FSBridge.Functions.PlayerInsideZone(playerId, zone)
if zone and zone.id then
print(('Player %s is inside safezone #%s'):format(playerId, zone.id))
end
endServer Events
4. Server Events
Safezone Creator triggers these server events. Each one also fires under the old fs_safezonecreator: prefix, so older scripts keep working.
| Event | When |
|---|---|
fwb_safezonecreator:server:onEnterZone | A player enters a zone |
fwb_safezonecreator:server:onExitZone | A player leaves a zone |
fwb_safezonecreator:server:insideZone | About once per second while a player is inside a zone |
Example:
lua
AddEventHandler('fwb_safezonecreator:server:onEnterZone', function(playerId, zone)
print(('Player %s entered safezone %s'):format(playerId, zone and zone.name or 'unknown'))
end)
AddEventHandler('fwb_safezonecreator:server:onExitZone', function(playerId, zone)
print(('Player %s left safezone %s'):format(playerId, zone and zone.name or 'unknown'))
end)
AddEventHandler('fwb_safezonecreator:server:insideZone', function(playerId, zone)
if zone and zone.id then
print(('Player %s is inside safezone #%s'):format(playerId, zone.id))
end
end)