Jump to content

[HELP] stat panel


Fory

Recommended Posts

Hello everyone!
My problem, how I did it a stat panel
"/stat [id] it's working, the player shows your data,
on the other hand and I got it ready buttons, 
-goto (to the player teleport)
-gethere (player to yourself telepor)
-fixveh (fixes the vehicle)
-unflip (let him turn the vehicle upside down)
-vhspawn (teleport to the city hall)
and from among these the vhspawn button, unflip, fixveh,
these work, the goto and the gethere command that trouble, that to myself teleport, and myself teleport self to myself.

I would like it, that some müködjön, that for who I take it the stat-let ját do the command on that player

Script: Server

--GETHERE
function getHere(thePlayer, target)
	if (exports.las_global:isPlayerSeged(thePlayer)) then
			if showingPlayer then
				local logged = getElementData(showingPlayer, "loggedin")

				if (logged==0) then
					outputChatBox("the player is not login", thePlayer, 255, 0 , 0, true)
				else
					local x, y, z = getElementPosition(thePlayer)
					local interior = getElementInterior(thePlayer)
					local dimension = getElementDimension(thePlayer)
					local r = getPedRotation(thePlayer)
					setCameraInterior(showingPlayer, interior)

					-- Maths calculations to stop the target being stuck in the player
					x = x + ( ( math.cos ( math.rad ( r ) ) ) * 2 )
					y = y + ( ( math.sin ( math.rad ( r ) ) ) * 2 )

					if (isPedInVehicle(showingPlayer)) then
						local veh = getPedOccupiedVehicle(showingPlayer)
						setElementAngularVelocity(veh, 0, 0, 0)
						setElementPosition(veh, x, y, z + 1)
						setTimer(setElementAngularVelocity, 50, 20, veh, 0, 0, 0)
						setElementInterior(veh, interior)
						setElementDimension(veh, dimension)

					else
						setElementPosition(showingPlayer, x, y, z)
						setElementInterior(showingPlayer, interior)
						setElementDimension(showingPlayer, dimension)
					end
					outputChatBox("Sikeresen magadhoz teleportáltad 'succes'", thePlayer,0,255,0,true)
				end
			end
		end
	end
addEvent("getHere", true)
addEventHandler("getHere", getRootElement(), getHere)

--GOTO

function gotoPlayer(thePlayer, target)
	if getElementData(thePlayer, "adminlevel") > 1 then
			if showingPlayer then
				local logged = getElementData(showingPlayer, "loggedin")

				if (logged==0) then
					outputChatBox("the player is not login", thePlayer, 255, 0 , 0, true)
				else
					local x, y, z = getElementPosition(showingPlayer)
					local interior = getElementInterior(showingPlayer)
					local dimension = getElementDimension(showingPlayer)
					local r = getPedRotation(showingPlayer)

					-- Maths calculations to stop the player being stuck in the target
					x = x + ( ( math.cos ( math.rad ( r ) ) ) * 2 )
					y = y + ( ( math.sin ( math.rad ( r ) ) ) * 2 )

					setCameraInterior(thePlayer, interior)

					if (isPedInVehicle(thePlayer)) then
						local veh = getPedOccupiedVehicle(thePlayer)
						setElementAngularVelocity(veh, 0, 0, 0)
						setElementInterior(thePlayer, interior)
						setElementDimension(thePlayer, dimension)
						setElementInterior(veh, interior)
						setElementDimension(veh, dimension)
						setElementPosition(veh, x, y, z + 1)
						warpPedIntoVehicle ( thePlayer, veh )
						setTimer(setElementAngularVelocity, 50, 20, veh, 0, 0, 0)
					else
						setElementPosition(thePlayer, x, y, z)
						setElementInterior(thePlayer, interior)
						setElementDimension(thePlayer, dimension)
					end
					outputChatBox("Elteleportáltál a kiválasztott játékoshoz 'succes'", thePlayer,0,255,0,true)
				end
			end
		end
	end
addEvent("gotoPlayer", true)
addEventHandler("gotoPlayer", getRootElement(), gotoPlayer)

the showingPlayer that's it at who I look (theoretically)

CLIENT

--GOTO
function buttonClicks2(button, state)
	if statpanelOpened then
		if button == "left" and state == "down" then
			if not countSelector then
				if isInSlot(sx/2+200, sy/2-260/2, 180,25) then
					triggerServerEvent("gotoPlayer", localPlayer, showingPlayer)
					currentTab = 1
					scrollData = 0
					scrollData2 = 0
				end
			end
		end
    end
end
addEventHandler("onClientClick", getRootElement(), buttonClicks2)

-GETHERE

function buttonClicks4(button, state)
	if statpanelOpened then
		if button == "left" and state == "down" then
			if not countSelector then
				if isInSlot(sx/2+200, sy/2-180/2, 180,25) then
					triggerServerEvent("getHere", localPlayer, showingPlayer)
					currentTab = 1
					scrollData = 0
					scrollData2 = 0
				end
			end
		end
    end
end
addEventHandler("onClientClick", getRootElement(), buttonClicks4)

 

Edited by Fory
Link to comment

Heya.

Your arg "showingPlayer" is existing on the client-side. Right now you are triggering the server-sided event with the showingPlayer argument which is "thePlayer" on server-side. You will have to pass localPlayer and showingPlayer both, which will be thePlayer and target on server-side if I'm looking at it correctly.

For future reference, please include errors, and also read our debugging tutorial please.

Link to comment

the debug writes nothing, in fact the showingPlayer, it targetPlayer

function getAdminPanel(thePlayer, commandName, targetPlayer)
		if targetPlayer then
			local targetPlayer, targetPlayerName = exports.las_global:findPlayerByPartialNick(thePlayer, targetPlayer)
			if not (targetPlayer) then
				outputChatBox("#d75959[LasMTA]:#ffffff Nincs ilyen játékos.", thePlayer, 255, 255, 255, true)
				return
			end
			showingPlayer = targetPlayer
		else
			showingPlayer = thePlayer
		end
		triggerClientEvent(thePlayer, "statpanelOpen", thePlayer, showingPlayer)
	end
addCommandHandler("stat", getAdminPanel, false, false)

 

Link to comment
the Client-in too the showingPlayer is in him
 
--CLINET SIDE
function statpanelOpen(showP)
	if showStats then
		showStats = false
		showingPlayer = false
		statpanelOpened = false
	else
		showStats = true
		
		if showP ~= localPlayer then
			showingPlayer = showP
		else
			showingPlayer = localPlayer
		end
		statpanelOpened = true
	end		
end
addEvent("statpanelOpen", true)
addEventHandler("statpanelOpen", root, statpanelOpen)

the /debugscript 3 write nothing.
the goto-ra I click then teleportál, only that trouble, that to myself,

Link to comment
triggerServerEvent("getHere", localPlayer, showingPlayer)
function getHere(thePlayer, target) 	if (exports.las_global:isPlayerSeged(thePlayer)) then

You are checking the target player's admin level as I explained above and I also said that debugging isn't just /debugscript 3.

 

Link to comment

Hello Fory,

your code does contain some variable flaws as @NeXuS™ has already mentioned. From what I gather you are messing up parameter associations for both remote event handlers "getHere" and "gotoPlayer". The actual function signature for both event handlers should be as follows:

...
function getHere(showingPlayer)
    thePlayer = source
    ...
end
...
function gotoPlayer(showingPlayer)
    thePlayer = source
    ...
end

 

Edited by The_GTA
Link to comment
  • 1 month later...

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