di3g0 Posted August 23, 2021 Share Posted August 23, 2021 Hola bros tengo un script de comprar mariguana y una vez que me dan el objeto, si me acerco a comprar de vuelta aunque ya lo tenga ,la sigue comprando. (supongo que el objeto se duplica y se pone dentro del mismo objeto... aparte de gastar la plata en ese mismo objeto inutilmente) y yo quiero que solo la pueda comprar cuando ya no tenga el objeto. acá uno de los scripts: function buyWeed () local money = getPlayerMoney( source ) if money >= 180 then setPedAnimation( source,"DEALER", "shop_pay") takePlayerMoney(source, 180) animTimers[source] = setTimer(startSmokingWeed,4500,1,source) else outputChatBox( "Vuelve cuando tengas el dinero",source,200,0,0) end end addEvent("buyWeed", true) addEventHandler("buyWeed", root, buyWeed) si me ayudan con este podré arreglar otros de comidas y otros objetos que estoy agregandole... Link to comment
Administrators Tut Posted August 23, 2021 Administrators Share Posted August 23, 2021 Your thread has been moved into the Spanish scripting section, as this is not a Scripting tutorial Link to comment
di3g0 Posted August 23, 2021 Author Share Posted August 23, 2021 6 minutes ago, Tut said: Your thread has been moved into the Spanish scripting section, as this is not a Scripting tutorial Thank you! , I could not find the section, now I know for the next 1 Link to comment
Yamamoto Posted August 24, 2021 Share Posted August 24, 2021 weed = {} -- creamos una tabla para almacenar las compras function buyWeed () local money = getPlayerMoney( source ) if not weed[source] then -- comprobamos que no tengo una compra ya hecha if money >= 180 then local player = source weed[player] = true -- añadimos la compra a la tabla setPedAnimation(player ,"DEALER", "shop_pay") takePlayerMoney(player, 180) animTimers[player] = setTimer(startSmokingWeed,4500, 1, player) else outputChatBox( "Vuelve cuando tengas el dinero",source,200,0,0) end else outputChatBox( "Ya compraste weed",source,200,0,0) end end addEvent("buyWeed", true) addEventHandler("buyWeed", root, buyWeed) function startSmokingWeed(player) weed[player] = nil -- en tu funcion startSmokingWeed añade esta linea que elimina la compra end 1 Link to comment
di3g0 Posted August 26, 2021 Author Share Posted August 26, 2021 On 24/08/2021 at 17:42, Yamamoto said: weed = {} -- creamos una tabla para almacenar las compras function buyWeed () local money = getPlayerMoney( source ) if not weed[source] then -- comprobamos que no tengo una compra ya hecha if money >= 180 then local player = source weed[player] = true -- añadimos la compra a la tabla setPedAnimation(player ,"DEALER", "shop_pay") takePlayerMoney(player, 180) animTimers[player] = setTimer(startSmokingWeed,4500, 1, player) else outputChatBox( "Vuelve cuando tengas el dinero",source,200,0,0) end else outputChatBox( "Ya compraste weed",source,200,0,0) end end addEvent("buyWeed", true) addEventHandler("buyWeed", root, buyWeed) function startSmokingWeed(player) weed[player] = nil -- en tu funcion startSmokingWeed añade esta linea que elimina la compra end Gracias bro! no te imaginas la ayuda que me has dado este es un mod que tengo desde el 2019 sin poder solucionarle ese defecto jsjs Link to comment
di3g0 Posted August 27, 2021 Author Share Posted August 27, 2021 On 24/08/2021 at 17:42, Yamamoto said: On 24/08/2021 at 17:42, Yamamoto said: weed = {} -- creamos una tabla para almacenar las compras function buyWeed () local money = getPlayerMoney( source ) if not weed[source] then -- comprobamos que no tengo una compra ya hecha if money >= 180 then local player = source weed[player] = true -- añadimos la compra a la tabla setPedAnimation(player ,"DEALER", "shop_pay") takePlayerMoney(player, 180) animTimers[player] = setTimer(startSmokingWeed,4500, 1, player) else outputChatBox( "Vuelve cuando tengas el dinero",source,200,0,0) end else outputChatBox( "Ya compraste weed",source,200,0,0) end end addEvent("buyWeed", true) addEventHandler("buyWeed", root, buyWeed) function startSmokingWeed(player) weed[player] = nil -- en tu funcion startSmokingWeed añade esta linea que elimina la compra end Acabo de notar que si elimino el objeto y despues intento comprarlo de nuevo me sigue lanzando el mensaje 'Ya compraste weed' supongo que tendria que resetear la tabla o algo asi cuando borro el objeto, no? porque no deja comprar nuevamente, es como si siguiera detectando el 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