Citizen.CreateThread(function()
while true do
Citizen.Wait(50)
local ped = PlayerPedId()
local handle, vehicle = FindFirstVehicle()
local finished = false
repeat
Wait(1)
for k,v in pairs (BlacklistedCars) do
if IsPedSittingInAnyVehicle(PlayerPedId()) then
local cVeh = GetVehiclePedIsUsing(PlayerPedId(), false)
local vehicle_name = GetDisplayNameFromVehicleModel(v)
if GetEntityModel(cVeh) == v then
print(vehicle_name)
ReqAndDelete(cVeh, false)
end
end
if GetEntityModel(vehicle) == (v) then
ReqAndDelete(vehicle, false)
end
end
finished, vehicle = FindNextVehicle(handle)
until not finished
EndFindVehicle(handle)
end
end)
i’m not spawning them i’m trying to delete them
the print native will become a DropPlayer when kicking player out of server
“v” should be the hash i put into the local array… (the fact is that i don’t want modders to decrypt and know what vehicles i blacklist but instead they would read the hashes and should look for those vehicles… if they know how to do)
I think looking at the code in [Release] Model Blacklist v1.1 may be beneficial. It seems to do the same functionality that you’re looking to create. FWIW, when I used that resource, I kicked Citizen.Wait(0) up to Citizen.Wait(250), meaning it checked every quarter second instead of every frame, which is intensive.
I believe hashes are typically strings. I don’t believe using GetHashKey should cause any significant performance issues. What does something like this do? You may need to add quotes around the hashes.
Citizen.CreateThread(function()
while true do
Citizen.Wait(50)
local ped = PlayerPedId()
local handle, vehicle = FindFirstVehicle()
local finished = false
repeat
Wait(1)
for k,v in pairs (BlacklistedCars) do
if IsVehicleModel(vehicle, v) then
ReqAndDelete(vehicle, false)
end
end
finished, vehicle = FindNextVehicle(handle)
until not finished
EndFindVehicle(handle)
end
end)
I’m not sure what is being accomplished with:
if IsPedSittingInAnyVehicle(PlayerPedId()) then
local cVeh = GetVehiclePedIsUsing(PlayerPedId(), false)
local vehicle_name = GetDisplayNameFromVehicleModel(v)
if GetEntityModel(cVeh) == v then
print(vehicle_name)
ReqAndDelete(cVeh, false)
end
end
Seems like an unnecessary double check.
You could also consider using the Entity Iterator if you’re running into issues, it has worked for me a lot.
the entire check looks for the vehicle near player, the second one checks if the player is inside that vehicle and once it’ll be working will kickhim out of server
that way if you spawn a vehicle and automatically set ped driving (using mod menu) you’ll be kicked out while if the vehicle spawns without player inside it simply get deleted
Ah, I understand. In that case, I would personally do it like this to prevent two checks unless needed.
Citizen.CreateThread(function()
while true do
Citizen.Wait(50)
local ped = PlayerPedId()
local handle, vehicle = FindFirstVehicle()
local finished = false
repeat
Wait(1)
for k,v in pairs (BlacklistedCars) do
if IsVehicleModel(vehicle, v) then
if IsPedSittingInAnyVehicle(PlayerPedId()) and GetVehiclePedIsUsing(PlayerPedId(), false) == vehicle then
-- Player is in the blacklisted vehicle, kick'em. Remember DropPlayer is a server sided native, so it'll need to trigger a server event.
end
ReqAndDelete(vehicle, false)
end
end
finished, vehicle = FindNextVehicle(handle)
until not finished
EndFindVehicle(handle)
end
end)
I believe you could also just do if GetVehiclePedIsUsing(PlayerPedId(), false) == vehicle then instead of if IsPedSittingInAnyVehicle(PlayerPedId()) and GetVehiclePedIsUsing(PlayerPedId(), false) == vehicle then, but it may through an error if the player isn’t in a vehicle. I think it just returns 0 if they aren’t in a vehicle.
while true do
Citizen.Wait(1000)
local ped = PlayerPedId()
local handle, object = FindFirstObject()
local finished = false
repeat
Wait(1)
for k,v in pairs(entimonio) do
if IsEntityAttached(object) and DoesEntityExist(object) then
if GetEntityModel(object) == v then
ReqAndDelete(object, true)
end
end
if GetEntityModel(object) == v then
ReqAndDelete(object, false)
end
end
finished, object = FindNextObject(handle)
until not finished
EndFindObject(handle)
end
end)
this is to check if the entity is attached or only spawned (i noted that some modders don’t spawn random vehicle on the head of player… but spawn those vehicles as objects)
so… can i ask you another thing? i opened another thread regarding blips… can you help me there?
i’m looking to find a way to show an entity blip only to police once a player spawns it
using esx i can send you privately the scripts… i created two missions gta online style… the only problem is how to make only police to see the blip when a player is stealing the mission vehicle
still nothing about the hashes… if i stop the script and restart it after i’m spawned it works perfectly… if join the server with the script already started then i get this