Some race commands (unfinished)

This commit is contained in:
Vortrex
2022-05-24 01:18:46 -05:00
parent 4766890f2f
commit 42b8125bc0
2 changed files with 79 additions and 0 deletions

View File

@@ -253,3 +253,13 @@ function messagePlayerHelpContent(client, messageString) {
}
// ===========================================================================
function messagePlayersInRace(raceId, message) {
for(let i in clients) {
if(getPlayerRace(clients[i]) == raceId) {
messagePlayerNormal(clients[i], message);
}
}
}
// ===========================================================================

View File

@@ -78,3 +78,72 @@ function createRaceCommand(command, params, client) {
}
// ===========================================================================
function createRaceCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let raceId = createRace(params, getPlayerPosition(client));
getRaceData(raceId).enabled = false;
initRace(raceId);
joinRace(client, raceId);
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created race {ALTCOLOUR}${params}`);
}
// ===========================================================================
function createRaceLocationCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let raceId = getPlayerRace(client);
if(raceId == false) {
messagePlayerError(client, "You are not in a race!");
return false;
}
let raceLocationName = params;
createRaceLocation(raceId, raceLocationName, getPlayerPosition(client));
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created race {ALTCOLOUR}${params}`);
}
// ===========================================================================
function createRaceLocationCommand(command, params, client) {
if(areParamsEmpty(params)) {
messagePlayerSyntax(client, getCommandSyntaxText(command));
return false;
}
let raceId = getPlayerRace(client);
if(raceId == false) {
messagePlayerError(client, "You are not in a race!");
return false;
}
let raceLocationName = params;
createRaceLocation(raceId, raceLocationName, getPlayerPosition(client));
messageAdmins(`{adminOrange}${getPlayerName(client)}{MAINCOLOUR} created race {ALTCOLOUR}${params}`);
}
// ===========================================================================
function stopRacingCommand(command, params, client) {
if(!isPlayerInARace(client)) {
messagePlayerError(client, "You aren't in a race!");
return false;
}
leaveRace(client);
messagePlayerSuccess(client, "You left the race!");
messagePlayersInRace(`${getCharacterFullName(client)} left the race!`);
checkRemainingPlayersInRace(raceId)
}
// ===========================================================================