Jump to content

¿Como puedo arreglar este chat?


depato123

Recommended Posts

Hola. tengo un problema con este script

script original:

function engineSwitch () 
  if (isPedInVehicle (source)) then 
    local veh = getPedOccupiedVehicle (source) 
    if (getVehicleEngineState (veh) == true) then 
      setVehicleEngineState (veh, false) 
      outputChatBox ("*".. getPlayerName(source) .." ah apagado el Vehiculo.", v, 255, 40, 80) 
    elseif (getVehicleEngineState (veh) == false) then 
      setVehicleEngineState (veh, true) 
         local px,py,pz = getElementPosition(source) 
    for _,v in ipairs(getElementsByType("player")) do 
        if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox ("*".. getPlayerName(source) .." ah encendido el Vehiculo.", v, 255, 40, 80) 
    end 
 end 
end 
  else 
    outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) 
  end 
end 
addEvent("engenieSwitch",true) 
addEventHandler("engenieSwitch",getRootElement(),engineSwitch) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
   local px,py,pz=getElementPosition(player) 
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5 <= range 
end 

script editado

chat_range = 100 -- Distancia 
  
function engineSwitch () 
  if (isPedInVehicle (source)) then 
    local veh = getPedOccupiedVehicle (source) 
    if (getVehicleEngineState (veh) == true) then 
      setVehicleEngineState (veh, false) 
         local px,py,pz = getElementPosition(source) 
    for _,v in ipairs(getElementsByType("player")) do 
        if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox ("*".. getPlayerName(source) .." ah apagado el Vehiculo.", v, 255, 40, 80) 
    elseif (getVehicleEngineState (veh) == false) then 
      setVehicleEngineState (veh, true) 
         local px,py,pz = getElementPosition(source) 
    for _,v in ipairs(getElementsByType("player")) do 
        if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox ("*".. getPlayerName(source) .." ah encendido el Vehiculo.", v, 255, 40, 80) 
    end 
 end 
end 
  else 
    outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) 
  end 
end 
addEvent("engenieSwitch",true) 
addEventHandler("engenieSwitch",getRootElement(),engineSwitch) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
   local px,py,pz=getElementPosition(player) 
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5 <= range 
end 

Al agregarle estas 3 renglones en la linea 5

deja de funcionar

         local px,py,pz = getElementPosition(source) 
    for _,v in ipairs(getElementsByType("player")) do 
        if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 

El resourse lo que tendria que hacer es al apretar un boton que el vehiculo se cierre y que aparezca el mensaje *Usuario: Ha encendido el vehiculo.

En el original solo pasa eso al apagarlo pero al encenderlo aparece el mensaje a todo el server. Mientras necesito que solo se vea en un rango de 10

Link to comment

Solo es un problema con los end, intenta esto:

chat_range = 100 -- Distancia 
  
function engineSwitch () 
  if (isPedInVehicle (source)) then 
    local veh = getPedOccupiedVehicle (source) 
    if (getVehicleEngineState (veh) == true) then 
      setVehicleEngineState (veh, false) 
         local px,py,pz = getElementPosition(source) 
    for _,v in ipairs(getElementsByType("player")) do 
        if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
      outputChatBox ("*".. getPlayerName(source) .." ah apagado el Vehiculo.", v, 255, 40, 80) 
    elseif (getVehicleEngineState (veh) == false) then 
      setVehicleEngineState (veh, true) 
         local px,py,pz = getElementPosition(source) 
        for _,v in ipairs(getElementsByType("player")) do 
            if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then 
                outputChatBox ("*".. getPlayerName(source) .." ah encendido el Vehiculo.", v, 255, 40, 80) 
            end 
        end 
    end 
        else 
            outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) 
        end 
    end 
  end 
 end 
addEvent("engenieSwitch",true) 
addEventHandler("engenieSwitch",getRootElement(),engineSwitch) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
   local px,py,pz=getElementPosition(player) 
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5 <= range 
end 

Link to comment
chat_range = 100 -- Distancia 
  
function engineSwitch ( ) 
    if ( isPedInVehicle ( source ) ) then 
        local veh = getPedOccupiedVehicle ( source ) 
        if ( getVehicleEngineState ( veh ) == true ) then 
            setVehicleEngineState ( veh, false ) 
            local px, py, pz = getElementPosition ( source ) 
            for _, v in ipairs ( getElementsByType ( "player" ) ) do 
                if isPlayerInRangeOfPoint ( v, px, py, pz, chat_range ) then 
                    outputChatBox ( "*".. getPlayerName ( source ) .." ah apagado el Vehiculo.", v, 255, 40, 80 ) 
                end 
            end 
        else 
            setVehicleEngineState ( veh, true ) 
            local px, py, pz = getElementPosition ( source ) 
            for _, v in ipairs ( getElementsByType ( "player" ) ) do 
                if isPlayerInRangeOfPoint ( v, px, py, pz, chat_range ) then 
                    outputChatBox ( "*".. getPlayerName ( source ) .." ah encendido el Vehiculo.", v, 255, 40, 80 ) 
                end 
            end 
        end 
    else 
        outputChatBox ("You aren't in a vehicle!", source, 255, 0, 0) 
    end 
end 
addEvent ( "engenieSwitch",true ) 
addEventHandler ( "engenieSwitch", getRootElement(), engineSwitch ) 
  
function isPlayerInRangeOfPoint(player,x,y,z,range) 
   local px,py,pz=getElementPosition(player) 
   return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5 <= range 
end 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...