Jump to content

Join Handler


CapY

Recommended Posts

Posted
function spaw(player) 
spawnPlayer(player, x , y  ,z , 0 , skin id ) 
end 
addEventHandler("onPlayerJoin",root,spaw) 

next time make it yourself use wiki ..

Posted

Well, with bandi's code the player will spawn, but you will still see a black screen.

And next time, use the wiki and the search in it.

For spawning a player you must use 3 functions:

fadeCamera -- fades the player's camera to a color or back to normal 
setCameraTarget -- used to make the camera follows the player (or follows another player 'spectate') 
spawnPlayer -- spawns the player 

Example:

addEventHandler("onPlayerJoin", root, 
function() 
local x = -1942 
local y = 537 
local z = 277 
spawnPlayer(source, x, y, z) 
fadeCamera(source, true) 
setCameraTarget(source, source) 
end) 

You can change the x, y, z.

Good luck.

Posted
It's working nice, but when i die it's respawns me at default place....

Respawns you, how?

It shouldn't respawn you at all, unless you made a script for it, with "onPlayerWasted".

Posted

we use "onPlayerJoin" and when somebody get killed then you get respawn whit the normal play script respawn you need to add

"onPlayerWasted" and "onPlayerJoin"

Posted

Are you using the freeroam resource or the play resource?

Those already have scripts for spawning and when somebody dies, they spawn in the same place in LV.

Posted
Are you using the freeroam resource or the play resource?

Those already have scripts for spawning and when somebody dies, they spawn in the same place in LV.

None of them ...i named resource "Join handler"

Posted

This works good.

addEventHandler("onResourceStart", resourceRoot, 
    function() 
        resetMapInfo() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
    if not isElement(player) then return end 
    repeat until spawnPlayer ( player, -711+math.random(1,5), 957+math.random(5,9), 12.4, 90, math.random(9,288), 0, 0) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    showChat(player, true) 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
    local x = -1942 
    local y = 537 
    local z = 277 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
    local x = -1942 
    local y = 537 
    local z = 277 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    setTimer(spawn, 1000, 1, source) 
    end 
) 

On join i spawn there and when i die i respawn there , but when i die i respawn there for 1 second and then it backs me to the default spawn...

What i did wrong ?

Posted

That's because you are using a timer to call "spawn" which will spawn the player back at the default position.

here:

addEventHandler("onPlayerWasted", root, 
    function() 
    local x = -1942 
    local y = 537 
    local z = 277 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    end 
) 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...