#Check for Blueprint
1 messages · Page 1 of 1 (latest)
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
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
No. The function fetchBlueprints takes a citizenId not a source and a blueprint
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?
fetchBlueprints will return a table with all the blueprints the player knows
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?
Might be yeah
Alright now to figure out how to get an admin command to run inside a script
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
Maybe you got to high rate of loot for the BPs
That will add the bp to the player, not give an item, but yeah sure
you also need to make sure addBlueprint is exported
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
wow now i feel really really dumb
Happens to the best of us 
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