Jump to content

KariiiM

Members
  • Posts

    1,312
  • Joined

  • Last visited

Everything posted by KariiiM

  1. You have to make a system for wanted points, there's no function that receive wanted points of a specified player.
  2. I improved my code alitle bit, try it and tell me the results: function getMostWantedPlayer ( ) local mostWanted = { } local playerWL = { } for _, player in ipairs ( getElementsByType ( "player", root ) ) do mostWanted[getPlayerWantedLevel ( player )] = getPlayerName ( player ) table.insert ( playerWL, getPlayerWantedLevel ( player ) ) end table.sort ( playerWL, function ( a, b ) return ( a > b ) end ) return mostWanted, playerWL end addCommandHandler ( "gewl", function ( thePlayer ) local mostWanted, playerWL = getMostWantedPlayer ( ) outputChatBox ( "The most online wanted player is ".. tostring ( mostWanted[playerWL[1]] ) .."!", thePlayer, 255, 255, 0 ) end )
  3. Well, all what you have to do is, to make a loop for all players, using getElementsByType( "player", root ) then, use the function getPlayerWantedLevel as the table index and store the looped players to the table. I coded this small code for you, not tested but it should work fine: [lua] local mostWanted = { } for _, player in ipairs ( getElementsByType ( "player", root ) ) do mostWanted[getPlayerWantedLevel ( player )] = getPlayerName ( player ) end table.sort ( mostWanted, function ( a, b ) return a > b end )[/lua]
  4. I like the new style of the forums, seriously it needs time to be used to this new style again xD, anyway good job mta team.
  5. What do you mean by faction?
  6. If you put addEventHandler inside a function it will be triggered untill the function is running
  7. onClientPlayerJoin and onClientPlayerQuit are client events, they cant be used at server side.
  8. KariiiM

    Window to Dx

    I understood him by wrong
  9. KariiiM

    Window to Dx

    No, you can't convert it to directx GUI's.
  10. No one is going to waste his time to script a whole server for you without a payment.
  11. Here you have it fixed, local mysql = exports.mysql local incomeTax = 0 local taxVehicles = {} local insuranceVehicles = {} local vehicleCount = {} local taxHouses = {} local threads = { } local threadTimer = nil local govAmount = 10000000 local unemployedPay = 100 --200 function payWage(player, pay, faction, tax) local dbid = tonumber(getElementData(player, "dbid")) local governmentIncome = 0 local bankmoney = getElementData(player, "bankmoney") local noWage = pay == 0 local donatormoney = 0 local startmoney = bankmoney if (exports.donators:hasPlayerPerk(player, 4)) then donatormoney = donatormoney + 25 end if (exports.donators:hasPlayerPerk(player, 5)) then donatormoney = donatormoney + 75 end local interest = 0 local cP = 0 if bankmoney > 0 then --interest = math.min(5000, math.floor(3 * math.sqrt(bankmoney))) interest = math.min(2500, math.floor(2 * math.sqrt(bankmoney))) -- 5000'e 3 cP = interest / bankmoney * 50 end if interest ~= 0 then mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (-57, " .. dbid .. ", " .. interest .. ", 'BANKINTEREST', 6)" ) end -- business money local profit = getElementData(player, "businessprofit") exports.anticheat:changeProtectedElementDataEx(player, "businessprofit", 0, false) bankmoney = bankmoney + math.max( 0, pay ) + interest + profit + donatormoney -- rentable houses local rent = 0 local rented = nil -- store id in here for key, value in ipairs(getElementsByType("interior")) do -- Who the hell made this bullsit lol / MAXIME local interiorStatus = getElementData(value, "status") local owner = tonumber( interiorStatus[4] ) if (owner) and (owner == dbid) and (getElementData(value, "status")) and (tonumber(interiorStatus[1]) == 3) and (tonumber(interiorStatus[5]) > 0) then rent = rent + tonumber(interiorStatus[5]) rented = tonumber(getElementData(value, "dbid")) end end if not faction then if bankmoney > 25000 then noWage = true pay = 0 elseif pay > 0 then governmentIncome = governmentIncome - pay mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (-3, " .. dbid .. ", " .. pay .. ", 'STATEBENEFITS', 6)" ) else pay = 0 end else if pay > 0 then local teamid = getElementData(player, "faction") if teamid <= 0 then teamid = 0 else teamid = -teamid end mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (" .. teamid .. ", " .. dbid .. ", " .. pay .. ", 'WAGE', 6)" ) else pay = 0 end end if tax > 0 then pay = pay - tax bankmoney = bankmoney - tax governmentIncome = governmentIncome + tax mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (" .. dbid .. ", -3, " .. tax .. ", 'INCOMETAX', 6)" ) end local vtax = taxVehicles[ dbid ] or 0 if vtax > 0 then vtax = math.min( vtax, bankmoney ) bankmoney = bankmoney - vtax governmentIncome = governmentIncome + vtax mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (" .. dbid .. ", -3, " .. vtax .. ", 'VEHICLETAX', 6)" ) end --vehicle insurance local totalInsFee, totalInsFeePerVehicles, totalInsFeePerFactions = 0, {}, {} if exports.global:isResourceRunning("insurance") and exports.global:isResourceRunning("factions") then --outputDebugString("Payday insurance running") totalInsFee, totalInsFeePerVehicles, totalInsFeePerFactions = exports.insurance:analyzeInsurance(insuranceVehicles[ dbid ], getElementData(player, "dbid")) if totalInsFee > 0 then if bankmoney >= totalInsFee then bankmoney = bankmoney - totalInsFee for factionId, data in pairs(totalInsFeePerFactions) do if data.fee > 0 then local theFaction = exports.factions:getTeamFromFactionID(factionId) if exports.bank:giveBankMoney(theFaction, data.fee) then exports.bank:addBankTransactionLog(dbid, -factionId, data.fee, 2, "Insurance fees for "..(#(data.vehs)).." vehicles.") end end end else if exports.global:isResourceRunning("announcement") then local customerName = getPlayerName(player):gsub("_", " ") for factionId, data in pairs(totalInsFeePerFactions) do local details = 'List of insuranced vehicles from customer '..customerName..":\n\n" for i, vehid in pairs(data.vehs) do details = details..'Vehicle VIN #'..vehid.."\n" end details = details.."\nTotal: $"..exports.global:formatMoney(data.fee) exports.factions:sendNotiToAllFactionMembers(factionId, customerName.." has failed to pay his total insurance fees of $"..exports.global:formatMoney(data.fee).." over his "..(#(data.vehs)).." vehicles.", details) end end end end end local ptax = taxHouses[ dbid ] or 0 if ptax > 0 then ptax = math.floor( ptax ) ptax = math.min( ptax, bankmoney ) bankmoney = bankmoney - ptax governmentIncome = governmentIncome + ptax mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (" .. dbid .. ", -3, " .. ptax .. ", 'PROPERTYTAX', 6)" ) end if (rent > 0) then if (rent > bankmoney) then rent = -1 call( getResourceFromName( "interior-system" ), "publicSellProperty", player, rented, false, true ) else bankmoney = bankmoney - rent mysql:query_free( "INSERT INTO wiretransfers (`from`, `to`, `amount`, `reason`, `type`) VALUES (" .. dbid .. ", 0, " .. rent .. ", 'HOUSERENT', 6)" ) end end -- save the bankmoney exports.anticheat:changeProtectedElementDataEx(player, "bankmoney", bankmoney, true) -- let the client tell them the (bad) news local grossincome = pay+profit+interest+donatormoney-rent-vtax-ptax triggerClientEvent(player, "cPayDay", player, faction, noWage and -1 or pay, profit, interest, donatormoney, tax, incomeTax, vtax, ptax, rent, grossincome, cP) return governmentIncome end function payAllWages(isForcePayday) if not isForcePayday then local mins = getRealTime().minute local minutes = 60 - mins if (minutes < 15) then minutes = minutes + 60 end setTimer(payAllWages, 60000*minutes, 1, false) end loadWelfare( ) threads = { } taxVehicles = {} vehicleCount = {} insuranceVehicles = {} for _, veh in pairs(getElementsByType("vehicle")) do if isElement(veh) then local owner, faction, registered = tonumber(getElementData(veh, "owner")) or 0, tonumber(getElementData(veh, "faction")) or 0, tonumber(getElementData(veh, "registered")) or 0 local vehid = getElementData(veh, "dbid") or 0 if vehid >0 and faction <= 0 and owner > 0 then -- Vehicle inactivity scanner / MAXIME / 2015.1.11 local deletedByScanner = nil local active, reason = exports['vehicle-system']:isActive(veh) if not active and not exports['vehicle-system']:isProtected(veh) then local name = exports.global:getVehicleName(veh) if exports['vehicle-manager']:systemDeleteVehicle(vehid, "Deleted by Inactivity Scanner. Reason: "..reason) then local account = exports.cache:getAccountFromCharacterId(owner) or {id = 0, username="No-one"} local characterName = exports.cache:getCharacterNameFromID(owner) or "No-one" if owner > 0 and account then exports.announcement:makePlayerNotification(account.id, "Vehicle ID #"..vehid.." ("..name..") was taken away from "..characterName.."'s possession by the vehicle inactivity scanner.", "Reason: "..reason..". Your vehicle was marked as inactive because your character hasn't been logged in game for longer than 30 days or no body has ever started its engine for longer than 14 days while parking outdoor. \n\nAn inactive vehicle is a waste of resources and thus far the vehicle's ownership was removed or stripped from your possession to give other players opportunities to buy and use it more efficiently.\n\nThis vehicle wasn't unprotected. To prevent this to happen again to other vehicles of yours, you may want to spend your GC(s) to protect it from the inactive vehicle scanner on UCP.") end exports.global:sendMessageToAdmins("[VEHICLE] Vehicle ID #"..vehid.." ("..name..", owner: "..characterName.." - "..account.username..") has been deleted by the vehicle inactivity scanner. "..reason) deletedByScanner = true end end if registered == 1 and not deletedByScanner then --Taxes local tax = tonumber(getElementData(veh, "carshop:taxcost")) or 25 if tax > 0 then taxVehicles[owner] = ( taxVehicles[owner] or 0 ) + ( tax * 1 ) --[[vehicleCount[owner] = ( vehicleCount[owner] or 0 ) + 1 if vehicleCount[owner] > 3 then -- $75 for having too much vehicles, per vehicle more than 3 taxVehicles[owner] = taxVehicles[owner] + 50 end]] end --Insurance if exports.global:isResourceRunning("insurance") then local insuranceFee = getElementData(veh, "insurance:fee") or 0 insurancefee = tonumber(insurancefee) local insuranceFaction = getElementData(veh, "insurance:faction") or 0 insuranceFaction = tonumber(insuranceFaction) if insuranceFee > 0 and insuranceFaction > 0 then if not insuranceVehicles[owner] then insuranceVehicles[owner] = {} end if not insuranceVehicles[owner][vehid] then insuranceVehicles[owner][vehid] = {} end if not insuranceVehicles[owner][vehid][insuranceFaction] then insuranceVehicles[owner][vehid][insuranceFaction] = 0 end insuranceVehicles[owner][vehid][insuranceFaction] = insuranceVehicles[owner][vehid][insuranceFaction] + insuranceFee end end end end end end -- count all player props taxHouses = { } for _, property in pairs( getElementsByType( "interior" ) ) do local interiorStatus = getElementData(property, "status") local cost = tonumber(interiorStatus[5]) or 0 local owner = tonumber(interiorStatus[4]) or 0 local type = tonumber(interiorStatus[1]) local intid = getElementData(property, "dbid") local name = getElementData(property, "name") if cost > 0 and owner > 0 and type < 2 then -- MAXIME local propertyTax = getPropertyTaxRate(interiorStatus[1]) taxHouses[ interiorStatus[4] ] = ( taxHouses[ interiorStatus[4] ] or 0 ) + propertyTax * interiorStatus[5] end -- Interior inactivity scanner / MAXIME / 2015.1.11 local active, reason = exports['interior-system']:isActive(property) if not active and not exports['interior-system']:isProtected(property) then if exports['interior-system']:unownProperty(intid, "Forcesold by Inactivity Scanner. Reason: "..reason) then local account = exports.cache:getAccountFromCharacterId(owner) or {id = 0, username="No-one"} local characterName = exports.cache:getCharacterNameFromID(owner) or "No-one" if owner > 0 and account then exports.announcement:makePlayerNotification(account.id, "Interior ID #"..intid.." ("..name..") was taken away from "..characterName.."'s possession by the interior inactivity scanner.", "Reason: "..reason..". Your interior was marked as inactive because no body has ever entered it for the last 14 days or your character(who owns it) hasn't been logged in game for 30 days.\n\nAn inactive interior is a waste of resources and thus far the interior's ownership was stripped from your possession to give other players opportunities to buy and use it more efficiently.\n\nThis interior wasn't unprotected. To prevent this to happen again to other interiors of yours, you may want to spend your GC(s) to protect it from the inactive interior scanner on UCP.") end exports.
  12. It will be triggered untill you are wasted.
  13. You will have to make a db and save your items into it in each action made, then send the results as a table of your data to client side AND loop it there to be shown in your gridlist. you can start with SQLite or default MTA's SQLite accounts data. ( setAccountData AND getAccountData to get the inserted data ).
  14. If you created the pickup object client sided only the localplayer who can see it, so the other players will not see your pickup's alpha.
  15. Can I know what are you trying to do? and post a full code instead of this less detailed code.
  16. To be more clear, MySQL is a database type require a MySQL server which uses SQL language to contact with it.
  17. KariiiM

    DELETE

    I believe there's a spanish scripting section: https://forum.multitheftauto.com/viewforum.php?f=145
  18. Change the tag REL to REQ
  19. This is a scripting section not a designing section
  20. @Bonus, you did a mistake, the values of pairs function are 1, 2 and 3 and your code will output: > 1 > 3 > 2 ( not sorted of course ) "hello", "my" and "name" are the keys of the table3 not the values. So, the correct code is: local table3 = { ["hello"] = 1, ["my"] = 2, ["name"] = 3 } for key in pairs ( table3 ) do outputChatBox ( key) end -- "name", "hello", "my" (not sorted)
  21. "IF NOT EXISTS" is part of SQL language, executeSQLQuery is just an MTA function who supports SQL language.
  22. Use pairs in this case, You are storing the player as an index and you inserted the same value as the index, why ? You can simply retrieve the stored player element just like that for player in pairs ( totalPlayerInEvent ) do triggerClientEvent ( player, "joinEvent", root ) end
×
×
  • Create New...