Kilfwan Posted August 15, 2015 Posted August 15, 2015 Hola, estaba creando un shop de DayZ pero al comprar me sale esto: ERROR: shopserver.lua:3: attempt to compare number with nil Probe con un comando, y si funciono pero lo puse para cuando aplaste el boton pero me tira ese error Este es el codigo: function czWeapon() local coin = exports.coinsystem:getPlayerCoin(source) if ( coin >= 150 ) then setElementData(source,"CZ 550",getElementData(source,"CZ 550") + 1) setElementData(source,"CZ 550 Mag",getElementData(source,"CZ 550 Mag") + 25) exports.coinsystem:takePlayerCoin(source, 150) outputChatBox("Comprastes una CZ 550 Por 150 coins", source, 0, 255, 0, false) else outputChatBox("No tienes coins!", source, 255, 0, 0, false) end end addEvent("armacz", true) addEventHandler("armacz", getRootElement(), czWeapon) Nose si hice algo mal o algo NaciónZ Developing server to the 65 %
Castillo Posted August 15, 2015 Posted August 15, 2015 Quiere decir que "coin" no tiene ningun dato, osea nil. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
aka Blue Posted August 15, 2015 Posted August 15, 2015 ¿No es getPlayerCoins? Si es el sistema de Enargy, en su propio post en la comunidad te da los exports.
Kilfwan Posted August 15, 2015 Author Posted August 15, 2015 Quiere decir que "coin" no tiene ningun dato, osea nil. Use un comando y si me dio los coins y yo solo copie y edite ese codigo y este es el original: function buyWeapon(thePlayer, command) local prize = 20000 local mycoins = exports.coinsystem:getPlayerCoin(thePlayer) if ( mycoins >= tonumber(prize) ) then giveWeapon(thePlayer, 31, 2000) exports.coinsystem:takePlayerCoin(thePlayer, prize) outputChatBox("you bought a M4.", thePlayer, 0, 255, 0, false) else outputChatBox("you don't have enough coins!", thePlayer, 255, 0, 0, false) end end addCommandHandler("buyw", buyWeapon) NaciónZ Developing server to the 65 %
aka Blue Posted August 15, 2015 Posted August 15, 2015 Tú has puesto source. Pon thePlayer en la función y thePlayer en el export.
Kilfwan Posted August 16, 2015 Author Posted August 16, 2015 function comprar() local row = guiGridListGetSelectedItem(shopp) local name = guiGridListGetItemText(shopp, row, columna) if name == "CZ 550" then triggerServerEvent("armacz", resourceRoot) end end No creo que este mal NaciónZ Developing server to the 65 %
Castillo Posted August 16, 2015 Posted August 16, 2015 triggerServerEvent("armacz", resourceRoot) Cambia 'resourceRoot' por 'localPlayer'. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kilfwan Posted August 16, 2015 Author Posted August 16, 2015 triggerServerEvent("armacz", resourceRoot) Cambia 'resourceRoot' por 'localPlayer'. LOL Si funciono gracias, aunque con getLocalPlayer no funcionaba, siempre eh usado resourceRoot para dar armas y otros mas. NaciónZ Developing server to the 65 %
Castillo Posted August 16, 2015 Posted August 16, 2015 getLocalPlayer es una funcion, osea que tenes que ejecutarla como tal, con los parentesis al final. triggerServerEvent ( "armacz", getLocalPlayer ( ) ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Kilfwan Posted August 16, 2015 Author Posted August 16, 2015 getLocalPlayer es una funcion, osea que tenes que ejecutarla como tal, con los parentesis al final. triggerServerEvent ( "armacz", getLocalPlayer ( ) ) Si lose, de igual manera gracias. NaciónZ Developing server to the 65 %
Recommended Posts