Jump to content

Problem cash


Carlossg

Recommended Posts

Solidsnake14, as onPlayerPickUpRacePickup it needs fix multi or it'll bugs/spam (i mean multi-pickup for hunter).

  
huntersplayers = {} 
  
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) 
    CheckPlayer = executeSQLSelect ( "playerData", "serial", "serial = '" .. serial .. "'" ) 
      
    if ( type( CheckPlayer ) == "table" and #CheckPlayer == 0 ) or not CheckPlayer then 
        executeSQLInsert ( "playerData", "'"..serial.."','0','0','0'" ) 
    end 
end     
  
addEventHandler("onPlayerJoin",root,function () addAccountIfNotExists(source) end) 
  
function DestructionMoney(mapInfo,mapOptions,gameOptions) 
info = mapInfo.modename 
if mapInfo.modename == "Destruction derby" then 
    huntersplayers = {} 
    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) and (not huntersplayers[source] or huntersplayers[source] == false) then     
    local serial = getPlayerSerial(source) 
    local Cash = executeSQLSelect ( "playerData", "Cash","serial = '" .. serial .. "'") 
    local Cash = tonumber(Cash[1]["Cash"]) + 1000 
    huntersplayers[source] = true 
    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) 
  

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) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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