Jump to content

Search the Community

Showing results for tags 'stock'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Multi Theft Auto: San Andreas 1.x
    • Support for MTA:SA 1.x
    • User Guides
    • Open Source Contributors
    • Suggestions
    • Ban appeals
  • General MTA
    • News
    • Media
    • Site/Forum/Discord/Mantis/Wiki related
    • MTA Chat
    • Other languages
  • MTA Community
    • Scripting
    • Maps
    • Resources
    • Other Creations & GTA modding
    • Competitive gameplay
    • Servers
  • Other
    • General
    • Multi Theft Auto 0.5r2
    • Third party GTA mods
  • Archive
    • Archived Items
    • Trash

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Gang


Location


Occupation


Interests

Found 1 result

  1. Hello guys , I started working on the stocks system, but I have some problems. I want when the stock is positive ( green ), he gives him money, and when the stock is negative ( red ), he takes money from the player, that is, he buys a stock, and if he loses he loses money , like forex Thanks , --- Gridlist Value Test ---- for i,d in pairs(data) do local r = dgsGridListAddRow(GUIEditor.gridlist[1]) dgsGridListSetItemText(GUIEditor.gridlist[1], r, 1, d.name, false, false ) dgsGridListSetItemText(GUIEditor.gridlist[1], r, 2, "$ "..round(d.pps,2)*totalMidifier, false, false ) dgsGridListSetItemText(GUIEditor.gridlist[1], r, 3, (d.diff[1] and "▲ " or "▼ " )..round(d.diff[2],2).."%", false, false ) dgsGridListSetItemColor(GUIEditor.gridlist[1], r, 3, d.diff[1] and 0 or 255, d.diff[1] and 255 or 0, 0 ) triggerServerEvent("test",localPlayer,round(d.diff[2],2)) end for k,s in pairs(playerData) do local r = dgsGridListAddRow(GUIEditor.gridlist[2]) dgsGridListSetItemText( GUIEditor.gridlist[2],r, 1, k, false, false ) dgsGridListSetItemText( GUIEditor.gridlist[2],r, 2, s[1], false, false ) local old = s[2]*s[1] local new = getCompPPS( k )*s[1] local change = new-old >= 0 and true dgsGridListSetItemText(GUIEditor.gridlist[2], r, 3, "$"..round(new-old,2), false, false ) --dgsGridListSetItemText(GUIEditor.gridlist[2], r, 3, (d.diff[1] and "▲ " or "▼ " )..round(d.diff[2],2).."%", false, false ) dgsGridListSetItemColor( GUIEditor.gridlist[2],r, 3, change and 0 or 255, change and 255 or 0, 0 ) ----- client ----- local c = currentData[selectedBuyRow+1].name local n = currentData[selectedBuyRow+1].pps*totalMidifier if exports.global:getMoney(localPlayer ) - n >= 0 then triggerServerEvent( "onClientStockTransaction", localPlayer, n ) local temp = localPlayer:getData "Stocks" or {} for k,d in pairs(currentData) do if d.name == c then temp[d.name] = {temp[d.name] and temp[d.name][1]+totalMidifier or totalMidifier,currentData[selectedBuyRow+1].pps} end end localPlayer:setData("Stocks",temp,false) buyD = true saveStocks( ) -- triggerServerEvent( "onClientStockTransaction", localPlayer, -n ) else outputChatBox( "test") end ----- Server ----- function round(number, decimals, method) decimals = decimals or 0 local factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end addEvent( "TriggerMoneyTest", true ) addEventHandler( "TriggerMoneyTest", root, function( money,n ) local take = exports.global:getMoney(source, tonumber(money)-n) triggerClientEvent( source, "onConfirmPayment", source ) if decimals >= 0 then exports.global:takeMoney( source, tonumber(take)-n ) else -- decimals === exports.global:giveMoney( source, tonumber(take)+n ) end end)
×
×
  • Create New...