#Check for Blueprint

1 messages · Page 1 of 1 (latest)

slate cedar
#

Is there a way to check to see if a person knows a blueprint before giving them a blueprint?

I don't want an influx of people having an abundance of blueprints to store if they already know them.

hollow torrent
#

Well, no. The idea is sorta to create a market. Players could find blueprints and sell to others etc.

However: there's a function that fetches them by citizenid, you can probably just make it an export, call it and check for the blueprints they got in whatever script you use

It's called fetchBlueprints, in server.lua.

Just export it by adding exports('fetchBlueprints', fetchBlueprints)

And then call it with a citizenid to get the list of known blueprints

slate cedar
#

so for something like this

if bpchance == 100 then
   if bproll == 1 then
      exports['cw-crafting']:giveBlueprintItem(source, 'weed08seed')
   elseif bproll == 2 then
      exports['cw-crafting']:giveBlueprintItem(source, 'weed04seed')
   end
TriggerClientEvent('QBCore:Notify', src, "You should find Zeva in the weed fields.", 'success', 3500)
end

Would I just do

if bpchance == 100 then
   if bproll == 1 then
      if not exports['cw-crafting']:fetchBlueprints(source, 'weed08seed') then 
             exports['cw-crafting']:giveBlueprintItem(source, 'weed08seed') end
   elseif bproll == 2 then
      if not exports['cw-crafting']:fetchBlueprints(source, 'weed04seed') then 
             exports['cw-crafting']:giveBlueprintItem(source, 'weed04seed')
   end
TriggerClientEvent('QBCore:Notify', src, "You should find Zeva in the weed fields.", 'success', 3500)
end

I will clean it up once i get it working

hollow torrent
#

No. The function fetchBlueprints takes a citizenId not a source and a blueprint

slate cedar
#

ah ok

#
local CitizenID = QBCore.Functions.GetPlayerData().citizenid
if bpchance == 100 then
   if bproll == 1 then
      if not exports['cw-crafting']:fetchBlueprints(CitizenID) then 
             exports['cw-crafting']:giveBlueprintItem(source, 'weed08seed') end
   elseif bproll == 2 then
      if not exports['cw-crafting']:fetchBlueprints(source, 'weed04seed') then 
             exports['cw-crafting']:giveBlueprintItem(source, 'weed04seed')
   end
TriggerClientEvent('QBCore:Notify', src, "You should find Zeva in the weed fields.", 'success', 3500)
end

Like this?

#

How would it know to look for a certain blueprint?

hollow torrent
#

fetchBlueprints will return a table with all the blueprints the player knows

slate cedar
#

would it be easier to code the

QBCore.Commands.Add('addblueprint', 'Give blueprint knowledge to player. (Admin Only)',{ { name = 'player id', help = 'the id of the player' }, { name = 'blueprint', help = 'name of blueprint' } }, true, function(source, args)
    local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
    local citizenId = Player.PlayerData.citizenid
    print('adding '..args[2].. ' to '..citizenId)
    addBlueprint(citizenId, args[2])
end, 'admin')

So that it auto gives this knowledge and it just cuts out the need to go to the weed fields?

hollow torrent
#

Might be yeah

slate cedar
#

Alright now to figure out how to get an admin command to run inside a script

slate cedar
#

so the command runs this function

RegisterNetEvent('cw-crafting:server:addBlueprint', function(citizenId,blueprint)
    addBlueprint(citizenId, blueprint)
end)
exports("addBlueprint", addBlueprint) -- I added this

Could I maybe do something like

local citizenId = Player.PlayerData.citizenid
exports['cw-crafting']:addBlueprint(citizenId, 'weed08seed')

instead of

exports['cw-crafting']:giveBlueprintItem(source, 'weed04seed')
#

Only reason I am trying to figure this out is because we are just at weed. Not including, gun crafting, tool crafting, other drug crafting, medical crafting, and others we are already at 1000 bps

hollow torrent
#

Maybe you got to high rate of loot for the BPs

hollow torrent
#

you also need to make sure addBlueprint is exported

slate cedar
#

I cant seem to figure out what I am doing wrong for the crafts to show up without the bp knowledge

#

nvm i might be super dumb

#

I just take out this highlighted line right

hollow torrent
#

yeah

#

haha

slate cedar
#

wow now i feel really really dumb

hollow torrent
#

Happens to the best of us laughatthisuser

slate cedar
#

alright so for the weed seeds I still need that to be fixed but in the process of trying to fix that I fixed another one of my issues