Skip to content

Commit

Permalink
feat(core): dev debug route now can generate the player id
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Aug 30, 2024
1 parent 4f737f8 commit a70b996
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/webroutes/devDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const devWarningMessage = 'The unsafe privileged /dev webroute was called and sh
const paramsSchema = z.object({
scope: z.string(),
});
let playerJoinCounter = 0;


/**
Expand Down Expand Up @@ -46,6 +47,19 @@ export const post = async (ctx: AuthedCtx) => {
if(!ctx.txAdmin.fxRunner.currentMutex){
return ctx.send({ error: 'server not ready' });
}
if (ctx.request.body.id === null) {
if (ctx.request.body.event === 'playerDropped') {
const onlinePlayers = ctx.txAdmin.playerlistManager.getPlayerList();
if (onlinePlayers.length){
ctx.request.body.id = onlinePlayers[0].netid;
}
} else if (ctx.request.body.event === 'playerJoining') {
ctx.request.body.id = playerJoinCounter + 101;
}
}
if (ctx.request.body.event === 'playerJoining') {
playerJoinCounter++;
}
ctx.txAdmin.playerlistManager.handleServerEvents(ctx.request.body, ctx.txAdmin.fxRunner.currentMutex);
return ctx.send({ success: true });
} catch (error) {
Expand Down

0 comments on commit a70b996

Please sign in to comment.