Jump to content

Crear script para bloquear y desbloquear autos?


lLinux

Recommended Posts

Posted

Hola a todos lo que susede es que estoy creando un script para bloquear y desbloquear autos pero esto es lo que hice:

function BloquearCarros(thePlayer) 
    playervehicle=getPlayerOccupiedVehicle(thePlayer) 
    if(playervehicle) then 
        if(isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false) 
            outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",thePlayer,255,0,0, true) 
        else 
            setVehicleLocked(playervehicle,true) 
            outputChatBox("#AFAFAF[VEHICULO] #FFFFFFBLOQUEADO",thePlayer,255,0,0, true) 
        end 
    end 
end 
bindKey( "L", "down", BloquearCarros) 

pero me dice que el bindKey tiene un mal argumento, no creo que sea por que la L esta en mayuscula ya que tambien intente con minuscula.

Skype: HackerlLinux

¿Quieres aprender scripting para MTA? - http://www.scriptingmtasa.wordpress.com

"La disciplina es la clave del exito"

Posted

bindKey server-side como primer argumento necesita un elemento de jugador.

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
bindKey server-side como primer argumento necesita un elemento de jugador.
function BloquearCarros(thePlayer) 
    playervehicle=getPlayerOccupiedVehicle(thePlayer) 
    if(playervehicle) then 
        if(isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false) 
            outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",thePlayer,255,0,0, true) 
        else 
            setVehicleLocked(playervehicle,true) 
            outputChatBox("#AFAFAF[VEHICULO] #FFFFFFBLOQUEADO",thePlayer,255,0,0, true) 
        end 
    end 
end 
bindKey( thePlayer, "L", "down", BloquearCarros) 

Asi? le intente y nada me dice lo mismo.

Skype: HackerlLinux

¿Quieres aprender scripting para MTA? - http://www.scriptingmtasa.wordpress.com

"La disciplina es la clave del exito"

  • MTA Team
Posted

thePlayer no está definido en tu bindkey. Solo existe en tu función.

DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp

 
Posted
thePlayer no está definido en tu bindkey. Solo existe en tu función.

Ya lo logre

function BloquearCarros(thePlayer, player) 
    playervehicle=getPlayerOccupiedVehicle(thePlayer) 
        if(playervehicle) then 
            if(isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false) 
            outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",thePlayer,255,0,0, true) 
        else 
            setVehicleLocked(playervehicle,true) 
            outputChatBox("#AFAFAF[VEHICULO] #FFFFFFBLOQUEADO",thePlayer,255,0,0, true) 
            end 
        end 
end 
  
  
function exit(player,seat,jacked) 
    if(isVehicleLocked(source)) then 
        setVehicleLocked(source,false) 
        outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",player,255,0,0, true) 
    end 
end 
 addEventHandler("onVehicleExit",getRootElement(),exit) 
  
  
 addEventHandler("onPlayerSpawn", getRootElement(), 
 function () 
    bindKey( source, "L", "down", BloquearCarros) 
 end) 

Skype: HackerlLinux

¿Quieres aprender scripting para MTA? - http://www.scriptingmtasa.wordpress.com

"La disciplina es la clave del exito"

Posted

El tema es que si no le das unbindKey, entonces se te pondra el bind varias veces.

Te sugiero que lo pongas al unirse el jugador y al iniciar el recurso para todos los jugadores.

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
El tema es que si no le das unbindKey, entonces se te pondra el bind varias veces.

Te sugiero que lo pongas al unirse el jugador y al iniciar el recurso para todos los jugadores.

Mira como hice el script:

SERVER-SIDE:

function BloquearCarros(thePlayer, player) 
    playervehicle=getPlayerOccupiedVehicle(thePlayer) 
        if(playervehicle) then 
            if playervehicle and getVehicleController ( playervehicle ) == thePlayer then 
            if(isVehicleLocked(playervehicle)) then 
            setVehicleLocked(playervehicle,false) 
            --outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",thePlayer,255,0,0, true) 
            triggerClientEvent( getRootElement(), "unBlq", thePlayer) 
        else 
            setVehicleLocked(playervehicle,true) 
           --outputChatBox("#AFAFAF[VEHICULO] #FFFFFFBLOQUEADO",thePlayer,255,0,0, true) 
            triggerClientEvent( getRootElement(), "Blq", thePlayer) 
            end 
            end 
        end 
end 
  
  
function exit(player,seat,jacked) 
    if(isVehicleLocked(source)) then 
        setVehicleLocked(source,false) 
        --outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",player,255,0,0, true) 
        triggerClientEvent( getRootElement(), "unBlq", player) 
    end 
end 
 addEventHandler("onVehicleExit",getRootElement(),exit) 
  
  
 addEventHandler("onPlayerSpawn", getRootElement(), 
 function () 
    bindKey( source, "L", "down", BloquearCarros) 
 end) 

CLIENT-SIDE:

  
IMGURL = "images/lock.png" 
dxText = "Vehiculo bloqueado" 
  
sx, sy = guiGetScreenSize() 
  
Rec1_x = 561/sx 
Rec1_y = 726/sy 
Rec2_x = 562/sx 
Rec2_y = 727/sy 
Text_x = 570/sx 
Text_y = 742/sy 
IMG_x = 585/sx 
IMG_y = 731/sy 
  
  
function Bloqueado() 
    addEventHandler("onClientRender", root, gui1) 
    dxText = "Vehiculo bloqueado" 
    IMGURL = "images/lock.png" 
    t1 = setTimer(removeGui, 5000, 1) 
    killTimer(t2) 
    sonido() 
end 
addEvent("Blq", true) 
addEventHandler("Blq", getRootElement(), Bloqueado) 
  
function DesBloqueado() 
    addEventHandler("onClientRender", root, gui1) 
    dxText = "Vehiculo desbloqueado" 
    IMGURL = "images/unlock.png" 
    t2 = setTimer(removeGui, 5000, 1) 
    killTimer(t1) 
    sonido() 
end 
addEvent("unBlq", true) 
addEventHandler("unBlq", getRootElement(), DesBloqueado) 
  
function removeGui() 
    removeEventHandler("onClientRender", root, gui1) 
end 
  
function sonido() 
    if getLocalPlayer() then 
        local sound = playSound("sounds/sonido.mp3") --Play wasted.mp3 from the sounds folder 
        setSoundVolume(sound, 0.5) 
    end 
end 
  
  
  
    function gui1() 
        dxDrawRectangle(sx*Rec1_x, sy*Rec1_y, 234, 43, tocolor(0, 0, 0, 50), true) --561, 726, 234, 43 
        dxDrawRectangle(sx*Rec2_x, sy*Rec2_y, 232, 41, tocolor(0, 0, 0, 160), true) --562, 727, 232, 41 
        dxDrawText(dxText, sx*Text_x, sy*Text_y, 814, 758, tocolor(255, 69, 59, 255), 1.00, "default-bold", "center", "top", false, false, true, false, false) --570, 742, 814, 758 
        dxDrawImage(sx*IMG_x, sy*IMG_y, 37, 34, IMGURL, 0, 0, 0, tocolor(255, 255, 255, 255), true) --585, 731, 37, 34 
    end 
  

El error que tengo ahora es que cuando ponen L en ves de aparecerle el dxDraw al local player le aparece a todos y el sonido igual, si me puedes ayudar te lo agradeceria mucho y me puedes decir que otros errores tiene.

Skype: HackerlLinux

¿Quieres aprender scripting para MTA? - http://www.scriptingmtasa.wordpress.com

"La disciplina es la clave del exito"

  • MTA Team
Posted

Es porque estas usando getRootElement en tu trigger:

triggerClientEvent( getRootElement(), "unBlq", thePlayer) 

DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp

 
Posted

Si, ya lo ayude en otro tema que creo.

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.

  • MTA Team
Posted

Si recién me doy cuenta, lei este primero xD.

Tema Bloqueado.

DevOps Engineer, Cloud Advocate & Security Engineer(Red Team) | Coffee, Containers & Burp

 
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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