Jump to content

Spawn


Drakath

Recommended Posts

Posted

Why doesn't this script spawn people in the place where it should?

Note: It should spawn people after death.

Script:

-- XYZ coördinates 
    local spawnX = 213.81648254395 
    local spawnY = 1870.0822753906 
    local spawnZ = 13.140625 
  
  
  
function spawnOnJoin() 
    spawnPlayer(source, 213.81648254395, 1870.0822753906, 13.140625, 0 , 285) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    giveWeapon(source, joinWeapon, joinAmmo) 
end 
  
  
function spawnOnDead(ammo, killer, weapon, bodypart) 
    end 
    setTimer(spawnPlayer, 3000, 1, source, 213.81648254395, 1870.0822753906, 13.140625, 0, 285) 
    setCameraTarget(source, source) 
end 
  
  
addEventHandler("onPlayerJoin", getRootElement(), spawnOnJoin) 
addEventHandler("onPlayerWasted", getRootElement(), spawnOnDead) 

Posted
function spawnOnDead(ammo, killer, weapon, bodypart) 
    end 
    setTimer(spawnPlayer, 3000, 1, source, 213.81648254395, 1870.0822753906, 13.140625, 0, 285) 
    setCameraTarget(source, source) 
end 

2 ends?

Posted

Thanks, I did not noticed it. Is there anything else wrong here because I'm getting crashes and is there anyway to make it don't spawn any skin?

Posted

Yes there is a way to change the skn

look at the syntax

spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil ] ) 
  

your'e using skin 285

edit:

this is a better way:

  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for i,player in ipairs(getElementsByType("player")) do 
            spawn(player) 
        end 
    end 
) 
  
function spawn(player) 
        spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , 285) 
    fadeCamera(player, true) 
    setCameraTarget(player, player) 
    giveWeapon(player, joinWeapon, joinAmmo) 
  
-- btw what is joinweapon and joinammo? 
end 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawn(source) 
    end 
) 
  
addEventHandler("onPlayerWasted", root, 
    function() 
        setTimer(spawn, 3000, 1, source) 
    end 
) 
  

Posted

I'm asking if there is way to don't spawn the skin not to change. And your script doesn't work every player spawned at one place and lost all weapons...

Posted

Use this to get the old skin:

getElementModel 

Use this to prevent spawn in same place:

math.random 

Make a script to save the weapon and retrieve it when you need.

Posted
Where do I put: getElementModel ? And why is my server crashing?

change this

spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , 285) 

to

spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , getElementModel(player)) 

Posted

Now everyone spawn as CJ.

Script:

local spawnX = 213.81648254395 
    local spawnY = 1870.0822753906 
    local spawnZ = 13.140625 
  
  
function spawnOnJoin() 
    spawnPlayer(player, 213.81648254395, 1870.0822753906, 13.140625, 0 , getElementModel(player)) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    giveWeapon(source, joinWeapon, joinAmmo) 
end 
  
  
function spawnOnDead(ammo, killer, weapon, bodypart) 
    setTimer(spawnPlayer, 3000, 1, source, 213.81648254395, 1870.0822753906, 13.140625, 0, getElementModel(player)) 
    setCameraTarget(source, source) 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), spawnOnJoin) 
addEventHandler("onPlayerWasted", getRootElement(), spawnOnDead) 

Posted
Worked, but why does this script makes players crash when reconnecting?

i think you need to use a timer with event onPlayerJoin for spawnPlayer.

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...