Jump to content

Spawn new player to a team


Leonard.DC

Recommended Posts

Posted

Hi, i know this problem is too stupid, but i cant fix it by myself

Server Side:

function spawnFirst () 
local mySkins = { 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 35, 33, 34, 37, 40, 41, 43, 45, 41, 46, 47, 48, 51, 52, 59, 60, 66, 67, 78, 98, 101, 123, 124, 125, 128,138, 143, 144 } 
    spawnPlayer (source, 1684.73242, -2330.71021, 13.54688, 360, mySkins[math.random(1, #mySkins)], 0, 0, OffDuty) 
      setCameraTarget (source, source) 
      fadeCamera(source, true, 2.0)  
      end 

function odTeam () 
OffDuty = createTeam ( "OffDuty", 0, 0, 0 ) 
end 
addEventHandler("onResourceStart", resourceRoot, odTeam) 

When the player connect and spawn for the first time to the server, he doesn't move to the OffDuty team, He be in the original place, on the top, Why? What i do wrong, please respond

Posted

Add the "Offduty" team above the spawn, is the two codes in the same script? Perhaps try something like this;

function spawnFirst () 
local mySkins = { 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 35, 33, 34, 37, 40, 41, 43, 45, 41, 46, 47, 48, 51, 52, 59, 60, 66, 67, 78, 98, 101, 123, 124, 125, 128,138, 143, 144 } 
local OffDuty = setPlayerTeam ( "OffDuty", 0, 0, 0 ) 
    spawnPlayer (source, 1684.73242, -2330.71021, 13.54688, 360, mySkins[math.random(1, #mySkins)], 0, 0, OffDuty) 
      setCameraTarget (source, source) 
      fadeCamera(source, true, 2.0) 
      end 

If not, try this;

function spawnFirst () 
local mySkins = { 7, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 35, 33, 34, 37, 40, 41, 43, 45, 41, 46, 47, 48, 51, 52, 59, 60, 66, 67, 78, 98, 101, 123, 124, 125, 128,138, 143, 144 } 
    spawnPlayer (source, 1684.73242, -2330.71021, 13.54688, 360, mySkins[math.random(1, #mySkins)], 0, 0, "OffDuty") 
      setCameraTarget (source, source) 
      fadeCamera(source, true, 2.0) 
      end 

(Adding "" around OffDuty, as the team is a name)

EDIT3: I think the last code should do the job, but I'll leave both here for now

Posted

Dont work sir, i was tryed this, but it doesn't move me to the team :(

Edit: This is an example from the wiki

spawnTeam = createTeam ("Teamname", 255, 0, 0) -- Create team to spawn. 
function spawnOnLogin (prevA, curA, autoLogin) 
    outputChatBox ("Welcome to ...", source, 255, 0, 0, false) 
    spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) -- spawns player with random skin 
    fadeCamera (source, true) 
    setCameraTarget (source, source) 
end 
addEventHandler("onPlayerLogin", getRootElement(), spawnOnLogin) 

They say it set the player to the team, but i think something is wrong

Posted

Please post the full code of the first code, include the eventHandler too, and it's onClientPlayerSpawn, did you try to make the script client-sided?

Posted

Changed the first code to this;

function spawnFirst () 
    setPlayerTeam (source, Civil) 
      end 
addEventHandler("onPlayerSpawn", getRootElement(), spawnFirst ) 
  

He never called his function, and when he afterwards did, it interfeered with his spawn system, works now.

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