Jump to content

Spawning


hihohihohiho

Recommended Posts

Theres alot of players coming into my server and i need like 5 different spawning points because after 1 kills 1 he spawns at the same spot and gets killed, then leaves because they cant even play.If someone could tell me where i can edit that, like which file or scripts to edit that would be great

thanks...

Link to comment

Put it where you put your normal player spawn - you must have this to be playing on your server. You can also do something like :

  
-- A global list of starting positions (x,y,z) for each spot 
spawnPoints = {{0,0,0},{0,0,30},{1000,300,40}} 
. 
. 
addEventHandler('onPlayerJoin',getRootElement(), 
    function() 
sp = spawnPoints[math.random(1,#spawnPoints)] 
spawnPlayer(source,sp[1],sp[2],sp[3]) 
    end 
) 
  

All I'm showing you is how to spawn a player at a random pre-determined spawn point. Where this code belongs in your servers code is not something I can explain. No it doesn't do skins.

Link to comment

  
function playerWasted () 
    destroyBlipsAttachedTo ( source ) 
    spawn_me ( source, 2500 ) 
end 
  
function playerJoin () 
    spawn_me( source, 1500 ) 
end 
  
  
function spawn_me( player, timer ) 
    setTimer ( spawnThePlayer, timer, 1, player ) 
end 
  
function spawnThePlayer ( player ) 
    local b = spawnPlayer ( player, -711+randInt(1,5), 957+randInt(5,9), 12.4, 90, randInt(9,288) ) 
    if not b then 
        spawnThePlayer ( player ) 
        return 
    end 
    fadeCamera(player,true) 
end 
  
  
addEventHandler ( "onPlayerJoin", root, playerJoin ) 
addEventHandler ( "onPlayerWasted", root, playerWasted ) 
  
  

This will spawn you at random points in a defined area and give u a random skin, this code is from the broph resource.

in the function spawnThePlayer on the line that starts with "local b=" is where the xyz is defined, put your x and y before each instance of "randInt" and then put your z coordinate. the next variable is for player rotation and after that the last one defines the range of skin id to select from at random ( uses pretty much all of them except the cj one).

This method will work but it is not recomended as eAi pointed out. This is especially true if you are writing a game mode that you want to make more than one map for, but if thats not the case and its just for you and not for release to the comunity then its up to you as it will solve your problem anyway.

ps. if eAi (or anyone that can tell me) reads this , please can you tell me if its possible, or how to, use randInt or math.random to spawn players, vehicles and pickups in a .map file , as this is a very useful function but i cant find any mention of it on the wiki and when i try to use it then it does not work unless i just do it in the .lua as above , but I want to use this function in a new map for an existing game mode.

Link to comment

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