Skip to content

Commit

Permalink
3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FAXES authored Apr 26, 2022
1 parent 5e100bb commit 9456ca6
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
33 changes: 33 additions & 0 deletions client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
////////////////////////////////////////////////
/// Discord Vehicle Whitelist, Made by FAXES ///
////////////////////////////////////////////////

let restricted = [];

Delay = (ms) => new Promise(res => setTimeout(res, ms));

onNet("DiscordVehicleWhitelist:SendEm", cars => {
cars.forEach(e => {
restricted.push({c: e.split(":")[1], d: e.split(":")[0]});
});
});

setTick(async () => {
await Delay(400);
let ped = GetPlayerPed(PlayerId())
let veh = GetVehiclePedIsIn(ped);
if(veh && DoesEntityExist(veh)) {
let model = GetEntityModel(veh);
let driver = GetPedInVehicleSeat(veh, -1);
if(driver == ped) {
const found = restricted.find(e => e.c == model);
if(found) {
if(found.d) {
DeleteEntity(veh);
} else {
TaskLeaveVehicle(ped, veh, 16);
}
}
}
}
});
10 changes: 5 additions & 5 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
----------------------------------------
--- Discord Whitelist, Made by FAXES ---
----------------------------------------
------------------------------------------------
--- Discord Vehicle Whitelist, Made by FAXES ---
------------------------------------------------

fx_version 'bodacious'
game 'gta5'
author 'FAXES'

server_script 'server.lua'
client_script 'client.lua'
server_script 'server.js'
client_script 'client.js'
31 changes: 31 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
////////////////////////////////////////////////
/// Discord Vehicle Whitelist, Made by FAXES ///
////////////////////////////////////////////////

const config = {
vehicles: [
{car: "POLICE", delete: true},
{car: "POLICE2", delete: false, role: ""},
{car: "POLICE3"}
]
}

if(GetResourceState("DiscordWhitelist") == "stopped" || GetResourceState("DiscordWhitelist") == "missing" || GetResourceState("DiscordWhitelist") == "uninitialized" ) {console.log(`^1 You must have DiscordWhitelist installed.^7`)}

on('playerConnecting', async (name, setKickReason, deferrals) => {
let src = global.source;
let arr = [];
const userRoles = await exports.DiscordWhitelist.getRoles(src);

await Promise.all(config.vehicles.map(async (e) => {
if(e.role) {
if(!userRoles.includes(e.role)) {
arr.push(`${e.delete}:${e.car}`);
}
} else {
arr.push(`${e.delete}:${e.car}`);
}
}));

emitNet("DiscordVehicleWhitelist:SendEm", src, arr);
});

0 comments on commit 9456ca6

Please sign in to comment.