What exactly do you mean by "a respawn"?
If you mean you want to respawn a character somewhere else on death, then yes that can be achieved via an LUA script.
You will need to create a file called random_player_spawn_location.lua containing the following code and place it in your gameguru/files/scriptbank folder:
local dead = 0
--sets minimum and maximum values to be randomed in x,y,z of world (game world is currently 0 x 50000 with a starting y of 600)
local x1 = 1000
local x2 = 49000
local y1 = 800
local y2 = 1000
local z1 = 1000
local z2 = 49000
--set object always active = yes
--copy name of object into the 'ifused' field
function random_player_spawn_location_init(e)
CollisionOff(e)
Hide(e)
end
function random_player_spawn_location_main(e)
Hide(e)
--Prompt(g_PlayerPosX.." "..g_PlayerPosZ)
if g_PlayerHealth > 0 then
if dead == 0 then
CollisionOff(e)
SetPosition(e,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
else
TransportToIfUsed(e)
dead = 0
end
else
CollisionOff(e)
local x = math.random(x1,x2)
local y = math.random(y1,y2)
local z = math.random(z1,z2)
SetPosition(e,x,y,z)
CollisionOn(e)
dead = 1
PromptDuration(x.." "..y.." "..z,2500)
end
end
function random_player_spawn_location_exit(e)
end
Place an object (this is a dummy object to use as a location to teleport to so it can be anything), click on it in and select properties, in the menu on the left find "set always active" ad change it to "yes", then find the field with the objects name in (should be the first one) and copy/paste that name into the "ifused" field, then find the script field and change the script to the one you just made, finally click the aknowledge changes button.
Your character will now respawn at a random location on the map when it dies.
If you don't want it to be random you can use the following code instead, this will spawn you next to the object you created above.
local dead = 0
--sets minimum and maximum values to be randomed in x,y,z of world (game world is currently 0 x 50000 with a starting y of 600)
local x1 = 1000
local x2 = 49000
local y1 = 800
local y2 = 1000
local z1 = 1000
local z2 = 49000
--set object always active = yes
--copy name of object into the 'ifused' field
function random_player_spawn_location_init(e)
CollisionOff(e)
Hide(e)
end
function random_player_spawn_location_main(e)
Hide(e)
--Prompt(g_PlayerPosX.." "..g_PlayerPosZ)
if g_PlayerHealth > 0 then
if dead == 0 then
CollisionOff(e)
SetPosition(e,g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
else
TransportToIfUsed(e)
dead = 0
end
else
CollisionOff(e)
local x = math.random(x1,x2)
local y = math.random(y1,y2)
local z = math.random(z1,z2)
CollisionOn(e)
dead = 1
PromptDuration(x.." "..y.." "..z,2500)
end
if GetScancode() == 18 then
HurtPlayer(e,g_PlayerHealth) --remove this code to stop e key from killing the player
end
end
function random_player_spawn_location_exit(e)
end
All credit for this script goes to one of our scripting gods smallg who posted it in a similar thread recently ( https://forum.game-guru.com/thread/213947#msg2534821 )