RottenFlesh Posted September 15, 2011 Share Posted September 15, 2011 Hola a todos... Hace algun tiempo hice un script que crea puertas moviles con un bind y un timer para que vuelvan a su sitio, pero he notado que al presionar el bind varias veces antes que abra por completo cada vez que se presiona va mas lenta la puerta, y como cada vez se hace un timer entoces al cerrarse tambien se ponen lentas asi que quisiera que me ayudaran a que solo se pueda hacer una vez el bind y se desactive y luego se vuelva a activar el bind cuando la puerta ya haya empezado a cerrarse... aca el codigo, es server side -- Este es solo una parte de el codigo, lo demas son mas puertas, colshapes y timers addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function () LSPD_gate = createObject(980, 1545.7392578125, -1627.7275390625, 15.206203460693, 0, 0, 90) LSPD_col = createColSphere (1545.7392578125, -1627.7275390625, 15.206203460693, 10) FBI_gate = createObject(2938, 1269.6904296875, -1842.349609375, 15.187080383301, 0, 0, 90) FBI_col = createColSphere(1269.6904296875, -1842.349609375, 14.187080383301, 10) FBI_gate2 = createObject(2938, 1213.5595703125, -1842.537109375, 15.187080383301, 0, 0, 90) FBI_col2 = createColSphere(1213.5595703125, -1842.537109375, 14.187080383301, 10) --[[ ... ]] end) addEventHandler("onPlayerLogin", root, function () bindKey(source, "crouch", "down", moving, source) bindKey(source, "horn", "down", moving, source) end) function moving (player) local team = getPlayerTeam(player) if (isElementWithinColShape(player, LSPD_col) == true and team == getTeamFromName("Los Santos PD")) then moveObject(LSPD_gate, 3000, 1545.7392578125, -1627.7275390625, 20.581121444702) setTimer(moveObject, 7000, 1, LSPD_gate, 3000, 1545.7392578125, -1627.7275390625, 15.206203460693) elseif (isElementWithinColShape(player, FBI_col) == true and team == getTeamFromName("FBI")) then moveObject(FBI_gate, 2000, 1269.6904296875, -1842.349609375, 19.887008666992) setTimer(moveObject, 7000, 1, FBI_gate, 2000, 1269.6904296875, -1842.349609375, 15.187080383301) elseif (isElementWithinColShape(player, FBI_col2) == true and team == getTeamFromName("FBI")) then moveObject(FBI_gate2, 2000, 1213.5595703125, -1842.537109375, 19.887008666992) setTimer(moveObject, 7000, 1, FBI_gate2, 2000, 1213.5595703125, -1842.537109375, 15.187080383301) --[[ ... ]] Lo peor es que me ha dado un cevero bloqueo mental y no se me ocurre nada he intentado algunas cosas pero no me funcionaron, el mayor problema es que son muchas puertas... me ayudan porfavor? Link to comment
Castillo Posted September 15, 2011 Share Posted September 15, 2011 -- Este es solo una parte de el codigo, lo demas son mas puertas, colshapes y timers addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function () movingGates = {} LSPD_gate = createObject(980, 1545.7392578125, -1627.7275390625, 15.206203460693, 0, 0, 90) LSPD_col = createColSphere (1545.7392578125, -1627.7275390625, 15.206203460693, 10) FBI_gate = createObject(2938, 1269.6904296875, -1842.349609375, 15.187080383301, 0, 0, 90) FBI_col = createColSphere(1269.6904296875, -1842.349609375, 14.187080383301, 10) FBI_gate2 = createObject(2938, 1213.5595703125, -1842.537109375, 15.187080383301, 0, 0, 90) FBI_col2 = createColSphere(1213.5595703125, -1842.537109375, 14.187080383301, 10) --[[ ... ]] end) addEventHandler("onPlayerLogin", root, function () bindKey(source, "crouch", "down", moving, source) bindKey(source, "horn", "down", moving, source) end) function moving (player) local team = getPlayerTeam(player) if (isElementWithinColShape(player, LSPD_col) == true and not movingGates[LSPD_gate] and team == getTeamFromName("Los Santos PD")) then moveObject(LSPD_gate, 3000, 1545.7392578125, -1627.7275390625, 20.581121444702) movingGates[LSPD_gate] = true setTimer(moveObject, 7000, 1, LSPD_gate, 3000, 1545.7392578125, -1627.7275390625, 15.206203460693) setTimer(function () movingGates[LSPD_gate] = false end, 7000, 1) elseif (isElementWithinColShape(player, FBI_col) == true and not movingGates[FBI_gate] and team == getTeamFromName("FBI")) then movingGates[FBI_gate] = true moveObject(FBI_gate, 2000, 1269.6904296875, -1842.349609375, 19.887008666992) setTimer(moveObject, 7000, 1, FBI_gate, 2000, 1269.6904296875, -1842.349609375, 15.187080383301) setTimer(function () movingGates[FBI_gate] = false end, 7000, 1) elseif (isElementWithinColShape(player, FBI_col2) == true and not movingGates[FBI_gate2] and team == getTeamFromName("FBI")) then movingGates[FBI_gate2] = true moveObject(FBI_gate2, 2000, 1213.5595703125, -1842.537109375, 19.887008666992) setTimer(moveObject, 7000, 1, FBI_gate2, 2000, 1213.5595703125, -1842.537109375, 15.187080383301) setTimer(function () movingGates[FBI_gate2] = false end, 7000, 1) --[[ ... ]] Con eso deberia funcionar, pero el problema es que 7 segundos no tarda en cerrarse la puerta, que yo sepa. Link to comment
RottenFlesh Posted September 17, 2011 Author Share Posted September 17, 2011 Muchas gracias funciona como deberia Link to comment
Recommended Posts