Jump to content

Auto de Jugador


Recommended Posts

Gracias Blue Pie, Cree lo siguiente pero no se porque motivo el auto vuela, se eleva poco a poco, y me envia varios outputs, esto es lo que cree:

function comando(thePlayer) 
  local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
  local vehicles = getElementsByType("vehicle") 
    if theVehicle then 
    for k,v in ipairs(vehicles) do 
     setElementCollisionsEnabled(v, false) 
     outputChatBox("Listo", thePlayer, 255, 0, 0) 
     end 
     else 
     for k,v in ipairs(vehicles) do 
     setElementCollisionsEnabled(v, true) 
     outputChatBox("Debes Subir a un Auto", thePlayer, 255, 0, 0) 
     end 
     end 
   end 
addCommandHandler("tt", comando) 

Link to comment

En cliente es mucho mas eficiente colocarlo:

function comando() 
    local vehicles = getElementsByType("vehicle") 
    for k,v in ipairs(vehicles) do 
        if not isPedInVehicle(localPlayer) then 
            outputChatBox("Debes Subir a un Auto", 255, 0, 0) 
            break 
        end 
        if getVehicleOccupant(v) ~= localPlayer then 
            setElementCollisionsEnabled(v, not getElementCollisionsEnabled(v)) 
        else 
            setElementCollisionsEnabled(v, true) 
        end 
    end 
end 
addCommandHandler("tt", comando) 

Link to comment
Muchas Gracias Gaberiel, pero hay un problema, yo puedo traspasar a el otro vehiculo, pero a el le aparece como si yo lo chocara, que podria hacer? usar trigger y poner que traspase el vehiculo en server?

Tienes que hacer la parte de las colisiones en el servidor.

Link to comment

Si exacto tomas a eso me referia, lo he creado y funciona, pero aun hay un error, si algun otro usuario esta en un auto, sale volando, si el auto esta vacio si funciona perfectamente el otro usuario ve que puedo traspasarlo

Client:

function comando() 
    local vehicles = getElementsByType("vehicle") 
    for k,v in ipairs(vehicles) do 
        if not isPedInVehicle(localPlayer) then 
            outputChatBox("Debes Subir a un Auto", 255, 0, 0) 
            break 
        end 
        if getVehicleOccupant(v) ~= localPlayer then 
        triggerServerEvent("alEntrar", localPlayer, v) 
        else 
            setElementCollisionsEnabled(v, true) 
        end 
    end 
end 
addCommandHandler("tt", comando) 

Server:

function alJoin(v) 
     setElementCollisionsEnabled(v, not getElementCollisionsEnabled(v)) 
     end 
addEvent("alEntrar", true) 
addEventHandler("alEntrar", getRootElement(), alJoin) 

Link to comment
  • Administrators

Alguien lee la wiki estos días?

Note: Vehicles that are collisionless and have a driver will cause bugs.

Prueba seteando las colisiones del jugador tambien en false, todo server-side.

Link to comment

Vale tenia razon @Alexs_Steel, Ahora me va bien, pero continua un error, yo utilizo el comando, pero si algun auto aparece luego de que yo puse el comando, puedo chocarlo y debo escribir el comando otra vez, como podria hacer? Aqui el script

Client:

function sies(vehicle, v) 
        if isElementCollidableWith(vehicle, v) then 
        setElementCollidableWith(vehicle, v, false ) 
        else 
        setElementCollidableWith(vehicle, v, true) 
end 
end 
addEvent("buenaAlarma", true) 
addEventHandler("buenaAlarma", getRootElement(), sies) 
  
function noes(vehicle, v) 
     setElementCollidableWith(vehicle, v, true) 
end 
addEvent("falsaAlarma", true) 
addEventHandler("falseAlarma", getRootElement(), noes) 

Server:

function ghostmode_on(thePlayer) 
local x, y, z = getElementPosition ( thePlayer ) 
local city = getZoneName ( x, y, z, true ) 
local v = getPedOccupiedVehicle(thePlayer) 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do 
    if not (city == "Los Santos") then 
    outputChatBox("Debes estar en Los Santos",thePlayer) 
    triggerClientEvent("falsaAlarma", thePlayer, v, vehicle) 
    break 
    end 
    if (city == "Los Santos") then 
    triggerClientEvent("buenaAlarma", thePlayer, v, vehicle) 
    end 
end 
end 
addCommandHandler("ghostmode", ghostmode_on) 

Link to comment
  • Recently Browsing   0 members

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