Jump to content

[HELP] Different dimensions


Cronoss

Recommended Posts

I was testing the "create character" system I been working on with a friend, and we did not expect this... when we both register our accounts and create our characters we can't see each other, we are invisibles, I don't know how to prevent this or what did I scripted wrong, please, help

This is the part that TP our characters and I think here it's the problem:

(Client-Side)

addEventHandler("onClientGUIClick", btnSeleccionar, function()
		showCursor(false)
		guiSetVisible(ventanaElegirSkinsM, false)
		setElementPosition ( getLocalPlayer(), 1742.9543457031,-1862.6853027344,13.575992584229)
		setElementDimension( getLocalPlayer(), 0)
		setElementRotation( getLocalPlayer(), -0, 0, 357.78338623047)
		setElementInterior( getLocalPlayer(), 0)
		triggerServerEvent("descongelar", getLocalPlayer(), localPlayer)
		setPlayerMoney(2500)

All the rest of the code runs like I wanted, the money, the triggerevent, the position, etc, but for some reason, the script send us to different "interiors" or "dimensions". 

And, most important thing is that when we both create our character, we can't see each other new nickname, the skin neither

Edited by Cronoss
Link to comment

there doesn't seem to be a problem here, everything seems correct are you sure there is a problem here?

by the way, make sure to use setPlayerMoney on server side because it doesn't work on client side

wiki:

Note: Using this function client side (not recommended) will not change a players money server side.

 

addEventHandler("onClientGUIClick", btnSeleccionar, function()
		showCursor(false)
		guiSetVisible(ventanaElegirSkinsM, false)
		setElementPosition ( getLocalPlayer(), 1742.9543457031,-1862.6853027344,13.575992584229)
		setElementDimension( getLocalPlayer(), 0)
		setElementRotation( getLocalPlayer(), -0, 0, 357.78338623047)
		setElementInterior( getLocalPlayer(), 0)
		triggerServerEvent("descongelar", getLocalPlayer(), localPlayer)
		setPlayerMoney(2500) -- <-- this
Edited by Burak5312
Link to comment

Here it's the part of the code that triggers the gui to create the character:

function registroHRP(user, clavecreada)
	if(addAccount(user, clavecreada))then
		triggerClientEvent(source, "cerrar", source)
		logIn(source, getAccount(user, clavecreada), clavecreada)
		setElementPosition(source, 209.41818237305,-33.872188568115,1001.9296875)
 		setElementInterior(source, 1)
		setElementDimension(source, 0)
		setPedRotation(source, 180)
		setElementFrozen(source, true)
		setCameraMatrix (source, 207.53846740723,-37.582496643066,1001.8046875, 209.41818237305,-33.872188568115,1001.9296875, 0, 100 )

		triggerClientEvent(source, "crearPJ", source)
		triggerClientEvent(source, "pararmusicaycamara", source) -- stop music and camera matrix

	else
		-----gotta add a text here------------
	end
end

(Server-Side)

 

If the problem isn't there I don't know where could be

Edited by Cronoss
Link to comment

I didn't added spawnPlayer function, it only works with "setelementposition, interior, dimension, etc", this is the code AFTER the player choosing the skin:

addEventHandler("onClientGUIClick", btnSeleccionar, function()
		showCursor(false)
		guiSetVisible(ventanaElegirSkinsM, false)
    ---------------Here starts the TP--------------
		setElementPosition ( getLocalPlayer(), 1742.9543457031,-1862.6853027344,13.575992584229) 
		setElementDimension( getLocalPlayer(), 0)
		setElementRotation( getLocalPlayer(), -0, 0, 357.78338623047)
		setElementInterior( getLocalPlayer(), 0)
		triggerServerEvent("descongelar", getLocalPlayer(), localPlayer) ----Just a function that unfreezes the player------
		setPlayerMoney(2500)
		end, false)
	end



also, I edited a little bit the freeroam/play gamemode, so if I stop the "Login resource" this is what you see:

(maybe this is the problem?)

click

Link to comment
setElementDimension( getLocalPlayer(), 0)
setElementInterior( getLocalPlayer(), 0)

Can you try to transfer these codes to the server side, it can be inside the descongelar event.

Apart from this, there may be other codes that you did not show here, I did not see a problem in the codes you sent.

Edited by Burak5312
Link to comment

I think the problem it's solved, but now we can't see the skin that we chose, I see him with the CJ default skin and he sees me like that too, here is the code of the skin selection (the code that you helped me to make I must say, thank you for that):

local currentTableID = 1
        setElementModel(localPlayer, tablaSkinsHombre[currentTableID])
		addEventHandler("onClientGUIClick", btnSiguienteSkin, function()
  		if(currentTableID > #tablaSkinsHombre) then currentTableID = 1 end
   		setElementModel(localPlayer, tablaSkinsHombre[currentTableID])
   		currentTableID = currentTableID + 1
		end, false) 

		addEventHandler("onClientGUIClick", btnAnteriorSkin, function()
  		if(currentTableID < 1) then currentTableID = 188 end
   		setElementModel(localPlayer, tablaSkinsHombre[currentTableID])
   		currentTableID = currentTableID - 1
		end, false) 

		addEventHandler("onClientGUIClick", btnSeleccionar, function()
		showCursor(false)
		guiSetVisible(ventanaElegirSkins, false)
		setElementPosition ( getLocalPlayer(), 1742.9543457031,-1862.6853027344,13.575992584229)
        setElementDimension( getLocalPlayer(), 0)
        setElementRotation( getLocalPlayer(), -0, 0, 357.78338623047)
        setElementInterior( getLocalPlayer(), 0)
		triggerServerEvent("descongelar", getLocalPlayer(), localPlayer)
        ----------------------At this point its just the setplayermoney and the end-------------------------

 

Link to comment

I understand the solution but how should I do it? I'm not asking for the code, I want to know if I should make a "triggerServerEvent" or something like that, if that's the case, could you explain me how to transfer the "table" and "currentid" to the server-side? Because I tried and it doesn't get any error but it doesn't work neither. Thanks for your time, I appreciate your help

Link to comment

 

Create an event on the server side to change the player's skin

addEvent("setPlayerSkin", true)
addEventHandler("setPlayerSkin", root,
    function(ID)
       setElementModel(source, ID)
    end
)

then call it with triggerServerEvent this can be inside the btnSeleccionar event

You don't need to delete the setElementModel function on the client side for this, just trigger it on the server side after the player selects the final skin

triggerServerEvent("setPlayerSkin", localPlayer, tablaSkinsHombre[currentTableID])
Edited by Burak5312
  • 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...