Jump to content

spawn Player


xXGhostXx

Recommended Posts

3 hours ago, JeViCo said:

you're probably using default 'play' gamemode. It always spawns player when he/she joins the server. You should remove it and spawn players after you login in your login-panel resource. Don't forget about onClientPlayerWasted event to respawn player and return camera 

@xXGhostXx

No ! i writing game mode !

addEventHandler('onPlayerJoin', root, function ()
  spawnPlayer(source, 1286.17578125, -1329.16015625, 13.55211353302)
  fadeCamera(source, true)
  setCameraTarget(source, source)
end)

local tempSkin;

addEventHandler( "onPlayerWasted", getRootElement( ), 
function() 
    tempSkin = getPlayerSkin ( source )
        setTimer( respawnAfterDeath, 3000, 1, source ) 
    end 
)

function respawnAfterDeath(source)

  spawnPlayer(source, 1286.17578125, -1329.16015625, 13.55211353302)
  setPlayerSkin(source, tempSkin)
  fadeCamera(source, true)
  setCameraTarget(source, source)

end

This code for my game mode !

please fix my script

Link to comment
Just now, JeViCo said:

@xXGhostXx remove this part of code and it'll solve your problem


addEventHandler('onPlayerJoin', root, function ()
  spawnPlayer(source, 1286.17578125, -1329.16015625, 13.55211353302)
  fadeCamera(source, true)
  setCameraTarget(source, source)
end)

 

What ?!

How players join to server ?

Link to comment
4 minutes ago, JeViCo said:

ok then. Replace 'onPlayerJoinwith 'onPlayerLogin'

Thanks !

But i have 5000$ in my cash and reset to 800$ because of on player login set player money has it, also skin players like this !

addEventHandler('onPlayerLogin', root, function ()
  spawnPlayer(source, 1286.17578125, -1329.16015625, 13.55211353302)
  setPlayerSkin(source, 170)
  setPlayerMoney(source, 800)
  fadeCamera(source, true)
  setCameraTarget(source, source)
end)

please answer me

Link to comment
2 hours ago, xXGhostXx said:

But i have 5000$ in my cash and reset to 800$

If player joins the server for first time and get 5000$, you should look for givePlayerMoney or setPlayerMoney functions in your other resources because default value is 0

2 hours ago, xXGhostXx said:

also skin players like this !

default skin is 0 (CJ) so that's normal

Also you can make this shorter. Replace this

spawnPlayer(source, 1286.17578125, -1329.16015625, 13.55211353302)
setPlayerSkin(source, 170)

with this

local rot = 90 -- spawn rotation
local skinID = 170
spawnPlayer(source, 1286.175+math.random(-1,1), -1329.160+math.random(-1,1), 13.552, rot, skinID)

I also added +math.random(-1,1). It prevents players being stuck (when 2+ players spawn at the same time)

Edited by JeViCo
Link to comment
3 minutes ago, JeViCo said:

If player joins the server for first time and get 5000$, you should look for givePlayerMoney or setPlayerMoney functions in your other resources because default value is 0

default skin is 0 (CJ) so that's normal

Also you can make this shorter. Replace this


spawnPlayer(source, 1286.17578125, -1329.16015625, 13.55211353302)
setPlayerSkin(source, 170)

with this


local rot = 90 -- spawn rotation
local skinID = 170
spawnPlayer(source, 1286.175+math.random(-1,1), -1329.160+math.random(-1,1), 13.552, rot, skinID)

I also added +math.random(-1,1). It prevents player sticking (when 2+ players spawn at the same time)

please give me code :(

Link to comment
addEventHandler('onPlayerLogin', root, function ()
	local rot = 90 -- spawn rotation
	local skinID = 170 -- skin id
	spawnPlayer(source, 1286.175+math.random(-1,1), -1329.160+math.random(-1,1), 13.552, rot, skinID)
	
	local acc = getPlayerAccount(source)
	if not getAccountData(acc,"player:register") then -- set money if player joined the server for first time
		setPlayerMoney(source, 800)
		setAccountData(acc,"player:register",true)
	end
    
	fadeCamera(source, true)
	setCameraTarget(source, source)
end)

@xXGhostXx

Link to comment
24 minutes ago, JeViCo said:

addEventHandler('onPlayerLogin', root, function ()
	local rot = 90 -- spawn rotation
	local skinID = 170 -- skin id
	spawnPlayer(source, 1286.175+math.random(-1,1), -1329.160+math.random(-1,1), 13.552, rot, skinID)
	
	local acc = getPlayerAccount(source)
	if not getAccountData(acc,"player:register") then -- set money if player joined the server for first time
		setPlayerMoney(source, 800)
		setAccountData(acc,"player:register",true)
	end
    
	fadeCamera(source, true)
	setCameraTarget(source, source)
end)

@xXGhostXx

Not work :(

Link to comment

khob aval  Akxe To Mizarm Ke Obne bish Nisti Harom Zade bache sal Madresatm 3 Roz Dg STart Mishe SIk kon Khob

Barye Fix Kardan Spawn Player Bayd Ye khorde Khye Haye Khareji haro Bemali Khar kose Havasetm bashe Kos begi Zod Bala Saret Va MIkonm ye Solakh RO madaret

Dg Nari Beshini Poshe Man Harf Bezani Ha KOse Nanat Bb :D #Darcy

http://uupload.ir/files/lwwv_photo_db_b2_db_b0_db_b1_db_b8_db_b0_db_b8_db_b2_db_b5_db_b1_db_b4_db_b2_db_b8_db_b3_db_b7.jpglwwv_photo_db_b2_db_b0_db_b1_db_b8_db_b0

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