sthprk Posted March 22, 2020 Share Posted March 22, 2020 (edited) Buenas gente , tengo una función con bindkey de crear un objeto bolsita de weed , otra funcion de crear objeto hojillas , y otra funcion de crear objeto cigarro le puse un bindkey al objeto hojilla para llamar y crear el objeto cigarro , Asi que si tengo las hojillas puedo crear el cigarro , sin tener que necesitar el objeto weed pero quiero que tengas que tener la weed y las hojillas para que te deje crear el cigarro sinó ni gracia pero no me sale una ayudita? acá mi intento xdd local hojillas1 = { } local cooldowns = { } local syncTimer = { } function starthojillas1 ( thePlayer ) setElementData ( thePlayer, "hojillas1", not getElementData ( thePlayer, "hojillas1" ) ) if hojillas1[thePlayer] == nil and not isTimer(cooldowns[thePlayer]) then setElementData ( thePlayer, "bolsitaweed", not getElementData ( thePlayer, "bolsitaweed" ) ) if isElement( starthojillas1 ) and getElementType( startbolsitaweed ) == "player" then unbindKey( thePlayer, "F","down", "fumarmariguanadmps" ) end Edited March 22, 2020 by sthprk Link to comment
Motar2k Posted March 23, 2020 Share Posted March 23, 2020 Hay una data que almacena la cantidad de weed? Link to comment
sthprk Posted March 23, 2020 Author Share Posted March 23, 2020 (edited) 3 hours ago, Motar2k said: Hay una data que almacena la cantidad de weed? Sip , tiene setelementdata solo no se como agregarle aca local bolsitaweed = { } local cooldowns = { } local syncTimer = { } function startbolsitaweed ( thePlayer ) if isPedInVehicle(thePlayer) then return end setElementData ( thePlayer, "bolsitaweed", not getElementData ( thePlayer, "bolsitaweed" ) ) -- setElementData data.s ( thePlayer, "bolsitaweed", not data.g ( thePlayer, "bolsitaweed" ) ) if bolsitaweed[thePlayer] == nil and not isTimer(cooldowns[thePlayer]) then --bindKey( thePlayer, "num_sub","down", "stopbolsitaweed" ) cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) -- Create weed local bolsetaweed = createObject(2663, 0,0,0) setObjectScale ( bolsetaweed, 0.2) bolsitaweed[thePlayer] = bolsetaweed --exports.bone_attach:attachElementToBone(bear,thePlayer,12, 0.26, 0.01, 0.16, 255, -9000, 90) exports.bone_attach:attachElementToBone(bolsetaweed,thePlayer,12, -0.04, 0.03, 0.1, 0, 180, 90) end end addCommandHandler("bolsitaweed", startbolsitaweed ) ----------------------------------fumar weed function smokeWeedDrag( thePlayer ) setElementData ( thePlayer, "bolsitaweed", not getElementData ( thePlayer, "bolsitaweed" ) ) getElementData( thePlayer, "bolsitaweed" ) data.spa( thePlayer, "GANGS", "smkcig_prtl", 0, false, true, false, true ) if getElementData(thePlayer, "bolsitaweed") then end addCommandHandler( "smokeweed_drag", smokeWeedDrag ) --------------------------------------------- function stophojillas1( thePlayer ) -- Unbind control keys unbindKey( thePlayer, "F","down", "fumarmariguanadmps" )-- if isElement(hojillas1[thePlayer]) then --setPedAnimation( thePlayer, "BASEBALL", "Bat_M", -1, false, true, true, false ) end setTimer( function() data.spa ( thePlayer ) if isElement(hojillas1[thePlayer]) then -- Free memory destroyElement (hojillas1[thePlayer]) hojillas1[thePlayer]=nil end end, 450, 1) end addCommandHandler( "stophojillas1", stophojillas1 ) Edited March 23, 2020 by sthprk Link to comment
Motar2k Posted March 23, 2020 Share Posted March 23, 2020 Para que utiliza lo seleccionado en la imagen y ya intentaste usar "getElementData(thePlayer, "bolsitaweed")" dentro del if de la linea 10? Link to comment
sthprk Posted March 23, 2020 Author Share Posted March 23, 2020 eso es el mismo codigo xd no le habia puesto el -- de comentar le puse el getElementData no se si tengan algo que ver los binds , porque activa el cigaro desde las hojillas desde los binds ... asi tengo en esta funcion: local bolsitaweed = { } -- tablas local cooldowns = { } local syncTimer = { } function startbolsitaweed ( thePlayer ) getElementData ( thePlayer, "bolsitaweed" ) -- setElementData borar if isPedInVehicle(thePlayer) then return end -- cancela la funcion si está en un vehiculo. if bolsitaweed[thePlayer] == nil and not getElementData(thePlayer, "bolsitaweed") and not isTimer(cooldowns[thePlayer]) then --bindKey( thePlayer, "F","down", "startbolsitaweed" ) bindKey( thePlayer, "H","down", "startbolsitaweed" ) -- Anim in --setPedAnimation( thePlayer, "GANGS", "drnkbr_prtl", 0, false, true, false, true ) --setTimer( function() -- setElementHealth ( thePlayer, getElementHealth(thePlayer) +4 )--- --end, 2000, 1) cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) Despues la otra de la hojillas: function starthojillas1 ( thePlayer ) if isPedInVehicle(thePlayer) then return end -- Bink keys to control bindKey( thePlayer, "F","down", "fumarmariguanadmps" ) cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) Link to comment
Motar2k Posted March 24, 2020 Share Posted March 24, 2020 1 hour ago, sthprk said: eso es el mismo codigo xd no le habia puesto el -- de comentar le puse el getElementData no se si tengan algo que ver los binds , porque activa el cigaro desde las hojillas desde los binds ... asi tengo en esta funcion: local bolsitaweed = { } -- tablas local cooldowns = { } local syncTimer = { } function startbolsitaweed ( thePlayer ) getElementData ( thePlayer, "bolsitaweed" ) -- setElementData borar if isPedInVehicle(thePlayer) then return end -- cancela la funcion si está en un vehiculo. if bolsitaweed[thePlayer] == nil and not getElementData(thePlayer, "bolsitaweed") and not isTimer(cooldowns[thePlayer]) then --bindKey( thePlayer, "F","down", "startbolsitaweed" ) bindKey( thePlayer, "H","down", "startbolsitaweed" ) -- Anim in --setPedAnimation( thePlayer, "GANGS", "drnkbr_prtl", 0, false, true, false, true ) --setTimer( function() -- setElementHealth ( thePlayer, getElementHealth(thePlayer) +4 )--- --end, 2000, 1) cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) Despues la otra de la hojillas: function starthojillas1 ( thePlayer ) if isPedInVehicle(thePlayer) then return end -- Bink keys to control bindKey( thePlayer, "F","down", "fumarmariguanadmps" ) cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) Ahora estas negando en el if estas poniendo si no tiene bolsitaweed Link to comment
sthprk Posted March 29, 2020 Author Share Posted March 29, 2020 nop, sigue sin andar ya intenté todo ,pegaria la biblia de comentadas de codigo que tengo pero :s , y el ejemplo de la wiki no hizo mas que confundirme lo cambié asi pero no anda tampoco xd function starthojillas1 ( thePlayer ) setElementData ( thePlayer, "hojillas1", getElementData ( thePlayer, "hojillas1" ) ) --if hojillas1[thePlayer] == nil and not getElementData ( thePlayer, "bolsitaweed" ) and not isTimer(cooldowns[thePlayer]) then -- Activar las funciones con una tecla usando bindkey --bindKey( thePlayer, "F","down", "fumarmariguanadmps" ) --bindKey( thePlayer, "num_sub","down", "stophojillas1" ) --cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) if (getElementData(thePlayer,"hojillas1") == true and getElementData(thePlayer,"bolsitaweed") then--------------------------------------------------------- getElementData(thePlayer, "bolsitaweed", true) bindKey (thePlayer, "F","down", "fumarmariguanadmps") print("con weed ") else if getElementData(thePlayer,"hojillas1") == true and not getElementData(thePlayer,"bolsitaweed") then----------------------------------------------------- getElementData(thePlayer, "bolsitaweed", false) unbindKey (thePlayer, "F","down", "fumarmariguanadmps") print("sin weed ") end end Link to comment
Motar2k Posted March 29, 2020 Share Posted March 29, 2020 (edited) 21 hours ago, sthprk said: nop, sigue sin andar ya intenté todo ,pegaria la biblia de comentadas de codigo que tengo pero :s , y el ejemplo de la wiki no hizo mas que confundirme lo cambié asi pero no anda tampoco xd function starthojillas1 ( thePlayer ) setElementData ( thePlayer, "hojillas1", getElementData ( thePlayer, "hojillas1" ) ) --if hojillas1[thePlayer] == nil and not getElementData ( thePlayer, "bolsitaweed" ) and not isTimer(cooldowns[thePlayer]) then -- Activar las funciones con una tecla usando bindkey --bindKey( thePlayer, "F","down", "fumarmariguanadmps" ) --bindKey( thePlayer, "num_sub","down", "stophojillas1" ) --cooldowns[thePlayer] = setTimer( function() end, 3000, 1 ) if (getElementData(thePlayer,"hojillas1") == true and getElementData(thePlayer,"bolsitaweed") then--------------------------------------------------------- getElementData(thePlayer, "bolsitaweed", true) bindKey (thePlayer, "F","down", "fumarmariguanadmps") print("con weed ") else if getElementData(thePlayer,"hojillas1") == true and not getElementData(thePlayer,"bolsitaweed") then----------------------------------------------------- getElementData(thePlayer, "bolsitaweed", false) unbindKey (thePlayer, "F","down", "fumarmariguanadmps") print("sin weed ") end end Te hare uno y tu lo adaptas a tu servidor Quieres que al usar un cmd se cree una hojilla, despues con un bindkey crear el cigarro sin embargo para que esto suceda necesitas tener weed. Solo confirma si es correcto para mandar el codigo. Edited March 29, 2020 by Motar2k Link to comment
sthprk Posted March 29, 2020 Author Share Posted March 29, 2020 1 hour ago, Motar2k said: Te hare uno y tu lo adaptas a tu servidor Quieres que al usar un cmd se cree una hojilla, despues con un bindkey crear el cigarro sin embargo para que esto suceda necesitas tener weed. Solo confirma si es correcto para mandar el codigo. Exacto amigo eso mismo quiero por las dudas te digo que ya tengo una funcion para comprar las hojillas y luego llamar a la función de ponerle las hojillas en la mano y es esta: local animTimers = {} -- Tabla , almacena datos function buyHojillas () -- Pie para dar comienzo a la función. local money = getPlayerMoney( source ) -- Devuelve la cantidad de dinero que un jugador tiene actualmente. if money >= 45 then -- si el dinero es mayor o igual a $45 entonces... setPedAnimation( source,"DEALER", "shop_pay", -1, false, true, true, false) -- Hace una animacion. takePlayerMoney(source, 45) -- Y quita $45 del Player animTimers[source] = setTimer(starthojillas1,4500,1,source) -- llama a la función: starthojillas1 , luego de 4.5 segundos. Link to comment
Motar2k Posted March 30, 2020 Share Posted March 30, 2020 No esta testado hojillas = {}; cigarros = {}; timers = {}; function crearHojilla(player) if not isPedInVehicle(player) then if getElementData(player, "hojillas") and hojillas[player] == nil and cigarros[player] == nil then hojillas[player] = createObject(model,x,y,z);--creando objeto y almacenandolo bindKey(player, "F","down", crearCigarro);--creando bind para llamar funcion crearCigarro bindKey(player, "X","down", pararWeed);--creando bind para llamar funcion pararWeed end end end addCommandHandler("crearHojilla", crearHojilla) function crearCigarro(player) if not isPedInVehicle(player) then if getElementData(player, "hojillas") and getElementData(player, "bolsitaweed") then destroyElement(hojillas[player])--destruyendo hojilla cigarros[player] = createObject(model,x,y,z);--creando cigarro unbindKey(player, "F","down", crearCigarro);--quitando bind de crearCigarro bindKey(player, "F","down", fumarCigarro);--creando bind para llamar funcion fumarCigarro end end end function fumarCigarro(player) --codigo al fumar removeElementData(player, "hojillas")--quitando hojilla removeElementData(player, "bolsitaweed")--quitando bolsitaweed end function pararWeed(player) if hojillas[player] and isElement(hojillas[player]) then destroyElement(hojillas[player]); hojillas[player] = nil; end if cigarros[player] and isElement(cigarros[player]) then destroyElement(cigarros[player]); cigarros[player] = nil; end unbindKey(player, "F","down", crearCigarro); unbindKey(player, "X","down", pararWeed); end Link to comment
sthprk Posted March 30, 2020 Author Share Posted March 30, 2020 4 hours ago, Motar2k said: No esta testado hojillas = {}; cigarros = {}; timers = {}; function crearHojilla(player) if not isPedInVehicle(player) then if getElementData(player, "hojillas") and hojillas[player] == nil and cigarros[player] == nil then hojillas[player] = createObject(model,x,y,z);--creando objeto y almacenandolo bindKey(player, "F","down", crearCigarro);--creando bind para llamar funcion crearCigarro bindKey(player, "X","down", pararWeed);--creando bind para llamar funcion pararWeed end end end addCommandHandler("crearHojilla", crearHojilla) function crearCigarro(player) if not isPedInVehicle(player) then if getElementData(player, "hojillas") and getElementData(player, "bolsitaweed") then destroyElement(hojillas[player])--destruyendo hojilla cigarros[player] = createObject(model,x,y,z);--creando cigarro unbindKey(player, "F","down", crearCigarro);--quitando bind de crearCigarro bindKey(player, "F","down", fumarCigarro);--creando bind para llamar funcion fumarCigarro end end end function fumarCigarro(player) --codigo al fumar removeElementData(player, "hojillas")--quitando hojilla removeElementData(player, "bolsitaweed")--quitando bolsitaweed end function pararWeed(player) if hojillas[player] and isElement(hojillas[player]) then destroyElement(hojillas[player]); hojillas[player] = nil; end if cigarros[player] and isElement(cigarros[player]) then destroyElement(cigarros[player]); cigarros[player] = nil; end unbindKey(player, "F","down", crearCigarro); unbindKey(player, "X","down", pararWeed); end no me funciono, me daba error en el argumento player , le cambie por thePlayer y despues no me aparecian los objetos en la mano a menos que pusiera la linea esta : if getElementData(player, "hojillas") and getElementData(player, "bolsitaweed") then de esta forma por ejemplo: if weed[thePlayer] == nil and not getElementData(thePlayer, "bolsitaweed") and not getElementData(thePlayer, "hojillas1") then osea si le saco el not a uno de esos ya no aparece ningun objeto .-. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now