Jump to content

Problema con Coinsystem


Kilfwan

Recommended Posts

Posted

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 :|

Posted
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) 

Posted
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

Posted
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.

Posted

getLocalPlayer es una funcion, osea que tenes que ejecutarla como tal, con los parentesis al final.

triggerServerEvent ( "armacz", getLocalPlayer ( ) ) 

Posted
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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...