Cacher les printers rprint

  • Initiateur de la discussion Nosios
  • Date de début
  • Initiateur de la discussion
N

Nosios

Têtard
Messages
9
Score réaction
0
Points
5
Bonjour , je cherche à cacher les printers de l'addon rprint dans le menu f4 pour les teams non autorisées à l'acheter car ils apparaissent pour tout le monde ( mais seulement les teams autorisées peuvent l'acheter ) , et je ne trouve pas ca propre du tout . Voici mon fichier pour ajouter les printers :
Code:
rPrint.RemovePrintersOnDisconnect = true --whether to remove printers on player disconnect
rPrint.OwnershipTransferEnabled = true --whether to allow users to take ownership of someone else's printer
rPrint.UpdateDelay = 2 --the time in between updates to the datatable (in seconds)
rPrint.MaxPrinters = 4 --maximum number of printers a user can own (including those that have had their owner changed)
rPrint.DefaultPrinterParams = { AutoAddToDarkRP = true, --automatically add printers to DarkRP Price = 1000, --price of the printer in DarkRP (only if automatically added) Color = Color( 255, 255, 255, 255 ), --color of the printer SoundEffectVolume = 50, --sound effects volume (between 0 and 100) TempMin = 28, --minimum temperature (won't go below this) TempMax = 80, --maximum temperature (will explode or shut down at this temperature) TempStart = 30, --starting temperature PrintRate = 4, --printing rate (in money per second) ($/s) HeatRate = 1 / 15, --heat rate (in degrees per money printed) (*/$) CoolRate = 1 / 10, --cool rate (in degrees per second) (*/s) CoolerCost = 40, --cooler cost CoolerCoolRate = 3 / 2, --cooler cooling rate (in degrees per second) (*/s) CoolerBreakEnabled = true, --should the cooler sometimes break CoolerBreakInterval = { --the time interval between the coolers breaking (in seconds, randomized) (s) 6 * 60, --minimum amount of seconds between breaks 10 * 60 --maximum amount of seconds between breaks }, PowerConsumptionRate = 1 / 20, --power consumption rate (in percent power per money printed) (%/$) PowerConsumptionRateCooler = 1 / 12, --power consumption rate for the cooler (in percent per second) (%/s) RechargeCost = 10, --cost to recharge RechargeMax = 20, --the value at which the recharge button becomes pressable FadeDistance = 125, --maximum distance that the printers render the GUI UseDistance = 100, --maximum distance a player can use the buttons AlertOwnerOnDestroyed = true, --alert the owner when someone blows up their printer AlertOwnerOnOverheated = true, --alert the owner when the printer overheats and blows up PrinterHealth = 125, --printer health (resistance to damage) ExplodeOnOverheat = true, --explode when the printer overheats CanBeDestroyed = true, --can the printers be broken DestroyPayout = 2500, --amount paid to the person who destroyed the printer DestroyPayoutTeamsExclusive = false, --whether to exclude or include the teams below in the payout DestroyPayoutTeams = { --teams which can receive money from destroying a printer; also supports team names as strings TEAM_POLICE, TEAM_MAIRE }
}
--[[ Examples:
--Printer with all default settings
rPrint.RegisterPrinterType( "Default", {} )
--Printer with default settings, except it uses less power
rPrint.RegisterPrinterType( "Eco", { Price = 1500, PowerConsumptionRate = 1 / 35, PowerConsumptionRateCooler = 1 / 25
} )
--Special VIP printer, you'll want to change this depending on the teams/user groups that you want to have access
--In this example, it is available to users who are both TEAM_CITIZEN or TEAM_AOD, and of the user group "vip"
rPrint.RegisterPrinterType( "VIP", { Price = 5000, AllowedTeams = { TEAM_CITIZEN, TEAM_AOD }, --make it so only citizens and AODs can buy the printer AllowedUserGroups = { "vip" }, --lock to user group vip SpawnCommand = "/buyvipprinter", --custom spawn commands are also supported PrintRate = 10, --$6,000 per minute! HeatRate = 1 / 100, --heats up very slowly CoolRate = 1 / 2, --cool down pretty fast, you shouldn't even need a cooler for this one CoolerCoolRate = 5, --super cooler for the hell of it CoolerBreakEnabled = false, --cooler never breaks PowerConsumptionRate = 1 / 500, --very efficient PowerConsumptionRateCooler = 1 / 300, --cooler is also very efficient PrinterHealth = 1000, --super strong ExplodeOnOverheat = false, --don't blow up DestroyPayout = 5000 --Police jackpot!
}, "rprint_vipprinter" ) --give it the entity name "rprint_vipprinter" (this is optional, see README for default names)
]]
rPrint.RegisterPrinterType( "Bronze", { Price = 10000, AllowedTeams = { TEAM_MAFIEUX, TEAM_PARRAIN, TEAM_CRIPZ, TEAM_BLOODZ, TEAM_YAKUZA }, PrintRate = 10, DestroyPayout = 5000, Color = Color( 205, 135, 65, 255 ), HeatRate = 1 / 100, PowerConsumptionRate = 1 / 500, RechargeCost = 150, CoolerCost = 250
} )
rPrint.RegisterPrinterType( "Argent", { Price = 15000, AllowedTeams = { TEAM_MAFIEUX, TEAM_PARRAIN, TEAM_CRIPZ, TEAM_BLOODZ, TEAM_YAKUZA }, PrintRate = 20, DestroyPayout = 9000, Color = Color( 150, 150, 150, 255 ), HeatRate = 1 / 100, PowerConsumptionRate = 1 / 500, RechargeCost = 300, CoolerCost = 450
} )
rPrint.RegisterPrinterType( "Or", { Price = 40000, AllowedTeams = { TEAM_MAFIEUX, TEAM_PARRAIN, TEAM_CRIPZ, TEAM_BLOODZ, TEAM_YAKUZA }, PrintRate = 30, DestroyPayout = 30000, Color = Color( 255, 255, 135, 255 ), HeatRate = 1 / 100, PowerConsumptionRate = 1 / 500, RechargeCost = 400, CoolerCost = 800
} )
Et voici le fichier contenant la class rPrint.RegisterPrinterType :
Code:
rPrint = {}
rPrint.MinorVersion = 3
rPrint.Revision = 0
rPrint.Version = ([[%u.%u]]):format( rPrint.MinorVersion, rPrint.Revision )
rPrint.DefaultPrinterParams = {}
rPrint.SelectionModes = { RECHARGE = 1, WITHDRAW = 2, PURCHASE_COOLER = 3, TRANSFER_OWNERSHIP = 4
}
local events = {}
function rPrint.RegisterEventCallback( event, ident, callback ) events[event] = events[event] or {} if !callback then callback = ident ident = #events[event] + 1 else rPrint.Assert( type( ident ) == "string", "Invalid callback identifier." ) end events[event][ident] = callback
end
function rPrint.UnregisterEventCallback( event, ident ) rPrint.Assert( type( ident ) == "string", "Invalid callback identifier." ) events[event] = events[event] or {} events[event][ident] = nil
end
function rPrint.TriggerEvent( event, ... ) if !events[event] then return end for _, cb in pairs( events[event] ) do cb( ... ) end
end
function rPrint.TriggerEventForResult( event, ... ) if !events[event] then return end for _, cb in pairs( events[event] ) do local results = { cb( ... ) } if #results > 0 then return unpack( results ) end end
end
function rPrint.Error( msg, nohalt, noprefix, level ) local func = nohalt and ErrorNoHalt or error msg = (noprefix and '' or "rPrint: ") .. msg .. '\n' level = level or 2 func( msg, level )
end
function rPrint.Assert( cond, msg ) if !cond then rPrint.Error( msg, false, false, 3 ) end
end
function rPrint.IsMemberOfTeams( ply, teams ) --accepts team ids or names teams = (type( teams ) == "table") and teams or { teams } local plyt = ply:Team() local lookup = {} for _, t in pairs( teams ) do if type( t ) == "string" then t = t:lower() for tid, tbl in pairs( team.GetAllTeams() ) do if tbl.Name and tbl.Name:lower() == t then t = tid break end end end lookup[t] = true end return lookup[plyt] == true
end
function rPrint.RegisterPrinterType( pname, params, entname ) local nice_name = ([[%s Printer]]):format( pname ) local clean_name = pname:lower():gsub( [=[[^%a%d]+]=], '_' ) params = params or {} entname = entname or ([[rprint_%sprinter]]):format( clean_name ) local ENT = {} ENT.Type = "anim" ENT.Base = "rprint_base" ENT.PrintName = nice_name ENT.Spawnable = false ENT.AdminSpawnable = false ENT.Params = table.Copy( rPrint.DefaultPrinterParams ) table.Merge( ENT.Params, params ) scripted_ents.Register( ENT, entname ) if ENT.Params.AutoAddToDarkRP then local cmd = ENT.Params.SpawnCommand if !cmd then local cmdfmt = [[buy%sprinter]] if !DarkRP or !DarkRP.createEntity then --quick and dirty check for DarkRP sub-2.5.4273 cmdfmt = [[/]] .. cmdfmt end cmd = cmdfmt:format( clean_name ) end AddEntity( nice_name, { ent = entname, model = "models/props_c17/consolebox01a.mdl", price = ENT.Params.Price or 1000, cmd = cmd, max = 999999, customCheck = function( ply ) if ENT.Params.CustomCheck then local result = ENT.Params.CustomCheck( ply ) if result != nil then return result end end if ENT.Params.AllowedTeams and !rPrint.IsMemberOfTeams( ply, ENT.Params.AllowedTeams ) then return false end if ENT.Params.AllowedUserGroups then local ug = ply:GetUserGroup():lower() local ingroup = false for _, group in pairs( ENT.Params.AllowedUserGroups ) do if group:lower() == ug then ingroup = true break end end if !ingroup then return false end end local steamid = ply:SteamID() local cnt = 0 for _, ent in pairs( ents.GetAll() ) do if ent.Base == ENT.Base and ent.SpawnerSteamID == steamid then cnt = cnt + 1 end end return cnt < (rPrint.MaxPrinters or 2) end } ) end return entname
end
 
Dernière édition:
Discord d'entraide
Rejoignz-nous sur Discord