Sign in to follow this  
Hukaeshi

Ayuda con panel de warpeo.

Recommended Posts

Estoy creando un panel para moderadores y quiero implementar una función de warpear un jugador seleccionado en una GridList a otro Jugador seleccionado en otra gridlist. Pero no logro hacerlo.

Tengo el siguiente codigo: 

---Lado Client

function WarpearJugadores(btn, state)
if source == WarpearOtroJugador then
				local r, c = guiGridListGetSelectedItem (JugadorListadoWarpeo)
				if not r or r == -1 or not c or c == -1 then
					return outputChatBox("#FF0000Moderador: #55FF00Selecciona a un jugador de la lista.", 255, 255, 255, true)
				end
				local WarpData = guiGridListGetItemData (JugadorListadoWarpeo, r, c)
				if not WarpData or not isElement(WarpData) then
					return outputChatBox("#FF0000Moderador: #55FF00El jugador #FFE800"..getPlayerName(WarpData).." #55FF00No existe o no se encuentra conectado.", 255, 255, 255, true)
				end
				player = guiGridListGetItemText(GridJugadores, guiGridListGetSelectedItem(GridJugadores), 1)
				selected2 = guiGridListGetItemText(JugadorListadoWarpeo, guiGridListGetSelectedItem(JugadorListadoWarpeo), 1)
				triggerServerEvent ("WarpOtro", getLocalPlayer(), selected1)
				triggerServerEvent ("WarpOtro", getLocalPlayer(), selected2)
				
			end
			end
addEventHandler ("onClientGUIClick", root, WarpearJugadores)



-----Lado Server

function warpearOtro (thePlayer) 
   toggleControl ( source, "radio_next", false )
  toggleControl ( source, "radio_previous", false )
if isPedInVehicle(source) == true then return
outputChatBox("#FF0000Moderador: #55FF00No puedes teletransportarte a un jugador si estas en un vehiculo." , source, 255, 255, 255, true)
 end
local player = getPlayerFromName(thePlayer) 
local x, y, z = getElementPosition(player) 
	local int = getElementInterior(player)
	local dim = getElementDimension(player)
	local vehicle = getPedOccupiedVehicle ( player )
	local seat = 0
	if ( vehicle ) then seat = getPedOccupiedVehicleSeat ( player ) end
	if ( vehicle ) then warpPedIntoVehicle ( player, vehicle, seat ) end
		if ( isPedInVehicle ( player ) ) then
      		  		local vehicle = getPedOccupiedVehicle ( player )
					local seats = getVehicleMaxPassengers ( vehicle ) + 1
					local i = 0
					while ( i < seats ) do
						if ( not getVehicleOccupant ( vehicle, i ) ) then
   						warpPedIntoVehicle (source, vehicle, i )
							break
						end
						i = i + 1
					end
					if ( i >= seats ) then
						warp ( source, player )
					end
				end
	setElementPosition(source, x + 0.5,y,z )
	setElementInterior(source,int)
	setElementDimension(source,dim)
	
end
addEvent("WarpOtro", true) 
addEventHandler("WarpOtro", getRootElement(), warpearOtro)

 

Share this post


Link to post
function WarpearJugadores(btn, state)
	if source == WarpearOtroJugador then
		local r, c = guiGridListGetSelectedItem (JugadorListadoWarpeo)
		if not r or r == -1 or not c or c == -1 then
			outputChatBox("#FF0000Moderador: #55FF00Selecciona a un jugador de la lista.", 255, 255, 255, true)
			return false
		end
		local WarpData = guiGridListGetItemData (JugadorListadoWarpeo, r, c)
		if not WarpData or not isElement(WarpData) then
			outputChatBox("#FF0000Moderador: #55FF00El jugador #FFE800"..getPlayerName(WarpData).." #55FF00No existe o no se encuentra conectado.", 255, 255, 255, true)
			return false
		end
		selected1 = guiGridListGetItemText(GridJugadores, guiGridListGetSelectedItem(GridJugadores), 1)
		selected2 = guiGridListGetItemText(JugadorListadoWarpeo, guiGridListGetSelectedItem(JugadorListadoWarpeo), 1)
		triggerServerEvent ("WarpOtro", getLocalPlayer(), selected1) -- Suponiendo que estamos seleccionando el jugador al que queremos llegar
		--triggerServerEvent ("WarpOtro", getLocalPlayer(), selected2) <- Para que repetir el proceso?
		
	end
end
addEventHandler ("onClientGUIClick", root, WarpearJugadores)




function warpearOtro (thePlayer) 
	toggleControl ( client, "radio_next", false )
	toggleControl ( client, "radio_previous", false )
	if isPedInVehicle(source) == true then 
		outputChatBox("#FF0000Moderador: #55FF00No puedes teletransportarte a un jugador si estas en un vehiculo." , source, 255, 255, 255, true)
		return false
	end
	local player = getPlayerFromName(thePlayer) 
	local x, y, z = getElementPosition(player) 
	local int = getElementInterior(player)
	local dim = getElementDimension(player)
	local vehicle = getPedOccupiedVehicle ( player )
	local seat = 0
	--if ( vehicle ) then seat = getPedOccupiedVehicleSeat ( player ) end
	--if ( vehicle ) then warpPedIntoVehicle ( player, vehicle, seat ) end
	
	setElementPosition(client, x + 0.5,y,z )
	setElementInterior(client,int)
	setElementDimension(client,dim)
	
	if ( isPedInVehicle ( player ) ) then
		local vehicle = getPedOccupiedVehicle ( player )
		local seats =   ( vehicle ) + 1
		local i = 0
		while ( i < seats ) do
			if ( not getVehicleOccupant ( vehicle, i ) ) then
			warpPedIntoVehicle (client, vehicle, i )
				break
			end
			i = i + 1
		end
		if ( i >= seats ) then
			warp ( client, player )
		end
	end	
	
end
addEvent("WarpOtro", true) 
addEventHandler("WarpOtro", getRootElement(), warpearOtro)



La verdad no lo probé, pero creo que debería funcionar, estaba casi todo bien xd

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.