lLinux Posted April 15, 2014 Share Posted April 15, 2014 (edited) Hola a todos bueno, anteriormente me avia ayudado con un script para bloquear autos, pero lo que susede es que a ese script le tenia una funcion que añadia un bindKey cunado un player hacia spawn, el script funciona bien, pero quiero cambiar el "onPlayerSpawn" por cuando el resource se inicie, intente con "onResourceStart" pero me marca un error: Como estaba: function BloquearCarros(thePlayer, player) playervehicle=getPlayerOccupiedVehicle(thePlayer) if(playervehicle) then if playervehicle and getVehicleController ( playervehicle ) == thePlayer then if(isVehicleLocked(playervehicle)) then setVehicleLocked(playervehicle,false) triggerClientEvent( thePlayer, "unBlq", thePlayer) else setVehicleLocked(playervehicle,true) triggerClientEvent( thePlayer, "Blq", thePlayer) end end end end function exit(player,seat,jacked) if(isVehicleLocked(source)) then setVehicleLocked(source,false) triggerClientEvent( player, "unBlq", player) end end addEventHandler("onVehicleExit",getRootElement(),exit) addEventHandler("onPlayerSpawn", getRootElement(), function () bindKey( source, "L", "down", BloquearCarros) end) Como lo acomode: function BloquearCarros(thePlayer, player) playervehicle=getPlayerOccupiedVehicle(thePlayer) if(playervehicle) then if playervehicle and getVehicleController ( playervehicle ) == thePlayer then if(isVehicleLocked(playervehicle)) then setVehicleLocked(playervehicle,false) triggerClientEvent( thePlayer, "unBlq", thePlayer) else setVehicleLocked(playervehicle,true) triggerClientEvent( thePlayer, "Blq", thePlayer) end end end end function exit(player,seat,jacked) if(isVehicleLocked(source)) then setVehicleLocked(source,false) triggerClientEvent( player, "unBlq", player) end end addEventHandler("onVehicleExit",getRootElement(),exit) function ontelca(player) bindKey( player, "L", "down", BloquearCarros) end addEventHandler ( "onResourceStart", getRootElement(), ontelca ) Pero no me funciona. Edited April 15, 2014 by Guest Link to comment
Tomas Posted April 15, 2014 Share Posted April 15, 2014 Porfavor usa [ code=lua ] [ /code ] Y el debug que te da es? Link to comment
lLinux Posted April 15, 2014 Author Share Posted April 15, 2014 Porfavor usa [ code=lua ] [ /code ] Y el debug que te da es? ok brio Link to comment
BorderLine Posted April 15, 2014 Share Posted April 15, 2014 pasa que en onResourceStart, no tienes como definir player, debes hacer un for. function ontelca() local pla = getElementsByType('player') for key,val in ipairs(pla) do bindKey( val, "L", "down", BloquearCarros) end end addEventHandler ( "onResourceStart", getRootElement(), ontelca ) Link to comment
Tomas Posted April 15, 2014 Share Posted April 15, 2014 Ayer lo logró solucionar de la misma manera Link to comment
lLinux Posted April 15, 2014 Author Share Posted April 15, 2014 pasa que en onResourceStart, no tienes como definir player, debes hacer un for. function ontelca() local pla = getElementsByType('player') for key,val in ipairs(pla) do bindKey( val, "L", "down", BloquearCarros) end end addEventHandler ( "onResourceStart", getRootElement(), ontelca ) Gracias... oye porfavor, tu ya que sabes vastante de scripting me puedes ayudar con este: viewtopic.php?f=145&t=74223 Link to comment
Recommended Posts