Jump to content

please help


liamknight24

Recommended Posts

i want my server to be like when a player has logged in he will spawn at a postion and then when he reconnects he wont spawn at the first position he will spawn where he left off,

here is what i have so far::

function spawn(player)
local playeraccount = getPlayerAccount ( thePlayer )
   playerpos = getAccountData ( playeraccount, "position", playerpos )
if ( playerpos ) then
spawnPlayer ( player, playerpos )
fadeCamera(player, true)
setCameraTarget(player, player)
else
spawnPlayer ( player, 2315.0593261719, -2968.7006835938, 1816.2529296875, 90, math.random(1,2) )
fadeCamera(player, true)
setCameraTarget(player, player)
end
end
 
function onPlayerQuit ( )
local playeraccount = getPlayerAccount ( thePlayer )
if ( playeraccount ) then
local playerpos = getElementPosition ( thePlayer )
setAccountData ( playeraccount, "position", playerpos )
end
end

is there any other way of doing this?? thanks for any help.

Link to comment

i want my server to be like when a player has logged in he will spawn at a postion and then when he reconnects he wont spawn at the first position he will spawn where he left off,

here is what i have so far::

function spawn(player)
local playeraccount = getPlayerAccount ( thePlayer )
   playerpos = getAccountData ( playeraccount, "position", playerpos )
if ( playerpos ) then
spawnPlayer ( player, playerpos )
fadeCamera(player, true)
setCameraTarget(player, player)
else
spawnPlayer ( player, 2315.0593261719, -2968.7006835938, 1816.2529296875, 90, math.random(1,2) )
fadeCamera(player, true)
setCameraTarget(player, player)
end
end
 
function onPlayerQuit ( )
local playeraccount = getPlayerAccount ( thePlayer )
if ( playeraccount ) then
local playerpos = getElementPosition ( thePlayer )
setAccountData ( playeraccount, "position", playerpos )
end
end

is there any other way of doing this?? thanks for any help.

Link to comment
function spawn(player)
local playeraccount = getPlayerAccount ( player )
local playerposX = getAccountData ( playeraccount, "positionX")
local playerposY = getAccountData ( playeraccount, "positionY")
local playerposZ = getAccountData ( playeraccount, "positionZ")
if ( playerposX ) then
spawnPlayer ( player, playerposX, playerposY, playerposZ )
fadeCamera(player, true)
setCameraTarget(player, player)
else
spawnPlayer ( player, 2315.0593261719, -2968.7006835938, 1816.2529296875, 90, math.random(1,2) )
fadeCamera(player, true)
setCameraTarget(player, player)
end
end
 
function onPlayerQuit ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playerposX,playerposY,playerposZ = getElementPosition ( source )
setAccountData ( playeraccount, "positionX", playerposX )
setAccountData ( playeraccount, "positionY", playerposY )
setAccountData ( playeraccount, "positionZ", playerposZ )
end
end

I just did a quick sweep and fixed some minor stuff. Important stuff to note:

- getElementPosition returns X, Y and Z. Not just 1 value

- In the "spawn" function there is no such variable as "thePlayer"

- In the "onPlayerQuit" function the player who quit is marked by "source", not "thePlayer"

- I don't see any event handlers

Link to comment
function spawn(player)
local playeraccount = getPlayerAccount ( player )
local playerposX = getAccountData ( playeraccount, "positionX")
local playerposY = getAccountData ( playeraccount, "positionY")
local playerposZ = getAccountData ( playeraccount, "positionZ")
if ( playerposX ) then
spawnPlayer ( player, playerposX, playerposY, playerposZ )
fadeCamera(player, true)
setCameraTarget(player, player)
else
spawnPlayer ( player, 2315.0593261719, -2968.7006835938, 1816.2529296875, 90, math.random(1,2) )
fadeCamera(player, true)
setCameraTarget(player, player)
end
end
 
function onPlayerQuit ( )
local playeraccount = getPlayerAccount ( source )
if ( playeraccount ) then
local playerposX,playerposY,playerposZ = getElementPosition ( source )
setAccountData ( playeraccount, "positionX", playerposX )
setAccountData ( playeraccount, "positionY", playerposY )
setAccountData ( playeraccount, "positionZ", playerposZ )
end
end

I just did a quick sweep and fixed some minor stuff. Important stuff to note:

- getElementPosition returns X, Y and Z. Not just 1 value

- In the "spawn" function there is no such variable as "thePlayer"

- In the "onPlayerQuit" function the player who quit is marked by "source", not "thePlayer"

- I don't see any event handlers

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