depato123 Posted November 12, 2013 Share Posted November 12, 2013 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
Alexs Posted November 12, 2013 Share Posted November 12, 2013 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
depato123 Posted November 12, 2013 Author Share Posted November 12, 2013 Gracias, pero eso no sirve. Al presionar el botón no sucede nada Link to comment
Alexs Posted November 12, 2013 Share Posted November 12, 2013 ¿Error en el debug al cargar el recurso o al presionar el botón? Link to comment
depato123 Posted November 12, 2013 Author Share Posted November 12, 2013 [2013-11-12 18:41:06] SCRIPT ERROR: vehiclesystemcarshops2\server.lua:56: 'end' expected (to close 'for' at line 44) near 'else' [2013-11-12 18:41:06] ERROR: Loading script failed: vehiclesystemcarshops2\server.lua:56: 'end' expected (to close 'for' at line 44) near 'else' Link to comment
Castillo Posted November 12, 2013 Share Posted November 12, 2013 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
Recommended Posts