Jump to content

Spawn_Location


Dadcdai

Recommended Posts

Hey i tryed so hard to change the location when you (create) you'r character,but every time i try to change somthing or it not doing anything or it gives me errors.

Can someone tell me how to change the location when you(created) you'r character?

Here is the code

        local locationToSpawn = {}
                if location then -- if this is not a newly created character spawn, location would be nil /maxime
                        --outputDebugString("this is a newly created character spawn.")
                        locationToSpawn.x = location[1]
                        locationToSpawn.y = location[2]
                        locationToSpawn.z = location[3]
                        locationToSpawn.rot = location[4]
                        locationToSpawn.int = location[5]
                        locationToSpawn.dim = location[6]
                else --Otherwise, spawn normally for old characters. Fetch location from database. /maxime
                        locationToSpawn.x = tonumber(characterData["x"])
                        locationToSpawn.y = tonumber(characterData["y"])
                        locationToSpawn.z = tonumber(characterData["z"])
                        locationToSpawn.rot = tonumber(characterData["rotation"])
                        locationToSpawn.int = tonumber(characterData["interior_id"])
                        locationToSpawn.dim = tonumber(characterData["dimension_id"])
                end
                spawnPlayer(client, locationToSpawn.x ,locationToSpawn.y ,locationToSpawn.z , locationToSpawn.rot, tonumber(characterData["skin"]))
                setElementDimension(client, locationToSpawn.dim)
                setElementInterior(client, locationToSpawn.int , locationToSpawn.x, locationToSpawn.y, locationToSpawn.z)
                setCameraInterior(client, locationToSpawn.int)
               

 

Link to comment

like my account-system has a character creation, like when i login it will pop on a gui if i dont have any character already, and when i am done creating my character it spawns me somewhere in the city, but like if i already have a character created it will spawn me when i was the last time i log out

 

so i want to change the spawn location when i create my character, and i dont know how....

like where i need to put the coordiantes so when i am done creating my character it will spawn me at the coordinate i put?

Link to comment

You have to find the file and edit the coordinates there,

but you can also use the following code without finding the file you need:

local spawn =
{
	position = { 0, 0, 3 },
	rotation = 90,
	skin = 124, -- skin ID
	int = 0, -- interior
	dim = 0, -- dimension
}

addEventHandler("onPlayerLogin",root,function()
    local x, y, z = unpack(spawn.position)
    
    setTimer(spawnPlayer,500,1,source,x,y,z,spawn.rotation,spawn.skin,spawn.int,spawn.dim)
end)

 

Link to comment

wait no cuz if i put that code, my old character location will change to the spawn, like i want when i log out of my character and i join again, my charater would be in the same

coordinates when i left it, i only want to change the coordinates when you newly created a character

and didnt i found the file?

Link to comment

It's not clear from the code and other info you've given what exactly the problem is. I mean if location is meant to indicate that the character is newly created, you need to pass it to this code when the player creates a new character. How creation/selection of characters is done in your script, that's another thing, we don't know that.

  • Thanks 1
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...