Jump to content

ayuda con mi primer script


-Gus-

Recommended Posts

Posted

bueno, hice mi primer script ayudandome con la wiki, y me funciono, pero no como yo esperaba

les explico, lo que quiero hacer es que cuando en modo race, cambie de vehiculo mediante un pickup, me diera unas ruedas, y lo que hace el script es darme las ruedas cuando un mapa se inicia, pero cuando cambio de vehiculo mediante pickup, vuelve a las ruedas por defecto.

el script es este:

theVehicle = getPedOccupiedVehicle () 
addEventHandler("onClientVehicleEnter", getRootElement(), 
function(thePlayer, seat) 
if thePlayer == getLocalPlayer() then 
addVehicleUpgrade( theVehicle, 1075 ) 
end 
end 
) 

Posted

onClientVehicleEnter es cuando entras al vehiculo, no cuando cambias su ID, y cuando el vehiculo cambia su ID, las ruedas se ponen a las preterminadas.

Podrías detectar cuando la ID del vehiculo ha cambiado:

setTimer ( function () 
    vehicle = getPedOccupiedVehicle ( getLocalPlayer () ) 
    currentWheel = getElementModel ( vehicle ) 
    if oldCurrentWheel == currentWheel then 
                 --aquí no pones nada 
    else 
                 addVehicleUpgrade( vehicle, 1075 ) 
    end 
    oldCurrentWheel = getElementModel ( vehicle ) 
end, 100, 0 ) 

"Everything exists, because otherwise nothing would", Bob Marley, 2015.

Posted

a ver si entendi todo...

    setTimer ( function () --setTimer para crear un delay entre el momento en que cambia en ID y cuando te da las ruedas 
        vehicle = getPedOccupiedVehicle ( getLocalPlayer () ) --vehicle = obtener el vehiculo actual 
        currentWheel = getElementModel ( vehicle ) --currentWheel = el modelo actual ( del vehiculo ) 
        if oldCurrentWheel == currentWheel then -- si el modelo viejo es igual al actual entonces... 
                     --no hacer nada 
        else --pero si es distinto 
                     addVehicleUpgrade( vehicle, 1075 ) --agregarle a "vehicle" las ruedas 1075 
        end 
        oldCurrentWheel = getElementModel ( vehicle ) --oldCurrentwheel = el vehiculo actual  
    end, 100, 0 ) --delay de 100 ms. 

Posted

Me pregunto, para que esta el evento: onPlayerPickUpRacePickup si no lo usan?

-- server side:

addEventHandler("onPlayerPickUpRacePickup",root, 
function (pickupID, pickupType, vehicleModel) 
    if (pickupType == "vehiclechange") then 
        local theVehicle = getPedOccupiedVehicle(source) 
                addVehicleUpgrade(theVehicle, 1075) 
    end 
end) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Ni yo, pero ultimamente me estan contratando para scripts de race, asi que tengo que saber que eventos existen :P.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yo que vos uso el mio (no es por sea mejor o algo parecido), pero es mas simple.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Eso es lo que yo entendi que querias, me equivoque?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

lo que queria son las dos cosas, es decir, iniciar el mapa con esas ruedas, y que cuando agarre el pickup no cambien, porque al cambiar de vehiculo vuelve a las por defecto. Se podria hacer una combinacion de lo que hice yo y lo que hiciste vos, que me de las ruedas "onClientVehicleEnter" y "onPlayerPickUpRacePickup"

Posted
   setTimer ( function () --setTimer para crear un delay entre el momento en que cambia en ID y cuando te da las ruedas 
        vehicle = getPedOccupiedVehicle ( getLocalPlayer () ) --vehicle = obtener el vehiculo actual 
        if (not vehicle) then return end 
        currentWheel = getElementModel ( vehicle ) --currentWheel = el modelo actual ( del vehiculo ) 
        if oldCurrentWheel == currentWheel then -- si el modelo viejo es igual al actual entonces... 
                     --no hacer nada 
        else --pero si es distinto 
                     addVehicleUpgrade( vehicle, 1075 ) --agregarle a "vehicle" las ruedas 1075 
        end 
        oldCurrentWheel = getElementModel ( vehicle ) --oldCurrentwheel = el vehiculo actual 
    end, 100, 0 ) --delay de 100 ms. 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
   setTimer ( function () --setTimer para crear un delay entre el momento en que cambia en ID y cuando te da las ruedas 
        if not isPedInVehicle ( getLocalPlayer() ) then return end 
        vehicle = getPedOccupiedVehicle ( getLocalPlayer () ) --vehicle = obtener el vehiculo actual 
        currentWheel = getElementModel ( vehicle ) --currentWheel = el modelo actual ( del vehiculo ) 
        if oldCurrentWheel == currentWheel then -- si el modelo viejo es igual al actual entonces... 
                     --no hacer nada 
        else --pero si es distinto 
                     addVehicleUpgrade( vehicle, 1075 ) --agregarle a "vehicle" las ruedas 1075 
        end 
        oldCurrentWheel = getElementModel ( vehicle ) --oldCurrentwheel = el vehiculo actual 
    end, 100, 0 ) --delay de 100 ms. 

"Everything exists, because otherwise nothing would", Bob Marley, 2015.

  • Recently Browsing   0 members

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