Jovanny Posted July 2, 2012 Share Posted July 2, 2012 tengo un problema con esta funcion, mi problema es que no se ejecuta un "if", mas adelante lo puse function HaveTheMoneyForSelectedWeapon(selected) local m = getLocalMoney() local price = 0 local r = 0 if( selected == 0) then price = 15 elseif(selected == 1) then price = 30 elseif(selected == 2) then price = 30 elseif(selected == 3) then price = 500 elseif(selected == 4) then price = 30 elseif(selected == 5) then price = 100 elseif(selected == 6) then price = 600 elseif(selected == 7) then price = 15 elseif(selected == 8 ) then price = 800 elseif(selected == 9) then price = 500 elseif(selected == 10) then price = 800 elseif(selected == 11) then price = 900 elseif(selected == 12) then price = 1000 elseif(selected == 13) then price = 1500 elseif(selected == 14) then price = 1600 elseif(selected == 15) then price = 1000 elseif(selected == 16) then price = 1200 elseif(selected == 17) then price = 1200 elseif(selected == 18) then price = 1500 elseif(selected == 19) then price = 1500 elseif(selected == 20) then price = 2500 end if(m > price) then r = 1 end return r end cual es el error ? Esa funcion la uso así local ret = HaveTheMoneyForSelectedWeapon(selected) if( ret == 1) then triggerServerEvent("BuyWeapon", getLocalPlayer(), arma_id) outputChatBox("Test") else outputChatBox("#ff0000[ * ] ERROR: No tienes dinero suficiente") end Donde selected es el item seleccionado de un gridlist arma_id se le asigna un valor segun el item seleccionado no es nada que ver con la variable selected ya que si pongo lo de comprar el arma directamente si lo hace triggerServerEvent("BuyWeapon", getLocalPlayer(), arma_id) outputChatBox("Test") el problema es en la funcion HaveTheMoneyForSelectedWeapon pero no se cual... Link to comment
Castillo Posted July 2, 2012 Share Posted July 2, 2012 Lo que ve es que estas usando la funcion: getLocalMoney ( ), pero esa funcion no existe. local armas = { [ 0 ] = 15, [ 1 ] = 30, [ 2 ] = 30, [ 3 ] = 500, [ 4 ] = 30, [ 5 ] = 100, [ 6 ] = 600, [ 7 ] = 15, [ 8 ] = 800, [ 9 ] = 500, [ 10 ] = 800, [ 11 ] = 900, [ 12 ] = 1000, [ 13 ] = 1500, [ 14 ] = 1600, [ 15 ] = 1000, [ 16 ] = 1200, [ 17 ] = 1200, [ 18 ] = 1500, [ 19 ] = 1500, [ 20 ] = 2500 } function HaveTheMoneyForSelectedWeapon ( selected ) local m = getPlayerMoney ( ) local price = armas [ tonumber ( selected ) ] return ( m >= price and 1 or 0 ) end Cambie tu script bastante, no era necesario, pero me parecio mas facil. Link to comment
Jovanny Posted July 2, 2012 Author Share Posted July 2, 2012 No hay problema, igual le entiendo, lo que hiciste fue enumerarlos en un array, gracias y no sabia que no existia esa funcion, por cierto "selected" ya es pasado como integer, gracias ya sirve... Link to comment
Recommended Posts