Skip to content

Commit

Permalink
39 (#87)
Browse files Browse the repository at this point in the history
* fix: fixes  #72, fixes group perm

* fix: fixes  #72, fixes group perm

* docs: changes
  • Loading branch information
Stuyk authored Jun 24, 2024
1 parent 6213158 commit 0bcb5f6
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
14 changes: 14 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## Version 39

### Code Changes

- Potentially fixes bug where dependencies.json aren't installed outright
- Fixes a `hasGroupPermission` function bug
- Modified client side player camera with some new functions

### Docs Changes

- N/A

---

## Version 38

### Code Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "stuyk",
"type": "module",
"version": "38",
"version": "39",
"scripts": {
"dev": "nodemon -x pnpm start",
"dev:linux": "nodemon -x pnpm start:linux",
Expand Down
50 changes: 46 additions & 4 deletions src/main/client/player/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ function tick() {
function destroy() {
try {
alt.clearInterval(interval);
} catch(err) {}
} catch (err) {}

try {
native.setCamActive(camera, false);
} catch(err) {}
} catch (err) {}

native.destroyAllCams(true);
native.renderScriptCams(false, false, 0, false, false, 0);
Expand All @@ -25,6 +25,8 @@ function destroy() {
}

export function useCamera() {
let camPos: alt.Vector3;

function create(
options: { fov: number; zOffset: number; bone: keyof typeof PedBones } = {
fov: 30,
Expand All @@ -37,9 +39,20 @@ export function useCamera() {
}

const fwd = native.getEntityForwardVector(alt.Player.local);
const pos = alt.Player.local.pos.add(fwd.x * 2, fwd.y * 2, options.zOffset);
camPos = alt.Player.local.pos.add(fwd.x * 2, fwd.y * 2, options.zOffset);

camera = native.createCamWithParams('DEFAULT_SCRIPTED_CAMERA', pos.x, pos.y, pos.z, 0, 0, 0, 55, false, 1);
camera = native.createCamWithParams(
'DEFAULT_SCRIPTED_CAMERA',
camPos.x,
camPos.y,
camPos.z,
0,
0,
0,
55,
false,
1,
);

native.setCamUseShallowDofMode(camera, true);
native.setCamFov(camera, options.fov);
Expand All @@ -56,12 +69,41 @@ export function useCamera() {
}
}

function pointAtBone(bone: keyof typeof PedBones) {
if (!camera) {
return;
}

native.pointCamAtPedBone(camera, alt.Player.local, PedBones[bone], 0, 0, 0, false);
native.renderScriptCams(true, true, 1000, false, false, 0);
}

function setFov(value: number) {
if (!camera) {
return;
}

native.setCamFov(camera, value);
native.renderScriptCams(true, true, 1000, false, false, 0);
}

function setOffset(offset: number) {
if (!camera) {
return;
}

native.setCamCoord(camera, camPos.x, camPos.y, camPos.z + offset);
}

return {
create,
destroy,
get() {
return camera;
},
setFov,
setOffset,
pointAtBone,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/server/document/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export function useCharacter(player: alt.Player) {
return false;
}

const perm = usePermissionGroup(player);
const perm = usePermissionGroup(data);
return perm.hasGroupPerm(groupName, permission);
}

Expand Down

0 comments on commit 0bcb5f6

Please sign in to comment.