Jump to content

Fallo


Carlossg

Recommended Posts

Obtengo estos errores en este script:

WARNING: cash-KHD\cash.lua:76: Bad argument @ 'getPlayerSerial' 
ERROR: cash-KHD\cash.lua:77: attempt to concatenate local 'serial' (a boolean value) 

cash.lua:

    function creatingTables() 
        exports.scoreboard:addScoreboardColumn("Cash") 
        executeSQLCreateTable("playerData", "serial STRING, Cash INT, DMAttempts INT, DDAttempts INT") 
        outputChatBox("Cash System by KHD started.") 
        for index, player in ipairs(getElementsByType("player")) do 
            addAccountIfNotExists(player) 
        end 
    end 
    addEventHandler("onResourceStart", resourceRoot, creatingTables) 
      
    function addAccountIfNotExists(player) 
        local serial = getPlayerSerial(player) 
        local CheckPlayer = executeSQLSelect ( "playerData", "*", "serial = '" .. serial .. "'" ) 
          
        if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then 
            executeSQLInsert ( "playerData", "'"..serial.."','0','0','0'" ) 
        else 
            local Cash  = tonumber(CheckPlayer [1]["Cash"]) 
            setElementData(source,"Cash", Cash) 
            setElementData(source,"data.money",Cash,true)         
        end 
    end 
      
    addEventHandler("onPlayerJoin",root,function () addAccountIfNotExists(source) end) 
      
    function DestructionMoney(mapInfo,mapOptions,gameOptions) 
    info = mapInfo.modename 
    if mapInfo.modename == "Destruction derby" then 
        for k,v in ipairs(getElementsByType("player")) do 
            local serial = getPlayerSerial(v) 
            local DDAttempts = executeSQLSelect ( "playerData", "DDAttempts","serial = '" .. serial .. "'") 
            local DDAttempts = tonumber(DDAttempts[1]["DDAttempts"]) + 1 
            executeSQLUpdate ( "playerData", "DDAttempts = '"..DDAttempts.."'","serial = '" .. serial .. "'") 
            setElementData(v,"data.DDAttempts",DDAttempts,true) 
            end 
        end 
    end 
    addEvent("onMapStarting") 
    addEventHandler("onMapStarting", getRootElement(), DestructionMoney) 
      
    function DestructionMoney2(thePlayer) 
        local playername = getPlayerName(thePlayer) 
        local serial = getPlayerSerial(thePlayer) 
        local Cash = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
        
        outputChatBox("*Wins: "..playername.." took $"..get('MoneyForDD').." for winning the map!",getRootElement(),255,255,0) 
        local Cash  = tonumber(Cash[1]["Cash"]) + get('MoneyForDD') 
        setElementData(thePlayer ,"Cash", Cash) 
        setElementData(thePlayer ,"data.money",Cash,true) 
        setElementData(thePlayer ,"data.playername",playername,true) 
        executeSQLUpdate ( "playerData", "Cash = '"..Cash.."'","serial = '" .. serial .. "'") 
    end 
      
    function hunterBonus(pickupID, pickupType, vehicleModel) 
    if (info == "Destruction derby" and pickupType == "vehiclechange" and vehicleModel == 425) then     
        local serial = getPlayerSerial(source) 
        local Cash = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
        local Cash = tonumber(Cash[1]["Cash"]) + 1000   
        outputChatBox("*Hunter: "..getPlayerName(source).." gets a $1000 hunter bonus!",source,25,125,225) 
        setElementData(source ,"Cash", Cash) 
        setElementData(source ,"data.money",Cash,true) 
        executeSQLUpdate ( "playerData", "Cash = '"..Cash.."'","serial = '" .. serial .. "'") 
        end 
    end 
    addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterBonus) 
     
        addCommandHandler("cash", 
    function (thePlayer) 
         local money = tonumber(getElementData(thePlayer,"data.money")) 
         if (money) then 
               outputChatBox("Your money is $".. tostring(money) .."!",thePlayer,0,255,0) 
         end 
    end) 
     addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
    local serial = getPlayerSerial(source) 
        local money = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
       if tonumber(ammount) > tonumber(getElementData(thePlayer,"data.money")) then 
             outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
       elseif tonumber(ammount) > 1000 then 
             outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
       end 
       local money = tonumber(getElementData(thePlayer,"data.money")) 
      if tonumber(ammount) <= tonumber(money) and tonumber(ammount) <= 1000 then   
       if math.random (2) == 1 then 
       setElementData(thePlayer, "data.money", money+tonumber(ammount)) 
       outputChatBox("Flip: "..getPlayerName(thePlayer).. " #00ff00flip " ..tonumber(ammount).. " and Wins!!",getRootElement(),0,255,0, true ) 
       else  
       setElementData(thePlayer, "data.money", money-tonumber(ammount)) 
       outputChatBox("Flip: "..getPlayerName(thePlayer).." #ff00ffflip " ..tonumber(ammount).. " and Lose!!",getRootElement(),255,0,0, true )        
       end 
      end 
      executeSQLUpdate ( "playerData", "Cash = '"..money.."'","serial = '" .. serial .. "'") 
     end) 

Link to comment
function creatingTables() 
    exports.scoreboard:addScoreboardColumn("Cash") 
    executeSQLCreateTable("playerData", "serial STRING, Cash INT, DMAttempts INT, DDAttempts INT") 
    outputChatBox("Cash System by KHD started.") 
    for index, player in ipairs(getElementsByType("player")) do 
        addAccountIfNotExists(player) 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, creatingTables) 
  
function addAccountIfNotExists(player) 
    local serial = getPlayerSerial(player) 
    local CheckPlayer = executeSQLSelect ( "playerData", "*", "serial = '" .. serial .. "'" ) 
  
    if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then 
        executeSQLInsert ( "playerData", "'"..serial.."','0','0','0'" ) 
    else 
        local Cash  = tonumber(CheckPlayer [1]["Cash"]) 
        setElementData(source,"Cash", Cash) 
        setElementData(source,"data.money",Cash,true)         
    end 
end 
addEventHandler("onPlayerJoin",root,function () addAccountIfNotExists(source) end) 
  
function DestructionMoney(mapInfo,mapOptions,gameOptions) 
    info = mapInfo.modename 
    if mapInfo.modename == "Destruction derby" then 
        for k,v in ipairs(getElementsByType("player")) do 
            local serial = getPlayerSerial(v) 
            local DDAttempts = executeSQLSelect ( "playerData", "DDAttempts","serial = '" .. serial .. "'") 
            local DDAttempts = tonumber(DDAttempts[1]["DDAttempts"]) + 1 
            executeSQLUpdate ( "playerData", "DDAttempts = '"..DDAttempts.."'","serial = '" .. serial .. "'") 
            setElementData(v,"data.DDAttempts",DDAttempts,true) 
            end 
        end 
    end 
addEvent("onMapStarting") 
addEventHandler("onMapStarting", getRootElement(), DestructionMoney) 
  
function DestructionMoney2(thePlayer) 
    local playername = getPlayerName(thePlayer) 
    local serial = getPlayerSerial(thePlayer) 
    local Cash = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
        
    outputChatBox("*Wins: "..playername.." took $"..get('MoneyForDD').." for winning the map!",getRootElement(),255,255,0) 
    local Cash  = tonumber(Cash[1]["Cash"]) + get('MoneyForDD') 
    setElementData(thePlayer ,"Cash", Cash) 
    setElementData(thePlayer ,"data.money",Cash,true) 
    setElementData(thePlayer ,"data.playername",playername,true) 
    executeSQLUpdate ( "playerData", "Cash = '"..Cash.."'","serial = '" .. serial .. "'") 
end 
  
function hunterBonus(pickupID, pickupType, vehicleModel) 
    if (info == "Destruction derby" and pickupType == "vehiclechange" and vehicleModel == 425) then     
        local serial = getPlayerSerial(source) 
        local Cash = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
        local Cash = tonumber(Cash[1]["Cash"]) + 1000   
        outputChatBox("*Hunter: "..getPlayerName(source).." gets a $1000 hunter bonus!",source,25,125,225) 
        setElementData(source ,"Cash", Cash) 
        setElementData(source ,"data.money",Cash,true) 
        executeSQLUpdate ( "playerData", "Cash = '"..Cash.."'","serial = '" .. serial .. "'") 
    end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterBonus) 
    
addCommandHandler("cash", 
function (thePlayer) 
    local money = tonumber(getElementData(thePlayer,"data.money")) 
        if (money) then 
        outputChatBox("Your money is $".. tostring(money) .."!",thePlayer,0,255,0) 
    end 
end) 
     
addCommandHandler("flip", 
    function(thePlayer, flip, ammount) 
    local serial = getPlayerSerial(thePlayer) -- El argumento es "thePlayer", no "source". 
    local money = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
    if tonumber(ammount) > tonumber(getElementData(thePlayer,"data.money")) then 
        outputChatBox("You don't have that kind of money",thePlayer,255,0,0) 
    elseif tonumber(ammount) > 1000 then 
        outputChatBox("You can't flip more than 1000$",thePlayer,255,0,0) 
    end 
    local money = tonumber(getElementData(thePlayer,"data.money")) 
    if tonumber(ammount) <= tonumber(money) and tonumber(ammount) <= 1000 then   
        if math.random (2) == 1 then 
        setElementData(thePlayer, "data.money", money+tonumber(ammount)) 
        outputChatBox("Flip: "..getPlayerName(thePlayer).. " #00ff00flip " ..tonumber(ammount).. " and Wins!!",getRootElement(),0,255,0, true ) 
    else 
        setElementData(thePlayer, "data.money", money-tonumber(ammount)) 
        outputChatBox("Flip: "..getPlayerName(thePlayer).." #ff00ffflip " ..tonumber(ammount).. " and Lose!!",getRootElement(),255,0,0, true )       
        end 
    end 
    executeSQLUpdate ( "playerData", "Cash = '"..money.."'","serial = '" .. serial .. "'") 
end) 

Link to comment
  • Recently Browsing   0 members

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