Mass commit

This commit is contained in:
Vortrex
2021-01-01 16:18:59 -06:00
parent a9dad59b27
commit 5af3023c85
45 changed files with 1648 additions and 1599 deletions

View File

@@ -12,11 +12,18 @@ var app = {};
let robotoFont = "Roboto"; let robotoFont = "Roboto";
let mainLogoPath = "files/images/main-logo.png";
let primaryColour = [200, 200, 200]; let primaryColour = [200, 200, 200];
let focusedColour = [200, 200, 200];
let invalidValueColour = [200, 200, 200];
let focusedColourOffset = 50;
let windowAlpha = 185; let windowAlpha = 185;
let windowTitleAlpha = 200; let windowTitleAlpha = 200;
let buttonAlpha = 200; let buttonAlpha = 200;
let textInputAlpha = 200;
let login = { let login = {
window: null, window: null,
@@ -532,7 +539,7 @@ let skinNames = [
[146, "Crack Maker", false], [146, "Crack Maker", false],
[147, "Businessman", false], [147, "Businessman", false],
[148, "Businesswoman", false], [148, "Businesswoman", false],
[149, "INVALID", false], //[149, "INVALID", false],
[150, "Businesswoman", false], [150, "Businesswoman", false],
[151, "Normal Ped", false], [151, "Normal Ped", false],
[152, "Prostitute", false], [152, "Prostitute", false],
@@ -701,9 +708,9 @@ let skinNames = [
], ],
[ // GTA IV [ // GTA IV
[-2020305438,"Male Multiplayer",false], //[-2020305438,"Male Multiplayer",false],
[-641875910,"Female Multiplayer",false], //[-641875910,"Female Multiplayer",false],
[-1370810922,"MODEL_SUPERLOD",false], //[-1370810922,"MODEL_SUPERLOD",false],
[1853617247,"Anna",false], [1853617247,"Anna",false],
[-1646893330,"Anthony",false], [-1646893330,"Anthony",false],
[1495769888,"Badman",false], [1495769888,"Badman",false],
@@ -1067,18 +1074,13 @@ let currentCharacter = 0;
app.init = function() app.init = function()
{ {
//let fontStream = openFile("RoleplayApp/Fonts/Roboto-Regular.ttf");
//if(fontStream != null) {
// robotoFont = lucasFont.createFont(fontStream, 10.0);
// fontStream.close();
//}
//robotoFont = lucasFont.createDefaultFont(10.0, "Roboto", "Regular");
console.log(`[Asshat.GUI] Initializing GUI ...`); console.log(`[Asshat.GUI] Initializing GUI ...`);
console.log(`[Asshat.GUI] Creating login GUI ...`); console.log(`[Asshat.GUI] Creating login GUI ...`);
login.window = mexui.window(game.width/2-150, game.height/2-115, 300, 280, 'LOGIN', { login.window = mexui.window(game.width/2-150, game.height/2-125, 300, 250, 'LOGIN', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
transitionTime: 500,
}, },
title: { title: {
textSize: 0.0, textSize: 0.0,
@@ -1087,12 +1089,19 @@ app.init = function()
icon: { icon: {
textSize: 0.0, textSize: 0.0,
textColour: toColour(0, 0, 0, 0), textColour: toColour(0, 0, 0, 0),
} },
focused: {
borderColour: toColour(0, 0, 0, 0),
},
}); });
login.window.titleBarIconSize = toVector2(0,0); login.window.titleBarIconSize = toVector2(0,0);
login.window.titleBarHeight = 0; login.window.titleBarHeight = 0;
login.logoImage = login.window.image(100, 20, 100, 100, "files/images/main-logo.png"); login.logoImage = login.window.image(100, 20, 100, 100, mainLogoPath, {
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
login.messageLabel = login.window.text(20, 135, 260, 20, 'Please enter your password!', { login.messageLabel = login.window.text(20, 135, 260, 20, 'Please enter your password!', {
main: { main: {
@@ -1100,25 +1109,31 @@ app.init = function()
textAlign: 0.5, textAlign: 0.5,
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textFont: robotoFont, textFont: robotoFont,
} },
focused: {
borderColour: toColour(0, 0, 0, 0),
},
}); });
login.passwordInput = login.window.textInput(20, 170, 260, 25, '', { login.passwordInput = login.window.textInput(20, 170, 260, 25, '', {
main: { main: {
backgroundColour: toColour(0, 0, 0, 120), backgroundColour: toColour(0, 0, 0, 120),
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], textInputAlpha),
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
}, },
caret: { caret: {
backgroundColour: toColour(200, 200, 200, 255), lineColour: toColour(255, 255, 255, 255),
}, },
placeholder: { placeholder: {
backgroundColour: toColour(0, 0, 0, 120), textColour: toColour(200, 200, 200, 150),
textColour: toColour(200, 200, 200, 200),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
} },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 255),
},
}); });
login.passwordInput.masked = true; login.passwordInput.masked = true;
login.passwordInput.placeholder = "Password"; login.passwordInput.placeholder = "Password";
@@ -1131,28 +1146,12 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
},
}, checkLogin); }, checkLogin);
login.notRegisteredLabel = login.window.text(20, 240, 175, 20, "Don't have an account?", { console.log(`[Asshat.GUI] Created login GUI`);
main: {
textSize: 10.0,
textAlign: 1.0,
textColour: toColour(200, 200, 200, 255),
textFont: robotoFont,
}
});
login.registerButton = login.window.button(205, 242, 75, 15, 'REGISTER', {
main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
textColour: toColour(0, 0, 0, 255),
textSize: 9.0,
textFont: robotoFont,
textAlign: 0.5,
},
}, showRegistration);
console.log(`[Asshat.GUI] Created login GUI.`);
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
@@ -1161,6 +1160,7 @@ app.init = function()
newCharacter.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'New Character', { newCharacter.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'New Character', {
main: { main: {
backgroundColour: toColour(0, 0, 0, 120), backgroundColour: toColour(0, 0, 0, 120),
transitionTime: 500,
}, },
title: { title: {
textSize: 11.0, textSize: 11.0,
@@ -1172,6 +1172,9 @@ app.init = function()
textColour: toColour(0, 0, 0, 0), textColour: toColour(0, 0, 0, 0),
backgroundColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0),
}, },
focused: {
borderColour: toColour(0, 0, 0, 0),
},
}); });
newCharacter.firstNameInput = newCharacter.window.textInput(10, 40, 200, 25, '', { newCharacter.firstNameInput = newCharacter.window.textInput(10, 40, 200, 25, '', {
@@ -1188,39 +1191,51 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
}, },
caret: { caret: {
backgroundColour: toColour(200, 200, 200, 255), lineColour: toColour(255, 255, 255, 255),
}, },
placeholder: { placeholder: {
backgroundColour: toColour(0, 0, 0, 200), backgroundColour: toColour(0, 0, 0, 200),
textColour: toColour(200, 200, 200, 200), textColour: toColour(200, 200, 200, 200),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
} },
focused: {
borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], textInputAlpha),
},
invalidValue: {
borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], textInputAlpha),
},
}); });
newCharacter.firstNameInput.placeholder = "First Name"; newCharacter.firstNameInput.placeholder = "First Name";
newCharacter.lastNameInput = newCharacter.window.textInput(10, 70, 200, 25, '', { newCharacter.lastNameInput = newCharacter.window.textInput(10, 70, 200, 25, '', {
main: { main: {
hover: { hover: {
backgroundColour: toColour(0, 0, 0, 200), backgroundColour: toColour(0, 0, 0, textInputAlpha),
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
}, },
backgroundColour: toColour(0, 0, 0, 200), backgroundColour: toColour(0, 0, 0, textInputAlpha),
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
}, },
caret: { caret: {
backgroundColour: toColour(200, 200, 200, 255), lineColour: toColour(255, 255, 255, 255),
}, },
placeholder: { placeholder: {
backgroundColour: toColour(0, 0, 0, 200), backgroundColour: toColour(0, 0, 0, textInputAlpha),
textColour: toColour(200, 200, 200, 200), textColour: toColour(150, 150, 150, 200),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
} },
focused: {
borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], 255),
},
invalidValue: {
borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], 255),
},
}); });
newCharacter.lastNameInput.placeholder = "Last Name"; newCharacter.lastNameInput.placeholder = "Last Name";
@@ -1236,7 +1251,13 @@ app.init = function()
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
} },
focused: {
borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], 255),
},
invalidValue: {
borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], 255),
},
}); });
newCharacter.placeOfOrigin = newCharacter.window.dropDown(10, 100, 200, 25, 'Place of Origin', { newCharacter.placeOfOrigin = newCharacter.window.dropDown(10, 100, 200, 25, 'Place of Origin', {
@@ -1266,21 +1287,26 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
width: 200, width: 200,
}, },
focused: {
borderColour: toColour(focusedColour[0], focusedColour[1], focusedColour[2], 255),
},
invalidValue: {
borderColour: toColour(invalidValueColour[0], invalidValueColour[1], invalidValueColour[2], 255),
},
}); });
for(let i in placesOfOrigin) { for(let i in placesOfOrigin) {
newCharacter.placeOfOrigin.item(placesOfOrigin[i]); newCharacter.placeOfOrigin.item(placesOfOrigin[i]);
} }
newCharacter.placeOfOrigin.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(primaryColour[0], primaryColour[1], primaryColour[2], 200); newCharacter.placeOfOrigin.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha);
newCharacter.placeOfOrigin.setScrollBarsManual(true); newCharacter.placeOfOrigin.setScrollBarsManual(true);
//if(gta.game == GAME_GTA_III) { newCharacter.skinImage = newCharacter.window.image(310, 32, 110, 70, "files/images/skins/none.png", {
// newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/gta3/Skin000.png"); focused: {
//} else { borderColour: toColour(0, 0, 0, 0),
// newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png"); },
//} });
newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png");
newCharacter.skinDropDown = newCharacter.window.dropDown(220, 100, 200, 25, 'Choose Skin', { newCharacter.skinDropDown = newCharacter.window.dropDown(220, 100, 200, 25, 'Choose Skin', {
main: { main: {
@@ -1296,16 +1322,9 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
width: 200, width: 200,
}, },
item: {
backgroundColour: toColour(0, 0, 0, 200),
textColour: toColour(200, 200, 200, 255),
textSize: 10.0,
textFont: robotoFont,
width: 200,
},
item: { item: {
hover: { hover: {
backgroundColour: toColour(32, 32, 32, 200), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 150),
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
@@ -1318,30 +1337,13 @@ app.init = function()
width: 200, width: 200,
}, },
}); });
// function() {
//let skinImagePath = skinNames[gta.game][this.selectedEntryIndex][2];
//if(newCharacter.skinImage != null) {
// newCharacter.skinImage.remove();
//}
//if(gta.game == GAME_GTA_III) { newCharacter.skinDropDown.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha);
// newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/gta3/" + toString(skinImagePath));
//} else {
// newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png");
//}
//newCharacter.skinImage = newCharacter.window.image(265, 30, 110, 70, "files/images/skins/none.png");
//}
newCharacter.skinDropDown.axis.y.scrollBar.styles.innerBar.backgroundColour = toColour(255, 128, 0, 200);
newCharacter.skinDropDown.setScrollBarsManual(true); newCharacter.skinDropDown.setScrollBarsManual(true);
for(let i in skinNames[gta.game]) { for(let i in skinNames[gta.game]) {
//if(skinNames[gta.game][i] != "INVALID") {
newCharacter.skinDropDown.item(skinNames[gta.game][i][1]); newCharacter.skinDropDown.item(skinNames[gta.game][i][1]);
//}
} }
//newCharacter.skinDropDown.selectedEntryIndex = 1;
newCharacter.createButton = newCharacter.window.button(220, 130, 200, 25, 'CREATE', { newCharacter.createButton = newCharacter.window.button(220, 130, 200, 25, 'CREATE', {
main: { main: {
@@ -1351,17 +1353,21 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
},
}, checkNewCharacter); }, checkNewCharacter);
console.log(`[Asshat.GUI] Creating new character GUI.`); console.log(`[Asshat.GUI] Created new character GUI`);
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating register GUI ...`); console.log(`[Asshat.GUI] Creating register GUI ...`);
register.window = mexui.window(game.width/2-130, game.height/2-140, 300, 260, 'Register', { register.window = mexui.window(game.width/2-130, game.height/2-115, 300, 230, 'Register', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
transitionTime: 500,
}, },
title: { title: {
textSize: 0.0, textSize: 0.0,
@@ -1377,7 +1383,11 @@ app.init = function()
register.window.titleBarIconSize = toVector2(0,0); register.window.titleBarIconSize = toVector2(0,0);
register.window.titleBarHeight = 0; register.window.titleBarHeight = 0;
register.window.image(115, 10, 65, 65, "files/images/main-logo.png"); register.window.image(115, 10, 65, 65, "files/images/main-logo.png", {
focused: {
borderColour: toColour(0, 0, 0, 0),
},
});
register.messageLabel = register.window.text(20, 75, 260, 20, 'Create an account', { register.messageLabel = register.window.text(20, 75, 260, 20, 'Create an account', {
main: { main: {
@@ -1385,7 +1395,10 @@ app.init = function()
textAlign: 0.5, textAlign: 0.5,
textColour: toColour(200, 200, 200, 255), textColour: toColour(200, 200, 200, 255),
textFont: robotoFont, textFont: robotoFont,
} },
focused: {
borderColour: toColour(0, 0, 0, 0),
},
}); });
register.passwordInput = register.window.textInput(20, 100, 260, 25, '', { register.passwordInput = register.window.textInput(20, 100, 260, 25, '', {
@@ -1396,7 +1409,7 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
}, },
caret: { caret: {
backgroundColour: toColour(200, 200, 200, 255), lineColour: toColour(255, 255, 255, 255),
}, },
placeholder: { placeholder: {
backgroundColour: toColour(0, 0, 0, 120), backgroundColour: toColour(0, 0, 0, 120),
@@ -1416,11 +1429,11 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
}, },
caret: { caret: {
backgroundColour: toColour(200, 200, 200, 255), lineColour: toColour(255, 255, 255, 255),
}, },
placeholder: { placeholder: {
backgroundColour: toColour(0, 0, 0, 120), backgroundColour: toColour(0, 0, 0, 120),
textColour: toColour(200, 200, 200, 200), textColour: toColour(150, 150, 150, 200),
textSize: 10.0, textSize: 10.0,
textFont: robotoFont, textFont: robotoFont,
} }
@@ -1436,7 +1449,7 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
}, },
caret: { caret: {
backgroundColour: toColour(200, 200, 200, 255), lineColour: toColour(255, 255, 255, 255),
}, },
placeholder: { placeholder: {
backgroundColour: toColour(0, 0, 0, 120), backgroundColour: toColour(0, 0, 0, 120),
@@ -1449,34 +1462,18 @@ app.init = function()
register.registerButton = register.window.button(20, 195, 260, 30, 'CREATE ACCOUNT', { register.registerButton = register.window.button(20, 195, 260, 30, 'CREATE ACCOUNT', {
main: { main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120), backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
textColour: toColour(255, 255, 255, 255), textColour: toColour(255, 255, 255, 255),
textSize: 12.0, textSize: 12.0,
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
},
}, checkRegistration); }, checkRegistration);
register.alreadyRegisteredLabel = register.window.text(20, 230, 175, 22, "Already have an account?", { console.log(`[Asshat.GUI] Created register GUI`);
main: {
textSize: 9.0,
textAlign: 1.0,
textColour: toColour(255, 255, 255, 255),
textFont: robotoFont,
}
});
register.loginButton = register.window.button(205, 232, 75, 15, 'LOGIN', {
main: {
backgroundColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], 120),
textColour: toColour(255, 255, 255, 255),
textSize: 9.0,
textAlign: 0.5,
textFont: robotoFont,
},
}, showLogin);
console.log(`[Asshat.GUI] Create register GUI ...`);
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
@@ -1485,6 +1482,7 @@ app.init = function()
errorDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'ERROR', { errorDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'ERROR', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
transitionTime: 500,
}, },
title: { title: {
textSize: 11.0, textSize: 11.0,
@@ -1517,11 +1515,16 @@ app.init = function()
}, },
}, closeErrorDialog); }, closeErrorDialog);
console.log(`[Asshat.GUI] Created error GUI ...`);
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Created prompt GUI ...`);
yesNoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Question', { yesNoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Question', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
transitionTime: 500,
}, },
title: { title: {
textSize: 11.0, textSize: 11.0,
@@ -1564,8 +1567,12 @@ app.init = function()
}, },
}, yesNoDialogAnswerNo); }, yesNoDialogAnswerNo);
console.log(`[Asshat.GUI] Created prompt GUI`);
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating info dialog GUI ...`);
infoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Information', { infoDialog.window = mexui.window(game.width/2-200, game.height/2-70, 400, 140, 'Information', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1601,8 +1608,12 @@ app.init = function()
}, },
}, closeInfoDialog); }, closeInfoDialog);
console.log(`[Asshat.GUI] Created info dialog GUI`);
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
console.log(`[Asshat.GUI] Creating character select GUI ...`);
characterSelect.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'Select Character', { characterSelect.window = mexui.window(game.width/2-215, game.height/2-83, 430, 166, 'Select Character', {
main: { main: {
backgroundColour: toColour(0, 0, 0, windowAlpha), backgroundColour: toColour(0, 0, 0, windowAlpha),
@@ -1616,7 +1627,7 @@ app.init = function()
textSize: 0.0, textSize: 0.0,
textColour: toColour(0, 0, 0, 0), textColour: toColour(0, 0, 0, 0),
backgroundColour: toColour(0, 0, 0, 0), backgroundColour: toColour(0, 0, 0, 0),
}, }
}); });
characterSelect.nameText = characterSelect.window.text(10, 40, 200, 25, 'Lastname, Firstname', { characterSelect.nameText = characterSelect.window.text(10, 40, 200, 25, 'Lastname, Firstname', {
@@ -1625,6 +1636,9 @@ app.init = function()
textAlign: 0.0, textAlign: 0.0,
textColour: toColour(255, 255, 255, 220), textColour: toColour(255, 255, 255, 220),
textFont: robotoFont, textFont: robotoFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
} }
}); });
@@ -1634,6 +1648,9 @@ app.init = function()
textAlign: 0.0, textAlign: 0.0,
textColour: toColour(255, 255, 255, 220), textColour: toColour(255, 255, 255, 220),
textFont: robotoFont, textFont: robotoFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
} }
}); });
@@ -1643,6 +1660,9 @@ app.init = function()
textAlign: 0.0, textAlign: 0.0,
textColour: toColour(255, 255, 255, 220), textColour: toColour(255, 255, 255, 220),
textFont: robotoFont, textFont: robotoFont,
},
focused: {
borderColour: toColour(0, 0, 0, 0),
} }
}); });
@@ -1654,6 +1674,9 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
}
}, selectThisCharacter); }, selectThisCharacter);
characterSelect.newCharacterButton = characterSelect.window.button(140, 180, 150, 25, 'NEW CHARACTER', { characterSelect.newCharacterButton = characterSelect.window.button(140, 180, 150, 25, 'NEW CHARACTER', {
@@ -1664,6 +1687,9 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
}
}, showNewCharacter); }, showNewCharacter);
characterSelect.previousCharacterButton = characterSelect.window.button(10, 130, 75, 25, '< PREV', { characterSelect.previousCharacterButton = characterSelect.window.button(10, 130, 75, 25, '< PREV', {
@@ -1674,6 +1700,9 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
}
}, selectPreviousCharacter); }, selectPreviousCharacter);
characterSelect.nextCharacterButton = characterSelect.window.button(345, 130, 75, 25, 'NEXT >', { characterSelect.nextCharacterButton = characterSelect.window.button(345, 130, 75, 25, 'NEXT >', {
@@ -1684,47 +1713,59 @@ app.init = function()
textFont: robotoFont, textFont: robotoFont,
textAlign: 0.5, textAlign: 0.5,
}, },
focused: {
borderColour: toColour(primaryColour[0], primaryColour[1], primaryColour[2], buttonAlpha),
}
}, selectNextCharacter); }, selectNextCharacter);
characterSelect.skinImage = characterSelect.window.image(265, 30, 110, 97, "files/images/skins/none.png"); characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png", {
focused: {
borderColour: toColour(0, 0, 0, 0),
}
});
console.log(`[Asshat.GUI] Created character select GUI`);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
console.log(`[Asshat.GUI] All GUI created successfully!`);
closeAllWindows();
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkLogin = function() { let checkLogin = function() {
console.log(`[Asshat.GUI] Checking login with server ...`);
triggerNetworkEvent("ag.checkLogin", login.passwordInput.lines[0]); triggerNetworkEvent("ag.checkLogin", login.passwordInput.lines[0]);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let loginFailed = function(errorMessage) { let loginFailed = function(errorMessage) {
//if(loginAttemptsRemaining >= 1) { console.log(`[Asshat.GUI] Server reports login failed`);
login.messageLabel.text = errorMessage; login.messageLabel.text = errorMessage;
login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); login.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
login.passwordInput.text = ""; login.passwordInput.text = "";
//} else {
// closeAllWindows();
//}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let loginSuccess = function() { let loginSuccess = function() {
console.log(`[Asshat.GUI] Server reports login was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkRegistration = function() { let checkRegistration = function() {
console.log(`[Asshat.GUI] Checking registration with server ...`);
triggerNetworkEvent("ag.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]); triggerNetworkEvent("ag.checkRegistration", register.passwordInput.lines[0], register.confirmPasswordInput.lines[0], register.emailInput.lines[0]);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let checkNewCharacter = function() { let checkNewCharacter = function() {
console.log(`[Asshat.GUI] Checking new character with server ...`);
let skinId = false; let skinId = false;
if(newCharacter.firstNameInput.lines[0].length < 2) { if(newCharacter.firstNameInput.lines[0].length < 2) {
@@ -1755,6 +1796,7 @@ let checkNewCharacter = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let registrationFailed = function(errorMessage) { let registrationFailed = function(errorMessage) {
console.log(`[Asshat.GUI] Server reports registration failed. Reason: ${errorMessage}`);
register.messageLabel.text = errorMessage; register.messageLabel.text = errorMessage;
register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255); register.messageLabel.styles.main.textColour = toColour(180, 32, 32, 255);
register.passwordInput.text = ""; register.passwordInput.text = "";
@@ -1765,18 +1807,21 @@ let registrationFailed = function(errorMessage) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let registrationSuccess = function() { let registrationSuccess = function() {
console.log(`[Asshat.GUI] Server reports registration was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let characterSelectSuccess = function() { let characterSelectSuccess = function() {
console.log(`[Asshat.GUI] Server reports character selection was successful`);
closeAllWindows(); closeAllWindows();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let closeErrorDialog = function() { let closeErrorDialog = function() {
console.log(`[Asshat.GUI] Closing error dialog`);
errorDialog.window.shown = false; errorDialog.window.shown = false;
mexui.setInput(false); mexui.setInput(false);
} }
@@ -1784,6 +1829,7 @@ let closeErrorDialog = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let closeInfoDialog = function() { let closeInfoDialog = function() {
console.log(`[Asshat.GUI] Closing info dialog`);
infoDialog.window.shown = false; infoDialog.window.shown = false;
mexui.setInput(false); mexui.setInput(false);
} }
@@ -1791,6 +1837,7 @@ let closeInfoDialog = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let closeAllWindows = function() { let closeAllWindows = function() {
console.log(`[Asshat.GUI] Closing all GUI windows`);
infoDialog.window.shown = false; infoDialog.window.shown = false;
errorDialog.window.shown = false; errorDialog.window.shown = false;
yesNoDialog.window.shown = false; yesNoDialog.window.shown = false;
@@ -1805,20 +1852,23 @@ let closeAllWindows = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let yesNoDialogAnswerNo = function() { let yesNoDialogAnswerNo = function() {
console.log(`[Asshat.GUI] Responding with answer NO to server prompt`);
triggerNetworkEvent("ag.promptAnswerNo"); triggerNetworkEvent("ag.promptAnswerNo");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let yesNoDialogAnswerYes = function() { let yesNoDialogAnswerYes = function() {
console.log(`[Asshat.GUI] Responding with answer YES to server prompt`);
triggerNetworkEvent("ag.promptAnswerYes"); triggerNetworkEvent("ag.promptAnswerYes");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showRegistration = function() { let showRegistration = function() {
setChatWindowEnabled(false); console.log(`[Asshat.GUI] Showing registration window`);
closeAllWindows(); closeAllWindows();
setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
register.window.shown = true; register.window.shown = true;
} }
@@ -1826,35 +1876,33 @@ let showRegistration = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showLogin = function() { let showLogin = function() {
console.log("login showing");
setChatWindowEnabled(false);
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing login window`);
setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
login.window.shown = true; login.window.shown = true;
console.log("login shown");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { let showCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing character selection window`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
characterSelect.nameText.text = lastName + ", " + firstName; characterSelect.nameText.text = lastName + ", " + firstName;
characterSelect.dateOfBirthText.text = "Born: " + toString(dateOfBirth); characterSelect.dateOfBirthText.text = "Born: " + toString(dateOfBirth);
characterSelect.placeOfOrigin.text = "From: " + toString(placeOfOrigin); characterSelect.placeOfOrigin.text = "From: " + toString(placeOfOrigin);
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.skinImage = characterSelect.window.image(265, 30, 110, 97, "files/images/skins/none.png");
characterSelect.window.shown = true; characterSelect.window.shown = true;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showError = function(errorMessage, errorTitle) { let showError = function(errorMessage, errorTitle) {
setChatWindowEnabled(false);
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing error window. Error: ${errorTitle} - ${errorMessage}`);
setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
errorDialog.messageLabel.text = errorMessage; errorDialog.messageLabel.text = errorMessage;
errorDialog.window.shown = true; errorDialog.window.shown = true;
@@ -1864,6 +1912,7 @@ let showError = function(errorMessage, errorTitle) {
let showYesNo = function(promptMessage, promptTitle) { let showYesNo = function(promptMessage, promptTitle) {
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing prompt window. Prompt: ${promptTitle} - ${promptMessage}`);
mexui.setInput(true); mexui.setInput(true);
yesNoDialog.messageLabel.text = promptMessage; yesNoDialog.messageLabel.text = promptMessage;
yesNoDialog.window.shown = true; yesNoDialog.window.shown = true;
@@ -1872,8 +1921,8 @@ let showYesNo = function(promptMessage, promptTitle) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showInfo = function(infoMessage, infoTitle) { let showInfo = function(infoMessage, infoTitle) {
setChatWindowEnabled(false);
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing info dialog window. Info: ${infoTitle} - ${infoMessage}`);
mexui.setInput(true); mexui.setInput(true);
infoDialog.messageLabel.text = infoMessage; infoDialog.messageLabel.text = infoMessage;
infoDialog.window.shown = true; infoDialog.window.shown = true;
@@ -1882,8 +1931,9 @@ let showInfo = function(infoMessage, infoTitle) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let showNewCharacter = function() { let showNewCharacter = function() {
setChatWindowEnabled(false);
closeAllWindows(); closeAllWindows();
console.log(`[Asshat.GUI] Showing info dialog window`);
setChatWindowEnabled(false);
mexui.setInput(true); mexui.setInput(true);
newCharacter.window.shown = true; newCharacter.window.shown = true;
} }
@@ -1891,91 +1941,104 @@ let showNewCharacter = function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let selectNextCharacter = function() { let selectNextCharacter = function() {
console.log(`[Asshat.GUI] Requesting next character info from server for character select window`);
triggerNetworkEvent("ag.nextCharacter"); triggerNetworkEvent("ag.nextCharacter");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let selectPreviousCharacter = function() { let selectPreviousCharacter = function() {
console.log(`[Asshat.GUI] Requesting previous character info from server for character select window`);
triggerNetworkEvent("ag.previousCharacter"); triggerNetworkEvent("ag.previousCharacter");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let selectThisCharacter = function() { let selectThisCharacter = function() {
console.log(`[Asshat.GUI] Tell server the current shown character was selected in character select window`);
triggerNetworkEvent("ag.selectCharacter"); triggerNetworkEvent("ag.selectCharacter");
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
let switchCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { let switchCharacterSelect = function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
console.log(`[Asshat.GUI] Updating character info with data from server`);
setChatWindowEnabled(false); setChatWindowEnabled(false);
characterSelect.window.shown = false; characterSelect.window.shown = false;
characterSelect.nameText.text = lastName + ", " + firstName; characterSelect.nameText.text = lastName + ", " + firstName;
characterSelect.dateOfBirthText.text = "Born: " + toString(dateOfBirth); characterSelect.dateOfBirthText.text = "Born: " + toString(dateOfBirth);
characterSelect.placeOfOrigin.text = "From: " + toString(placeOfOrigin); characterSelect.placeOfOrigin.text = "From: " + toString(placeOfOrigin);
characterSelect.skinImage = characterSelect.window.image(310, 32, 100, 90, "files/images/skins/none.png");
characterSelect.skinImage = characterSelect.window.image(265, 30, 110, 97, "files/images/skins/none.png");
characterSelect.window.shown = true; characterSelect.window.shown = true;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showLogin", function() { addNetworkHandler("ag.showLogin", function() {
console.log(`[Asshat.GUI] Received request from server to show login window`);
showLogin(); showLogin();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showRegistration", function() { addNetworkHandler("ag.showRegistration", function() {
console.log(`[Asshat.GUI] Received request from server to show registration window`);
showRegistration(); showRegistration();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showNewCharacter", function() { addNetworkHandler("ag.showNewCharacter", function() {
console.log(`[Asshat.GUI] Received request from server to show new character window`);
showNewCharacter(); showNewCharacter();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { addNetworkHandler("ag.showCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
console.log(`[Asshat.GUI] Received request from server to show character selection window`);
showCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId); showCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.switchCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) { addNetworkHandler("ag.switchCharacterSelect", function(firstName, lastName, placeOfOrigin, dateOfBirth, skinId) {
console.log(`[Asshat.GUI] Received request from server to update character selection window with new info`);
switchCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId); switchCharacterSelect(firstName, lastName, placeOfOrigin, dateOfBirth, skinId);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showError", function(errorMessage, errorTitle) { addNetworkHandler("ag.showError", function(errorMessage, errorTitle) {
console.log(`[Asshat.GUI] Received request from server to show error window`);
showError(errorMessage, errorTitle); showError(errorMessage, errorTitle);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showPrompt", function(promptMessage, promptTitle) { addNetworkHandler("ag.showPrompt", function(promptMessage, promptTitle) {
console.log(`[Asshat.GUI] Received request from server to show prompt window`);
showYesNo(promptMessage, promptTitle); showYesNo(promptMessage, promptTitle);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.showInfo", function(infoMessage) { addNetworkHandler("ag.showInfo", function(infoMessage) {
console.log(`[Asshat.GUI] Received request from server to show info dialog`);
showInfo(infoMessage); showInfo(infoMessage);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.loginSuccess", function() { addNetworkHandler("ag.loginSuccess", function() {
console.log(`[Asshat.GUI] Received signal of successful login from server`);
loginSuccess(); loginSuccess();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.characterSelectSuccess", function() { addNetworkHandler("ag.characterSelectSuccess", function() {
console.log(`[Asshat.GUI] Received signal of successful character selection from server`);
characterSelectSuccess(); characterSelectSuccess();
setChatWindowEnabled(true); setChatWindowEnabled(true);
}); });
@@ -1983,28 +2046,34 @@ addNetworkHandler("ag.characterSelectSuccess", function() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.loginFailed", function(remainingAttempts) { addNetworkHandler("ag.loginFailed", function(remainingAttempts) {
console.log(`[Asshat.GUI] Received signal of failed login from server`);
loginFailed(remainingAttempts); loginFailed(remainingAttempts);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.registrationSuccess", function() { addNetworkHandler("ag.registrationSuccess", function() {
console.log(`[Asshat.GUI] Received signal of successful registration from server`);
registrationSuccess(); registrationSuccess();
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.registrationFailed", function(errorMessage) { addNetworkHandler("ag.registrationFailed", function(errorMessage) {
console.log(`[Asshat.GUI] Received signal of failed registration from server`);
registrationFailed(errorMessage); registrationFailed(errorMessage);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.guiColour", function(red, green, blue) { addNetworkHandler("ag.guiColour", function(red, green, blue) {
console.log("New colours for GUI"); console.log(`[Asshat.GUI] Received new GUI colours from server`);
primaryColour = [red, green, blue]; primaryColour = [red, green, blue];
focusedColour = [red+focusedColourOffset, green+focusedColourOffset, blue+focusedColourOffset];
console.log(`[Asshat.GUI] Initializing MexUI app`);
app.init(); app.init();
closeAllWindows(); triggerNetworkEvent("ag.guiReady", true);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -72,6 +72,9 @@ bindEventHandler("onResourceStart", thisResource, function(event, resource) {
gta.setCiviliansEnabled(false); gta.setCiviliansEnabled(false);
} }
// Run garbage collector every minute
garbageCollectorInterval = setInterval(collectAllGarbage, 1000*60);
addNetworkHandler("ag.passenger", enterVehicleAsPassenger); addNetworkHandler("ag.passenger", enterVehicleAsPassenger);
}); });
@@ -338,6 +341,12 @@ function processEvent(event, deltaTime) {
} }
}); });
getElementsByType(ELEMENT_PICKUP).forEach(function(pickup) {
if(pickup.owner != -1) {
destroyElement(pickup);
}
});
if(gta.game == GAME_GTA_SA) { if(gta.game == GAME_GTA_SA) {
if(jobRouteStopSphere != null) { if(jobRouteStopSphere != null) {
if(position.distance(jobRouteStopSphere.position) <= 2.0) { if(position.distance(jobRouteStopSphere.position) <= 2.0) {
@@ -381,11 +390,13 @@ addEventHandler("OnDrawnHUD", function (event) {
} }
// Draw logo in corner of screen // Draw logo in corner of screen
if(mainLogo != null && showLogo) { if(mainLogo != null) {
if(showLogo) {
let logoPos = toVector2(gta.width-132, gta.height-132); let logoPos = toVector2(gta.width-132, gta.height-132);
let logoSize = toVector2(128, 128); let logoSize = toVector2(128, 128);
drawing.drawRectangle(mainLogo, logoPos, logoSize); drawing.drawRectangle(mainLogo, logoPos, logoSize);
} }
}
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -482,9 +493,7 @@ addNetworkHandler("ag.showBusStop", function(position, colour) {
jobRouteStopSphere.colour = colour; jobRouteStopSphere.colour = colour;
} }
jobRouteStopBlip = gta.createBlip(position, 0, 2, colour); jobRouteStopBlip = gta.createBlip(position, 0, 2, colour);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -18,7 +18,7 @@ addEventHandler("onProcess", function(event, deltaTime) {
if(localPlayer != null && localPlayer.getData("ag.spawned") != null) { if(localPlayer != null && localPlayer.getData("ag.spawned") != null) {
if(localPlayer.health <= 0) { if(localPlayer.health <= 0) {
localPlayer.clearWeapons(); localPlayer.clearWeapons();
triggerNetworkEvent("ag.player.death", localPlayer.position, localPlayer.heading.toFixed(2)); triggerNetworkEvent("ag.player.death", localPlayer.position);
} }
} }
}); });

View File

@@ -295,7 +295,7 @@ function loadAccountFromName(accountName, fullLoad = false) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if(dbConnection) { if(dbConnection) {
accountName = escapeDatabaseString(dbConnection, accountName); accountName = escapeDatabaseString(dbConnection, accountName);
let dbQueryString = `SELECT * FROM acct_main WHERE acct_name = '${accountName}' LIMIT 1;`; let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ipstring FROM acct_main WHERE acct_name = '${accountName}' LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString); let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) { if(dbQuery) {
if(dbQuery.numRows > 0) { if(dbQuery.numRows > 0) {
@@ -322,7 +322,7 @@ function loadAccountFromName(accountName, fullLoad = false) {
function loadAccountFromId(accountId, fullLoad = false) { function loadAccountFromId(accountId, fullLoad = false) {
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if(dbConnection) { if(dbConnection) {
let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ip FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`; let dbQueryString = `SELECT *, INET_NTOA(acct_ip) AS ipstring FROM acct_main WHERE acct_id = ${accountId} LIMIT 1;`;
let dbQuery = queryDatabase(dbConnection, dbQueryString); let dbQuery = queryDatabase(dbConnection, dbQueryString);
if(dbQuery) { if(dbQuery) {
let dbAssoc = fetchQueryAssoc(dbQuery); let dbAssoc = fetchQueryAssoc(dbQuery);
@@ -544,13 +544,13 @@ function checkLogin(client, password) {
let loginAttemptsRemaining = getEntityData(client, "ag.loginAttemptsRemaining")-1; let loginAttemptsRemaining = getEntityData(client, "ag.loginAttemptsRemaining")-1;
if(isPlayerLoggedIn(client)) { if(isPlayerLoggedIn(client)) {
console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.loginSuccess", client); triggerNetworkEvent("ag.loginSuccess", client);
console.log(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} has successfully logged in`);
} else { } else {
messagePlayerError(client, "You are already logged in!"); messagePlayerError(client, "You are already logged in!");
console.warn(`[Asshat.Account] ${getPlayerDisplayForConsole(client)} attempted to login but is already logged in`);
} }
return false; return false;
} }

View File

@@ -105,6 +105,8 @@ function createBusinessCommand(command, params, client) {
createBusinessEntranceBlip(getServerData().businesses.length-1); createBusinessEntranceBlip(getServerData().businesses.length-1);
createBusinessExitBlip(getServerData().businesses.length-1); createBusinessExitBlip(getServerData().businesses.length-1);
saveBusinessToDatabase(getServerData().businesses.length-1);
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created business [#0099FF]${tempBusinessData.name}`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]created business [#0099FF]${tempBusinessData.name}`);
} }
@@ -403,6 +405,55 @@ function setBusinessPickupCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function setBusinessInteriorTypeCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "business";
let businessId = getBusinessFromParams(splitParams[1]) || (isPlayerInAnyBusiness(client)) ? getPlayerBusiness(client) : getClosestBusinessEntrance(getPlayerPosition(client));
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business not found!");
return false;
}
if(isNaN(typeParam)) {
if(toLowerCase(typeParam) == "none") {
getBusinessData(businessId).exitPosition = toVector3(0.0, 0.0, 0.0);
getBusinessData(businessId).exitInterior = 0;
getBusinessData(businessId).hasInterior = false;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]remove business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]interior`);
return false;
}
if(isNull(getGameConfig().interiorTemplates[getServerGame()][typeParam])) {
messagePlayerError(client, "Invalid interior type! Use an interior type name or an existing business database ID");
messagePlayerInfo(client, `Interior Types: [#AAAAAA]${Object.keys(getGameConfig().interiorTemplates[getServerGame()]).join(", ")}`)
return false;
}
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set business [#0099FF]${getBusinessData(businessId).name} [#FFFFFF]interior type to [#AAAAAA]${toLowerCase(typeParam)}`);
getBusinessData(businessId).exitPosition = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitPosition;
getBusinessData(businessId).exitInterior = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitInterior;
getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart;
getBusinessData(businessId).hasInterior = true;
} else {
if(!getBusinessData(businessId)) {
messagePlayerError(client, "Business ID not found!");
return false;
}
getBusinessData(businessId).exitPosition = getBusinessData(businessId).exitPosition;
getBusinessData(businessId).exitInterior = getBusinessData(businessId).exitInterior;
getBusinessData(businessId).exitDimension = getBusinessData(businessId).databaseId+getGlobalConfig().businessDimensionStart;
getBusinessData(businessId).hasInterior = true;
}
deleteBusinessEntrancePickup(businessId);
deleteBusinessExitPickup(businessId);
createBusinessEntrancePickup(businessId);
createBusinessExitPickup(businessId);
}
// ---------------------------------------------------------------------------
function setBusinessBlipCommand(command, params, client) { function setBusinessBlipCommand(command, params, client) {
let splitParams = params.split(" "); let splitParams = params.split(" ");
@@ -625,11 +676,11 @@ function saveBusinessToDatabase(businessId) {
if(dbConnection) { if(dbConnection) {
let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name); let safeBusinessName = escapeDatabaseString(dbConnection, tempBusinessData.name);
if(tempBusinessData.databaseId == 0) { if(tempBusinessData.databaseId == 0) {
let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.exitDimension})`; let dbQueryString = `INSERT INTO biz_main (biz_server, biz_name, biz_owner_type, biz_owner_id, biz_locked, biz_entrance_fee, biz_till, biz_entrance_pos_x, biz_entrance_pos_y, biz_entrance_pos_z, biz_entrance_rot_z, biz_entrance_int, biz_entrance_vw, biz_exit_pos_x, biz_exit_pos_y, biz_exit_pos_z, biz_exit_rot_z, biz_exit_int, biz_exit_vw) VALUES (${getServerId()}, '${safeBusinessName}', ${tempBusinessData.ownerType}, ${tempBusinessData.ownerId}, ${boolToInt(tempBusinessData.locked)}, ${tempBusinessData.entranceFee}, ${tempBusinessData.till}, ${tempBusinessData.entrancePosition.x}, ${tempBusinessData.entrancePosition.y}, ${tempBusinessData.entrancePosition.z}, ${tempBusinessData.entranceRotation}, ${tempBusinessData.entranceInterior}, ${tempBusinessData.entranceDimension}, ${tempBusinessData.exitPosition.x}, ${tempBusinessData.exitPosition.y}, ${tempBusinessData.exitPosition.z}, ${tempBusinessData.exitRotation}, ${tempBusinessData.exitInterior}, ${tempBusinessData.databaseId+getGlobalConfig().businessDimensionStart}, ${boolToInt(tempBusinessData.hasInterior)})`;
queryDatabase(dbConnection, dbQueryString); queryDatabase(dbConnection, dbQueryString);
getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection); getServerData().businesses[businessId].databaseId = getDatabaseInsertId(dbConnection);
} else { } else {
let dbQueryString = `UPDATE biz_main SET biz_name='${safeBusinessName}', biz_owner_type=${tempBusinessData.ownerType}, biz_owner_id=${tempBusinessData.ownerId}, biz_locked=${boolToInt(tempBusinessData.locked)}, biz_entrance_fee=${tempBusinessData.entranceFee}, biz_till=${tempBusinessData.till}, biz_entrance_pos_x=${tempBusinessData.entrancePosition.x}, biz_entrance_pos_y=${tempBusinessData.entrancePosition.y}, biz_entrance_pos_z=${tempBusinessData.entrancePosition.z}, biz_entrance_rot_z=${tempBusinessData.entranceRotation}, biz_entrance_int=${tempBusinessData.entranceInterior}, biz_entrance_vw=${tempBusinessData.entranceDimension}, biz_exit_pos_x=${tempBusinessData.exitPosition.x}, biz_exit_pos_y=${tempBusinessData.exitPosition.y}, biz_exit_pos_z=${tempBusinessData.exitPosition.z}, biz_exit_rot_z=${tempBusinessData.exitRotation}, biz_exit_int=${tempBusinessData.exitInterior}, biz_exit_vw=${tempBusinessData.exitDimension} WHERE biz_id=${tempBusinessData.databaseId}`; let dbQueryString = `UPDATE biz_main SET biz_name='${safeBusinessName}', biz_owner_type=${tempBusinessData.ownerType}, biz_owner_id=${tempBusinessData.ownerId}, biz_locked=${boolToInt(tempBusinessData.locked)}, biz_entrance_fee=${tempBusinessData.entranceFee}, biz_till=${tempBusinessData.till}, biz_entrance_pos_x=${tempBusinessData.entrancePosition.x}, biz_entrance_pos_y=${tempBusinessData.entrancePosition.y}, biz_entrance_pos_z=${tempBusinessData.entrancePosition.z}, biz_entrance_rot_z=${tempBusinessData.entranceRotation}, biz_entrance_int=${tempBusinessData.entranceInterior}, biz_entrance_vw=${tempBusinessData.entranceDimension}, biz_exit_pos_x=${tempBusinessData.exitPosition.x}, biz_exit_pos_y=${tempBusinessData.exitPosition.y}, biz_exit_pos_z=${tempBusinessData.exitPosition.z}, biz_exit_rot_z=${tempBusinessData.exitRotation}, biz_exit_int=${tempBusinessData.exitInterior}, biz_exit_vw=${tempBusinessData.exitDimension}, biz_has_interior=${boolToInt(tempBusinessData.hasInterior)} WHERE biz_id=${tempBusinessData.databaseId}`;
queryDatabase(dbConnection, dbQueryString); queryDatabase(dbConnection, dbQueryString);
} }
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
@@ -849,34 +900,9 @@ function doesBusinessHaveInterior(businessId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function sendAllBusinessLabelsToPlayer(client) {
let tempBusinessLabels = [];
let totalBusinesses = getServerData().businesses.length;
let businessesPerNetworkEvent = 100;
let totalNetworkEvents = Math.ceil(totalBusinesses/businessesPerNetworkEvent);
for(let i = 0 ; i < totalNetworkEvents ; i++) {
for(let j = 0 ; j < businessesPerNetworkEvent ; j++) {
let tempBusinessId = (i*businessesPerNetworkEvent)+j;
if(typeof getServerData().businesses[tempBusinessId] != "undefined") {
let tempBusinessLabels = [];
tempBusinessLabels.push([tempBusinessId, getServerData().businesses[tempBusinessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[tempBusinessId].description, getServerData().businesses[tempBusinessId].locked, false]);
}
}
triggerNetworkEvent("ag.bizlabel.all", client, tempBusinessLabels);
tempBusinessLabels = [];
}
}
// ---------------------------------------------------------------------------
function sendBusinessLabelToPlayers(businessId) {
triggerNetworkEvent("ag.bizlabel.add", null, businessId, getServerData().businesses[businessId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().businesses[businessId].name, getServerData().businesses[businessId].locked, false);
}
// ---------------------------------------------------------------------------
function deleteBusinessEntrancePickup(businessId) { function deleteBusinessEntrancePickup(businessId) {
if(getBusinessData(businessId).entrancePickup) { if(getBusinessData(businessId).entrancePickup != null) {
removeFromWorld(getBusinessData(businessId).entrancePickup);
destroyElement(getBusinessData(businessId).entrancePickup); destroyElement(getBusinessData(businessId).entrancePickup);
getBusinessData(businessId).entrancePickup = false; getBusinessData(businessId).entrancePickup = false;
} }
@@ -885,7 +911,8 @@ function deleteBusinessEntrancePickup(businessId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function deleteBusinessExitPickup(businessId) { function deleteBusinessExitPickup(businessId) {
if(getBusinessData(businessId).exitPickup) { if(getBusinessData(businessId).exitPickup != null) {
removeFromWorld(getBusinessData(businessId).exitPickup);
destroyElement(getBusinessData(businessId).exitPickup); destroyElement(getBusinessData(businessId).exitPickup);
getBusinessData(businessId).exitPickup = false; getBusinessData(businessId).exitPickup = false;
} }
@@ -894,7 +921,8 @@ function deleteBusinessExitPickup(businessId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function deleteBusinessEntranceBlip(businessId) { function deleteBusinessEntranceBlip(businessId) {
if(getBusinessData(businessId).entranceBlip) { if(getBusinessData(businessId).entranceBlip != null) {
removeFromWorld(getBusinessData(businessId).entranceBlip);
destroyElement(getBusinessData(businessId).entranceBlip); destroyElement(getBusinessData(businessId).entranceBlip);
getBusinessData(businessId).entranceBlip = false; getBusinessData(businessId).entranceBlip = false;
} }
@@ -903,7 +931,8 @@ function deleteBusinessEntranceBlip(businessId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function deleteBusinessExitBlip(businessId) { function deleteBusinessExitBlip(businessId) {
if(getBusinessData(businessId).exitBlip) { if(getBusinessData(businessId).exitBlip != null) {
removeFromWorld(getBusinessData(businessId).exitBlip);
destroyElement(getBusinessData(businessId).exitBlip); destroyElement(getBusinessData(businessId).exitBlip);
getBusinessData(businessId).exitBlip = false; getBusinessData(businessId).exitBlip = false;
} }
@@ -932,10 +961,6 @@ function reloadAllBusinessesCommand(command, params, client) {
createAllBusinessPickups(); createAllBusinessPickups();
createAllBusinessBlips(); createAllBusinessBlips();
for(let i in clients) {
sendAllBusinessLabelsToPlayer(clients[i]);
}
messageAdminAction(`All businesses have been reloaded by an admin!`); messageAdminAction(`All businesses have been reloaded by an admin!`);
} }

View File

@@ -120,10 +120,30 @@ function initClassTable() {
}, },
accountData: class { accountData: class {
constructor(accountAssoc) { constructor(accountAssoc) {
if(!accountAssoc) { this.databaseId = 0;
return; this.name = "";
} this.password = "";
this.registerDate = 0;
this.flags = {
moderation: 0,
settings: 0,
admin: 0,
};
this.staffTitle = "";
this.ircAccount = "";
this.discordAccount = 0,
this.settings = 0,
this.emailAddress = "";
this.ipAddress = 0,
this.notes = [];
this.messages = [];
this.keyBinds = [];
this.contacts = [];
this.subAccounts = [];
this.loggedIn = false;
if(accountAssoc) {
this.databaseId = accountAssoc["acct_id"]; this.databaseId = accountAssoc["acct_id"];
this.name = accountAssoc["acct_name"]; this.name = accountAssoc["acct_name"];
this.password = accountAssoc["acct_pass"]; this.password = accountAssoc["acct_pass"];
@@ -138,7 +158,7 @@ function initClassTable() {
this.discordAccount = accountAssoc["acct_discord"]; this.discordAccount = accountAssoc["acct_discord"];
this.settings = accountAssoc["acct_settings"]; this.settings = accountAssoc["acct_settings"];
this.emailAddress = accountAssoc["acct_email"]; this.emailAddress = accountAssoc["acct_email"];
this.ipAddress = accountAssoc["ip"]; this.ipAddress = accountAssoc["ipstring"];
this.notes = []; this.notes = [];
this.messages = []; this.messages = [];
@@ -147,6 +167,7 @@ function initClassTable() {
this.subAccounts = []; this.subAccounts = [];
this.loggedIn = false; this.loggedIn = false;
} }
}
}, },
accountContactData: class { accountContactData: class {
constructor(accountContactAssoc) { constructor(accountContactAssoc) {
@@ -276,8 +297,6 @@ function initClassTable() {
this.entranceDimension = toInteger(businessAssoc["biz_entrance_vw"]); this.entranceDimension = toInteger(businessAssoc["biz_entrance_vw"]);
this.entrancePickupModel = toInteger(businessAssoc["biz_entrance_pickup"]); this.entrancePickupModel = toInteger(businessAssoc["biz_entrance_pickup"]);
this.entranceBlipModel = toInteger(businessAssoc["biz_entrance_blip"]); this.entranceBlipModel = toInteger(businessAssoc["biz_entrance_blip"]);
this.entrancePickup = null;
this.entrancePickup = null;
this.exitPosition = toVector3(businessAssoc["biz_exit_pos_x"], businessAssoc["biz_exit_pos_y"], businessAssoc["biz_exit_pos_z"]); this.exitPosition = toVector3(businessAssoc["biz_exit_pos_x"], businessAssoc["biz_exit_pos_y"], businessAssoc["biz_exit_pos_z"]);
this.exitRotation = toInteger(businessAssoc["biz_exit_rot_z"]); this.exitRotation = toInteger(businessAssoc["biz_exit_rot_z"]);
@@ -285,8 +304,6 @@ function initClassTable() {
this.exitDimension = toInteger(businessAssoc["biz_exit_vw"]); this.exitDimension = toInteger(businessAssoc["biz_exit_vw"]);
this.exitPickupModel = toInteger(businessAssoc["biz_exit_pickup"]); this.exitPickupModel = toInteger(businessAssoc["biz_exit_pickup"]);
this.exitBlipModel = toInteger(businessAssoc["biz_exit_blip"]); this.exitBlipModel = toInteger(businessAssoc["biz_exit_blip"]);
this.exitPickup = null;
this.exitBlip = null;
this.entranceFee = toInteger(businessAssoc["biz_entrance_fee"]); this.entranceFee = toInteger(businessAssoc["biz_entrance_fee"]);
this.till = toInteger(businessAssoc["biz_till"]); this.till = toInteger(businessAssoc["biz_till"]);
@@ -353,8 +370,6 @@ function initClassTable() {
this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]); this.entranceDimension = toInteger(houseAssoc["house_entrance_vw"]);
this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]); this.entrancePickupModel = toInteger(houseAssoc["house_entrance_pickup"]);
this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]); this.entranceBlipModel = toInteger(houseAssoc["house_entrance_blip"]);
this.entrancePickup = null;
this.entranceBlip = null;
this.exitPosition = toVector3(toFloat(houseAssoc["house_exit_pos_x"]), toFloat(houseAssoc["house_exit_pos_y"]), toFloat(houseAssoc["house_exit_pos_z"])); this.exitPosition = toVector3(toFloat(houseAssoc["house_exit_pos_x"]), toFloat(houseAssoc["house_exit_pos_y"]), toFloat(houseAssoc["house_exit_pos_z"]));
this.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]); this.exitRotation = toFloat(houseAssoc["house_exit_rot_z"]);
@@ -362,8 +377,6 @@ function initClassTable() {
this.exitDimension = toInteger(houseAssoc["house_exit_vw"]); this.exitDimension = toInteger(houseAssoc["house_exit_vw"]);
this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]); this.exitPickupModel = toInteger(houseAssoc["house_exit_pickup"]);
this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]); this.exitBlipModel = toInteger(houseAssoc["house_exit_blip"]);
this.exitPickup = null;
this.exitBlip = null;
} }
} }
}, },
@@ -692,6 +705,12 @@ function initClassTable() {
this.range = range; this.range = range;
} }
}, },
interiorTemplateData: class {
constructor(exitPosition, interior) {
this.exitPosition = exitPosition;
this.interior = interior;
}
},
} }
return tempClasses; return tempClasses;

View File

@@ -99,8 +99,8 @@ addNetworkHandler("ag.heldKey", function(client, key) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.player.death", function(client, position, heading) { addNetworkHandler("ag.player.death", function(client, position) {
processPlayerDeath(client); processPlayerDeath(client, position);
}); });
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -143,6 +143,13 @@ addNetworkHandler("ag.clientReady", function(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
addNetworkHandler("ag.guiReady", function(client) {
client.setData("ag.guiReady", true, false);
console.log(`${getPlayerDisplayForConsole(client)}'s client GUI is initialized and ready!`);
});
// ---------------------------------------------------------------------------
addNetworkHandler("ag.clientStarted", function(client) { addNetworkHandler("ag.clientStarted", function(client) {
client.setData("ag.isStarted", true, false); client.setData("ag.isStarted", true, false);
console.log(`${getPlayerDisplayForConsole(client)}'s client resources are started and running!`); console.log(`${getPlayerDisplayForConsole(client)}'s client resources are started and running!`);

View File

@@ -59,6 +59,7 @@ function loadCommandData() {
commandData("bizinfo", getBusinessInfoCommand, "[id]", getStaffFlagValue("none"), true, true), commandData("bizinfo", getBusinessInfoCommand, "[id]", getStaffFlagValue("none"), true, true),
commandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizentrance", moveBusinessEntranceCommand, "", getStaffFlagValue("manageBusinesses"), true, true),
commandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("manageBusinesses"), true, true), commandData("bizexit", moveBusinessExitCommand, "", getStaffFlagValue("manageBusinesses"), true, true),
commandData("bizinttype", setBusinessInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageBusinesses"), true, true),
], ],
chat: [ chat: [
commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false), commandData("me", meActionCommand, "<message>", getStaffFlagValue("none"), true, false),
@@ -142,6 +143,7 @@ function loadCommandData() {
commandData("houseinfo", getHouseInfoCommand, "[id]", getStaffFlagValue("none"), true, true), commandData("houseinfo", getHouseInfoCommand, "[id]", getStaffFlagValue("none"), true, true),
commandData("houseentrance", moveHouseEntranceCommand, "", getStaffFlagValue("manageHouses"), true, true), commandData("houseentrance", moveHouseEntranceCommand, "", getStaffFlagValue("manageHouses"), true, true),
commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true), commandData("houseexit", moveHouseExitCommand, "", getStaffFlagValue("manageHouses"), true, true),
commandData("houseinttype", setHouseInteriorTypeCommand, "<interior template name/business id>", getStaffFlagValue("manageHouses"), true, true),
], ],
item: [], item: [],
job: [ job: [

View File

@@ -37,8 +37,8 @@ let globalConfig = {
], ],
exitPropertyDistance: 3.0, exitPropertyDistance: 3.0,
enterPropertyDistance: 3.0, enterPropertyDistance: 3.0,
businessDimensionStart: 1000, businessDimensionStart: 5000,
houseDimensionStart: 3000, houseDimensionStart: 100,
buyVehicleDriveAwayDistance: 25.0, buyVehicleDriveAwayDistance: 25.0,
returnToJobVehicleTime: 30, returnToJobVehicleTime: 30,
}; };
@@ -222,21 +222,48 @@ let gameConfig = {
removedWorldObjects: [ removedWorldObjects: [
false, false,
[ [
new serverClasses.removedWorldObjectData("fraightback04", new Vec3(1229.88, -84.8012, 13.4004), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot new serverClasses.removedWorldObjectData("fraightback04", toVector3(1229.88, -84.8012, 13.4004), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot
new serverClasses.removedWorldObjectData("fraightback03", new Vec3(1239.49, -68.0529, 11.6914), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot new serverClasses.removedWorldObjectData("fraightback03", toVector3(1239.49, -68.0529, 11.6914), 50.0), // Truck trailer in Easy Credit Autos dealership parking lot
], ],
[], [],
[], [],
[], [],
[], [],
[], [],
] ],
interiorTemplates: [
false,
{ // GTA 3
},
{ // GTA VC
mall: new serverClasses.interiorTemplateData(toVector3(379.62, 1007.00, 19.22), 4),
malibuClub: new serverClasses.interiorTemplateData(toVector3(489.83, -76.49, 11.48), 17),
policeStation: new serverClasses.interiorTemplateData(toVector3(396.38, -472.96, 12.34), 12),
apartment: new serverClasses.interiorTemplateData(toVector3(26.67, -1328.89, 13.00), 11),
hotel: new serverClasses.interiorTemplateData(toVector3(228.53, -1277.12, 12.07), 1),
bikerBar: new serverClasses.interiorTemplateData(toVector3(-597.41, 651.84, 11.30), 11),
mansion: new serverClasses.interiorTemplateData(toVector3(-379.14, -551.65, 19.32), 2),
ammunationRange: new serverClasses.interiorTemplateData(toVector3(-667.79, 1217.51, 11.10), 10),
bank: new serverClasses.interiorTemplateData(toVector3(-894.52, -341.16, 13.45), 3),
stripClub: new serverClasses.interiorTemplateData(toVector3(97.53, -1472.06, 10.43), 5),
office: new serverClasses.interiorTemplateData(toVector3(120.82, -827.98, 10.62), 6),
arena: new serverClasses.interiorTemplateData(toVector3(-1080.49, 1331.16, 13.91), 15),
ghettoShack: new serverClasses.interiorTemplateData(toVector3(-962.72, 146.11, 9.395), 12),
},
{ // GTA SA
}
],
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function initConfigScript() { function initConfigScript() {
console.log("[Asshat.Config]: Initializing config script ..."); console.log("[Asshat.Config]: Initializing config script ...");
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port);
applyConfigToServer(serverConfig);
console.log("[Asshat.Config]: Config script initialized!"); console.log("[Asshat.Config]: Config script initialized!");
} }

View File

@@ -11,10 +11,10 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
let databaseConfig = { let databaseConfig = {
host: "158.69.238.64", host: "127.0.0.1",
user: "db24053", user: "gtac-main",
pass: "G3At3d7BsA", pass: "QaH2rOP7BOBAkuX5V74EsOFi4uh5XO",
name: "db24053", name: "gtac_main",
port: 3306, port: 3306,
usePersistentConnection: true, usePersistentConnection: true,
} }

View File

@@ -229,28 +229,75 @@ function playerExitedVehicle(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function processPlayerDeath(client) { function processPlayerDeath(client, position) {
removeEntityData(client.player, "ag.spawned", true); removeEntityData(client.player, "ag.spawned");
let closestHospital = getClosestHospital(getPlayerPosition(client));
triggerNetworkEvent("ag.control", client, false); triggerNetworkEvent("ag.control", client, false);
setTimeout(function() { setTimeout(function() {
triggerNetworkEvent("ag.fadeCamera", client, false, 1.0); triggerNetworkEvent("ag.fadeCamera", client, false, 1.0);
setTimeout(function() { setTimeout(function() {
client.despawnPlayer(); client.despawnPlayer();
if(getPlayerCurrentSubAccount(client).inJail) { if(getPlayerCurrentSubAccount(client).inJail) {
let closestJail = getClosestJail(getPlayerPosition(client)); let closestJail = getClosestJail(position);
spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin); spawnPlayer(client, closestJail.position, closestJail.heading, getPlayerCurrentSubAccount(client).skin);
} else { } else {
getPlayerCurrentSubAccount(client).inHospital = true;
let closestHospital = getClosestHospital(position);
spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin); spawnPlayer(client, closestHospital.position, closestHospital.heading, getPlayerCurrentSubAccount(client).skin);
} }
setTimeout(function() {
setEntityData(client.player, "ag.spawned", true, true);
triggerNetworkEvent("ag.fadeCamera", client, true, 1.0);
triggerNetworkEvent("ag.control", client, true);
}, 1000);
}, 2000); }, 2000);
}, 1000); }, 1000);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function processPedSpawn(ped) {
if(ped.type == ELEMENT_PLAYER) {
setTimeout(processPlayerSpawn, 1000, ped);
}
}
// ---------------------------------------------------------------------------
function processPlayerSpawn(ped) {
if(getClientFromPlayerElement(ped) == null) {
setTimeout(processPlayerSpawn, ped, 500);
return false;
}
let client = getClientFromPlayerElement(ped);
if(!getPlayerData(client)) {
client.disconnect();
return false;
}
if(!getPlayerData(client).switchingCharacter) {
return false;
}
messagePlayerAlert(client, `You are now playing as: [#0099FF]${tempSubAccount.firstName} ${tempSubAccount.lastName}`, getColourByName("white"));
messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
triggerNetworkEvent("ag.restoreCamera", client);
setEntityData(client, "ag.spawned", true, true);
setTimeout(function() {
setEntityData(ped, "ag.spawned", true, true);
setPlayerPosition(client, tempSubAccount.spawnPosition);
setPlayerHeading(client, tempSubAccount.spawnHeading);
setPlayerInterior(client, tempSubAccount.interior);
setPlayerVirtualWorld(client, tempSubAccount.dimension);
setTimeout(function() {
updatePlayerCash(client);
}, 1000);
}, 500);
updateAllPlayerNameTags();
getPlayerData(client).switchingCharacter = false;
triggerNetworkEvent("ag.jobType", client, tempSubAccount.job);
}
// ---------------------------------------------------------------------------

View File

@@ -133,7 +133,7 @@ function showAccountHelpMessage(client) {
function showVehicleHelpMessage(client) { function showVehicleHelpMessage(client) {
messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Help [#FF9900]============================="); messagePlayerInfo(client, "[#FF9900]== [#FFFF00]Vehicle Help [#FF9900]=============================");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit dealerships to buy new vehicles (Use [#AAAAAA]/help dealership [#FFFFFF]for more info."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit dealerships to buy new vehicles (Use [#AAAAAA]/help dealership [#FFFFFF]for more info.)");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some commands: [#AAAAAA]/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Some commands: [#AAAAAA]/lock, /engine, /lights, /trunk, /rentveh, /buyveh, /rentprice, /buyprice");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Your personal vehicles will save wherever you or somebody else leaves them!"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Your personal vehicles will save wherever you or somebody else leaves them!");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit a mechanic garage to repair, colour, and tune up your car! [#AAAAAA]/help mechanic [#FFFFFF] for info"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Visit a mechanic garage to repair, colour, and tune up your car! [#AAAAAA]/help mechanic [#FFFFFF] for info");
@@ -179,7 +179,7 @@ function showRulesHelpMessage(client) {
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]No terrorist or terrorism roleplay is allowed."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]No terrorist or terrorism roleplay is allowed.");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Always follow instructions given by moderators and admins."); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Always follow instructions given by moderators and admins.");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Do not mix the chats (metagaming). You can't use info in IC that was received OOC"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Do not mix the chats (metagaming). You can't use info in IC that was received OOC");
messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help [#FFFFFF]language"); messagePlayerNormal(client, "[#FF9900]• [#FFFFFF]Keep English in main chats. If you aren't good at English, use [#AAAAAA]/help language");
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -169,6 +169,56 @@ function setHousePickupCommand(command, params, client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function setHouseInteriorTypeCommand(command, params, client) {
let splitParams = params.split(" ");
let typeParam = splitParams[0] || "none";
let houseId = getHouseFromParams(splitParams[1]) || (isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client));
if(!getHouseData(houseId)) {
messagePlayerError(client, "Business not found!");
return false;
}
if(isNaN(typeParam)) {
if(toLowerCase(typeParam) == "none") {
getHouseData(houseId).exitPosition = toVector3(0.0, 0.0, 0.0);
getHouseData(houseId).exitInterior = -1;
getHouseData(houseId).hasInterior = false;
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]remove house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]interior`);
return false;
}
if(isNull(getGameConfig().interiorTemplates[getServerGame()][typeParam])) {
messagePlayerError(client, "Invalid interior type! Use an interior type name or an existing house database ID");
messagePlayerInfo(client, `Interior Types: [#AAAAAA]${Object.keys(getGameConfig().interiorTemplates[getServerGame()]).join(", ")}`)
return false;
}
getHouseData(houseId).exitPosition = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitPosition;
getHouseData(houseId).exitInterior = getGameConfig().interiorTemplates[getServerGame()][typeParam].exitInterior;
getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart;
getHouseData(houseId).hasInterior = true;
} else {
if(!getHouseData(houseId)) {
messagePlayerError(client, "Business ID not found!");
return false;
}
getHouseData(houseId).exitPosition = getHouseData(houseId).exitPosition;
getHouseData(houseId).exitInterior = getHouseData(houseId).exitInterior;
getHouseData(houseId).exitDimension = getHouseData(houseId).databaseId+getGlobalConfig().houseDimensionStart;
getHouseData(houseId).hasInterior = true;
}
deleteHouseEntrancePickup(houseId);
deleteHouseExitPickup(houseId);
createHouseEntrancePickup(houseId);
createHouseExitPickup(houseId);
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]set house [#11CC11]${getHouseData(houseId).description} [#FFFFFF]interior type to [#AAAAAA]${toLowerCase(typeParam)}`);
}
// ---------------------------------------------------------------------------
function setHouseBlipCommand(command, params, client) { function setHouseBlipCommand(command, params, client) {
let typeParam = params || "house"; let typeParam = params || "house";
let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client))); let houseId = toInteger((isPlayerInAnyHouse(client)) ? getPlayerHouse(client) : getClosestHouseEntrance(getPlayerPosition(client)));
@@ -361,11 +411,11 @@ function saveHouseToDatabase(houseId) {
if(dbConnection) { if(dbConnection) {
let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description); let safeHouseDescription = escapeDatabaseString(dbConnection, tempHouseData.description);
if(tempHouseData.databaseId == 0) { if(tempHouseData.databaseId == 0) {
let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw) VALUES (${getServerId()}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension})`; let dbQueryString = `INSERT INTO house_main (house_server, house_description, house_owner_type, house_owner_id, house_locked, house_entrance_pos_x, house_entrance_pos_y, house_entrance_pos_z, house_entrance_rot_z, house_entrance_int, house_entrance_vw, house_exit_pos_x, house_exit_pos_y, house_exit_pos_z, house_exit_rot_z, house_exit_int, house_exit_vw, house_has_interior) VALUES (${getServerId()}, '${safeHouseDescription}', ${tempHouseData.ownerType}, ${tempHouseData.ownerId}, ${boolToInt(tempHouseData.locked)}, ${tempHouseData.entrancePosition.x}, ${tempHouseData.entrancePosition.y}, ${tempHouseData.entrancePosition.z}, ${tempHouseData.entranceRotation}, ${tempHouseData.entranceInterior}, ${tempHouseData.entranceDimension}, ${tempHouseData.exitPosition.x}, ${tempHouseData.exitPosition.y}, ${tempHouseData.exitPosition.z}, ${tempHouseData.exitRotation}, ${tempHouseData.exitInterior}, ${tempHouseData.exitDimension}, ${boolToInt(tempHouseData.hasInterior)})`;
queryDatabase(dbConnection, dbQueryString); queryDatabase(dbConnection, dbQueryString);
getServerData().houses[houseId].databaseId = getDatabaseInsertId(dbConnection); getServerData().houses[houseId].databaseId = getDatabaseInsertId(dbConnection);
} else { } else {
let dbQueryString = `UPDATE house_main SET house_description='${safeHouseDescription}', house_owner_type=${tempHouseData.ownerType}, house_owner_id=${tempHouseData.ownerId}, house_locked=${boolToInt(tempHouseData.locked)}, house_entrance_pos_x=${tempHouseData.entrancePosition.x}, house_entrance_pos_y=${tempHouseData.entrancePosition.y}, house_entrance_pos_z=${tempHouseData.entrancePosition.z}, house_entrance_rot_z=${tempHouseData.entranceRotation}, house_entrance_int=${tempHouseData.entranceInterior}, house_entrance_vw=${tempHouseData.entranceDimension}, house_exit_pos_x=${tempHouseData.exitPosition.x}, house_exit_pos_y=${tempHouseData.exitPosition.y}, house_exit_pos_z=${tempHouseData.exitPosition.z}, house_exit_rot_z=${tempHouseData.exitRotation}, house_exit_int=${tempHouseData.exitInterior}, house_exit_vw=${tempHouseData.exitDimension} WHERE house_id=${tempHouseData.databaseId}`; let dbQueryString = `UPDATE house_main SET house_description='${safeHouseDescription}', house_owner_type=${tempHouseData.ownerType}, house_owner_id=${tempHouseData.ownerId}, house_locked=${boolToInt(tempHouseData.locked)}, house_entrance_pos_x=${tempHouseData.entrancePosition.x}, house_entrance_pos_y=${tempHouseData.entrancePosition.y}, house_entrance_pos_z=${tempHouseData.entrancePosition.z}, house_entrance_rot_z=${tempHouseData.entranceRotation}, house_entrance_int=${tempHouseData.entranceInterior}, house_entrance_vw=${tempHouseData.entranceDimension}, house_exit_pos_x=${tempHouseData.exitPosition.x}, house_exit_pos_y=${tempHouseData.exitPosition.y}, house_exit_pos_z=${tempHouseData.exitPosition.z}, house_exit_rot_z=${tempHouseData.exitRotation}, house_exit_int=${tempHouseData.exitInterior}, house_exit_vw=${tempHouseData.exitDimension}, house_has_interior=${boolToInt(tempHouseData.hasInterior)} WHERE house_id=${tempHouseData.databaseId}`;
queryDatabase(dbConnection, dbQueryString); queryDatabase(dbConnection, dbQueryString);
} }
disconnectFromDatabase(dbConnection); disconnectFromDatabase(dbConnection);
@@ -572,33 +622,9 @@ function doesHouseHaveInterior(houseId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function sendAllHouseLabelsToPlayer(client) {
let tempHouseLabels = [];
let totalHouses = getServerData().houses.length;
let housesPerNetworkEvent = 100;
let totalNetworkEvents = Math.ceil(totalHouses/housesPerNetworkEvent);
for(let i = 0 ; i < totalNetworkEvents ; i++) {
for(let j = 0 ; j < housesPerNetworkEvent ; j++) {
let tempHouseId = (i*housesPerNetworkEvent)+j;
if(typeof getServerData().houses[tempHouseId] != "undefined") {
tempHouseLabels.push([tempHouseId, getServerData().houses[tempHouseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[tempHouseId].description, getServerData().houses[tempHouseId].locked, false]);
}
}
triggerNetworkEvent("ag.houselabel.all", client, tempHouseLabels);
tempHouseLabels = [];
}
}
// ---------------------------------------------------------------------------
function sendHouseLabelToPlayers(houseId) {
triggerNetworkEvent("ag.houselabel.add", null, houseId, getServerData().houses[houseId].entrancePosition, getGameConfig().propertyLabelHeight[getServerGame()], getServerData().houses[houseId].description, getServerData().houses[houseId].locked, false);
}
// ---------------------------------------------------------------------------
function deleteHouseEntrancePickup(houseId) { function deleteHouseEntrancePickup(houseId) {
if(getHouseData(houseId).entrancePickup != null) { if(getHouseData(houseId).entrancePickup != null) {
removeFromWorld(getHouseData(houseId).entrancePickup);
destroyElement(getHouseData(houseId).entrancePickup); destroyElement(getHouseData(houseId).entrancePickup);
getHouseData(houseId).entrancePickup = null; getHouseData(houseId).entrancePickup = null;
} }
@@ -608,6 +634,7 @@ function deleteHouseEntrancePickup(houseId) {
function deleteHouseExitPickup(houseId) { function deleteHouseExitPickup(houseId) {
if(getHouseData(houseId).exitPickup != null) { if(getHouseData(houseId).exitPickup != null) {
removeFromWorld(getHouseData(houseId).exitPickup);
destroyElement(getHouseData(houseId).exitPickup); destroyElement(getHouseData(houseId).exitPickup);
getHouseData(houseId).exitPickup = null; getHouseData(houseId).exitPickup = null;
} }
@@ -617,6 +644,7 @@ function deleteHouseExitPickup(houseId) {
function deleteHouseEntranceBlip(houseId) { function deleteHouseEntranceBlip(houseId) {
if(getHouseData(houseId).entranceBlip != null) { if(getHouseData(houseId).entranceBlip != null) {
removeFromWorld(getHouseData(houseId).entranceBlip);
destroyElement(getHouseData(houseId).entranceBlip); destroyElement(getHouseData(houseId).entranceBlip);
getHouseData(houseId).entranceBlip = null; getHouseData(houseId).entranceBlip = null;
} }
@@ -626,6 +654,7 @@ function deleteHouseEntranceBlip(houseId) {
function deleteHouseExitBlip(houseId) { function deleteHouseExitBlip(houseId) {
if(getHouseData(houseId).exitBlip != null) { if(getHouseData(houseId).exitBlip != null) {
removeFromWorld(getHouseData(houseId).exitBlip);
destroyElement(getHouseData(houseId).exitBlip); destroyElement(getHouseData(houseId).exitBlip);
getHouseData(houseId).exitBlip = null; getHouseData(houseId).exitBlip = null;
} }
@@ -653,10 +682,6 @@ function reloadAllHousesCommand(command, params, client) {
createAllHousePickups(); createAllHousePickups();
createAllHouseBlips(); createAllHouseBlips();
for(let i in clients) {
sendAllHouseLabelsToPlayer(clients[i]);
}
messageAdminAction(`All houses have been reloaded by an admin!`); messageAdminAction(`All houses have been reloaded by an admin!`);
} }

View File

@@ -16,8 +16,6 @@ function initJobScript() {
createAllJobPickups(); createAllJobPickups();
createAllJobBlips(); createAllJobBlips();
//addEvent("onJobPickupCollected", null, 2);
console.log("[Asshat.Job]: Job script initialized successfully!"); console.log("[Asshat.Job]: Job script initialized successfully!");
return true; return true;
} }
@@ -602,8 +600,8 @@ function jobUniformCommand(command, params, client) {
return false; return false;
} }
messagePlayerSuccess(client, `You put on the ${uniforms[uniformId-1].name} uniform`); messagePlayerSuccess(client, `You put on the [#AAAAAA]${uniforms[uniformId-1].name} [#FFFFFF]uniform`);
triggerNetworkEvent("ag.pedSkin", null, client.player, uniforms[uniformId-1].skin); setPlayerSkin(client, uniforms[uniformId-1].skin);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -724,11 +722,6 @@ function reloadAllJobsCommand(command, params, client) {
createAllJobPickups(); createAllJobPickups();
createAllJobBlips(); createAllJobBlips();
let clients = getClients();
for(let i in clients) {
sendAllJobLabelsToPlayer(clients[i]);
}
messageAdminAction(`All server jobs have been reloaded by an admin!`); messageAdminAction(`All server jobs have been reloaded by an admin!`);
} }
@@ -758,9 +751,10 @@ function deleteJobLocationCommand(command, params, client) {
let closestJobLocation = getClosestJobLocation(getPlayerPosition(client)); let closestJobLocation = getClosestJobLocation(getPlayerPosition(client));
let jobData = getJobData(closestJobLocation.job); let jobData = getJobData(closestJobLocation.job);
messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]${getEnabledDisabledFromBool(closestJobLocation.enabled)} location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`); messageAdmins(`[#AAAAAA]${client.name} [#FFFFFF]deleted location [#AAAAAA]${closestJobLocation.databaseId} [#FFFFFF]for the [#AAAAAA]${jobData.name} [#FFFFFF]job`);
deleteJobLocation(closestJobLocation); deleteJobLocation(closestJobLocation);
getJobData(closestJobLocation.job).locations.splice(getClosestJobLocation.index, 1);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1189,8 +1183,8 @@ function canPlayerUseJob(client, jobId) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function deleteJobLocation(jobLocationData) { function deleteJobLocation(jobLocationData) {
removeFromWorld(jobLocationData.pickup);
destroyElement(jobLocationData.pickup); destroyElement(jobLocationData.pickup);
triggerNetworkEvent("ag.joblabel.del", jobLocationData.databaseId);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -1222,7 +1216,21 @@ function getJobIdFromDatabaseId(databaseId) {
function setAllJobDataIndexes() { function setAllJobDataIndexes() {
for(let i in getServerData().jobs) { for(let i in getServerData().jobs) {
getServerData().jobs[i].id = i; getServerData().jobs[i].index = i;
for(let j in getServerData().jobs[i].locations) {
getServerData().jobs[i].locations[j].index = j;
}
for(let k in getServerData().jobs[i].uniforms) {
getServerData().jobs[i].uniforms[k].index = k;
}
for(let m in getServerData().jobs[i].equipment) {
getServerData().jobs[i].equipment[m].index = m;
for(let n in getServerData().jobs[i].equipment[m].weapons) {
getServerData().jobs[i].equipment[m].weapons[n].index = n;
}
}
} }
} }

View File

@@ -21,62 +21,7 @@ let busRoutes = [
name: "Portland Red Line", name: "Portland Red Line",
island: 0, island: 0,
busColour: 3, busColour: 3,
positions: [ payout: 175,
toVector3(1269, -1056.4, 14.75),
toVector3(1088.7, -968.8, 14.91),
toVector3(1059.1, -870.9, 14.91),
toVector3(917.6, -815.9, 14.91),
toVector3(851.1, -766.1, 14.91),
toVector3(838.8, -598.7, 14.91),
toVector3(959.3, -581.6, 14.91),
toVector3(853.1, -485.9, 14.91),
toVector3(838.8, -312.68, 6.8),
toVector3(913.9, -177.4, 4.91),
toVector3(1123.3, -67.74, 7.41),
toVector3(1043.6, -191.63, 4.91),
toVector3(1213.2, -281.3, 25.76),
toVector3(1193.3, -474.3, 24.98),
toVector3(1335.4, -499.7, 45.28),
toVector3(1220.3, -341.4, 26.38),
toVector3(1122.6, -475.6, 19.91),
toVector3(1309.2, -642.4, 12.3),
toVector3(1350.5, -845, 14.91),
toVector3(1322.2, -1025.3, 14.76),
toVector3(1307.5, -995.54, 14.88),
],
},
{ // BLUE ROUTE (1)
name: "Portland Blue Line",
island: 0,
busColour: 2,
positions: [
toVector3(1269, -1056.4, 14.75),
toVector3(1088.7, -968.8, 14.91),
toVector3(1059.1, -870.9, 14.91),
toVector3(917.6, -815.9, 14.91),
toVector3(851.1, -766.1, 14.91),
toVector3(838.8, -598.7, 14.91),
toVector3(959.3, -581.6, 14.91),
toVector3(853.1, -485.9, 14.91),
toVector3(838.8, -312.68, 6.8),
toVector3(913.9, -177.4, 4.91),
toVector3(1123.3, -67.74, 7.41),
toVector3(1043.6, -191.63, 4.91),
toVector3(1213.2, -281.3, 25.76),
toVector3(1193.3, -474.3, 24.98),
toVector3(1335.4, -499.7, 45.28),
toVector3(1220.3, -341.4, 26.38),
toVector3(1122.6, -475.6, 19.91),
toVector3(1309.2, -642.4, 12.3),
toVector3(1350.5, -845, 14.91),
toVector3(1322.2, -1025.3, 14.76),
toVector3(1307.5, -995.54, 14.88),
],
},
{ // YELLOW ROUTE (2)
name: "Portland Yellow Line",
island: 0,
busColour: 6,
positions: [ positions: [
toVector3(1269, -1056.4, 14.75), toVector3(1269, -1056.4, 14.75),
toVector3(1088.7, -968.8, 14.91), toVector3(1088.7, -968.8, 14.91),
@@ -108,72 +53,7 @@ let busRoutes = [
name: "Staunton Red Line", name: "Staunton Red Line",
island: 1, island: 1,
busColour: 3, busColour: 3,
positions: [ payout: 175,
toVector3(-1.11, -388.4, 16.11),
toVector3(-15.75, -735.3, 26.15),
toVector3(33.63, -1029.4, 26.11),
toVector3(-53.92, -1233.4, 26.11),
toVector3(126.58, -1323.7, 26.11),
toVector3(189.39, -1285.6, 26.11),
toVector3(266.9, -1179.1, 26.11),
toVector3(283.93, -1370.2, 26.11),
toVector3(144.44, -1455.5, 26.11),
toVector3(34.5, -1511.7, 26.11),
toVector3(325.31, -1579, 26.03),
toVector3(302.33, -1417.7, 26.11),
toVector3(309.76, -1290, 26.11),
toVector3(378.5, -1235.1, 26.11),
toVector3(404, -1376.3, 26.11),
toVector3(189.07, -1159.3, 26.11),
toVector3(189.44, -956.9, 26.11),
toVector3(254.18, -722.3, 26.11),
toVector3(383.4, -704.2, 26.11),
toVector3(429.3, -420.6, 22.04),
toVector3(570.9, -336.4, 19.71),
toVector3(267.46, 91.12, 15.96),
toVector3(99.13, -31.96, 16.11),
toVector3(243.94, -187.01, 21.31),
toVector3(99.17, -263.44, 16.11),
toVector3(-26.92, -283.73, 16.11),
],
},
{ // BLUE ROUTE (1)
name: "Staunton Blue Line",
island: 1,
busColour: 2,
positions: [
toVector3(-1.11, -388.4, 16.11),
toVector3(-15.75, -735.3, 26.15),
toVector3(33.63, -1029.4, 26.11),
toVector3(-53.92, -1233.4, 26.11),
toVector3(126.58, -1323.7, 26.11),
toVector3(189.39, -1285.6, 26.11),
toVector3(266.9, -1179.1, 26.11),
toVector3(283.93, -1370.2, 26.11),
toVector3(144.44, -1455.5, 26.11),
toVector3(34.5, -1511.7, 26.11),
toVector3(325.31, -1579, 26.03),
toVector3(302.33, -1417.7, 26.11),
toVector3(309.76, -1290, 26.11),
toVector3(378.5, -1235.1, 26.11),
toVector3(404, -1376.3, 26.11),
toVector3(189.07, -1159.3, 26.11),
toVector3(189.44, -956.9, 26.11),
toVector3(254.18, -722.3, 26.11),
toVector3(383.4, -704.2, 26.11),
toVector3(429.3, -420.6, 22.04),
toVector3(570.9, -336.4, 19.71),
toVector3(267.46, 91.12, 15.96),
toVector3(99.13, -31.96, 16.11),
toVector3(243.94, -187.01, 21.31),
toVector3(99.17, -263.44, 16.11),
toVector3(-26.92, -283.73, 16.11),
],
},
{ // YELLOW ROUTE (2)
name: "Staunton Yellow Line",
island: 1,
busColour: 6,
positions: [ positions: [
toVector3(-1.11, -388.4, 16.11), toVector3(-1.11, -388.4, 16.11),
toVector3(-15.75, -735.3, 26.15), toVector3(-15.75, -735.3, 26.15),
@@ -213,6 +93,7 @@ let busRoutes = [
name: "Vice City Red Line", name: "Vice City Red Line",
island: 0, island: 0,
busColour: 3, busColour: 3,
payout: 100,
positions: [ positions: [
toVector3(-997.698, 175.8, 10.704), toVector3(-997.698, 175.8, 10.704),
toVector3(-607.007, 659.024, 10.9994), toVector3(-607.007, 659.024, 10.9994),
@@ -231,6 +112,7 @@ let busRoutes = [
name: "Vice City Green Line", name: "Vice City Green Line",
island: 0, island: 0,
busColour: 46, busColour: 46,
payout: 250,
positions: [ positions: [
toVector3(-1106.57, -300.12, 11.189), toVector3(-1106.57, -300.12, 11.189),
toVector3(-1012.97, -372.445, 10.8688), toVector3(-1012.97, -372.445, 10.8688),
@@ -262,39 +144,6 @@ let busRoutes = [
toVector3(-1082.1, -294.416, 11.2065), toVector3(-1082.1, -294.416, 11.2065),
], ],
}, },
{ // YELLOW ROUTE (2)
name: "Staunton Yellow Line",
island: 1,
busColour: 6,
positions: [
toVector3(-1.11, -388.4, 16.11),
toVector3(-15.75, -735.3, 26.15),
toVector3(33.63, -1029.4, 26.11),
toVector3(-53.92, -1233.4, 26.11),
toVector3(126.58, -1323.7, 26.11),
toVector3(189.39, -1285.6, 26.11),
toVector3(266.9, -1179.1, 26.11),
toVector3(283.93, -1370.2, 26.11),
toVector3(144.44, -1455.5, 26.11),
toVector3(34.5, -1511.7, 26.11),
toVector3(325.31, -1579, 26.03),
toVector3(302.33, -1417.7, 26.11),
toVector3(309.76, -1290, 26.11),
toVector3(378.5, -1235.1, 26.11),
toVector3(404, -1376.3, 26.11),
toVector3(189.07, -1159.3, 26.11),
toVector3(189.44, -956.9, 26.11),
toVector3(254.18, -722.3, 26.11),
toVector3(383.4, -704.2, 26.11),
toVector3(429.3, -420.6, 22.04),
toVector3(570.9, -336.4, 19.71),
toVector3(267.46, 91.12, 15.96),
toVector3(99.13, -31.96, 16.11),
toVector3(243.94, -187.01, 21.31),
toVector3(99.17, -263.44, 16.11),
toVector3(-26.92, -283.73, 16.11),
],
},
], ],
], ],
@@ -318,6 +167,7 @@ let busRoutes = [
name: "Los Santos Yellow Line", name: "Los Santos Yellow Line",
island: 0, island: 0,
busColour: 6, busColour: 6,
payout: 200,
positions: [ positions: [
toVector3(1823.79, -1852.66, 13.5144), toVector3(1823.79, -1852.66, 13.5144),
toVector3(1804.12, -1609.59, 13.4419), toVector3(1804.12, -1609.59, 13.4419),
@@ -364,6 +214,7 @@ let busRoutes = [
name: "Los Santos Blue Line", name: "Los Santos Blue Line",
island: 0, island: 0,
busColour: 2, busColour: 2,
payout: 250,
positions: [ positions: [
toVector3(1824.17, -1851.5, 13.5134), toVector3(1824.17, -1851.5, 13.5134),
toVector3(1853.95, -1395.48, 13.4882), toVector3(1853.95, -1395.48, 13.4882),
@@ -415,6 +266,7 @@ let busRoutes = [
name: "Los Santos Green Line", name: "Los Santos Green Line",
island: 0, island: 0,
busColour: 86, busColour: 86,
payout: 175,
positions: [ positions: [
toVector3(1823.94, -1853.88, 13.5103), toVector3(1823.94, -1853.88, 13.5103),
toVector3(1823.97, -1655.31, 13.4738), toVector3(1823.97, -1655.31, 13.4738),
@@ -470,6 +322,7 @@ let busRoutes = [
name: "Los Santos Red Line", name: "Los Santos Red Line",
island: 0, island: 0,
busColour: 3, busColour: 3,
payout: 150,
positions: [ positions: [
toVector3(1823.79, -1852.66, 13.5144), toVector3(1823.79, -1852.66, 13.5144),
toVector3(1804.12, -1609.59, 13.4419), toVector3(1804.12, -1609.59, 13.4419),

View File

@@ -12,30 +12,6 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function agSpawnPlayer(client, subAccountData) {
return spawnPlayer(client, subAccountData.spawnPosition, subAccountData.spawnRotation, subAccountData.skin);
}
// ---------------------------------------------------------------------------
function agCreateVehicle(vehicleData) {
return createVehicle(vehicleData.model, vehicleData.spawnPosition);
}
// ---------------------------------------------------------------------------
function agSetVehiclePosition(vehicle, position) {
vehicle.position = position;
}
// ---------------------------------------------------------------------------
function agSetVehicleRotation(vehicle, heading) {
vehicle.heading = heading;
}
// ---------------------------------------------------------------------------
function getServerGame() { function getServerGame() {
return server.game; return server.game;
} }
@@ -201,3 +177,9 @@ function removePlayerFromVehicle(client) {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function setPlayerSkin(client, skin) {
client.player.modelIndex = skin;
}
// ---------------------------------------------------------------------------

View File

@@ -12,6 +12,8 @@ function initServerScripts() {
checkForAllRequiredModules(); checkForAllRequiredModules();
initConfigScript();
initClassScript(); initClassScript();
initDatabaseScript(); initDatabaseScript();
initBitFlagScript(); initBitFlagScript();
@@ -27,7 +29,6 @@ function initServerScripts() {
initJobScript(); initJobScript();
initVehicleScript(); initVehicleScript();
initDeveloperScript(); initDeveloperScript();
initConfigScript();
initKeyBindScript(); initKeyBindScript();
initEventScript(); initEventScript();
initAntiCheatScript(); initAntiCheatScript();
@@ -46,7 +47,7 @@ function initServerScripts() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function checkForHashingModule() { function checkForHashingModule() {
if(module.hashing == "undefined") { if(typeof module.hashing == "undefined") {
return false; return false;
} }
return true; return true;
@@ -55,7 +56,7 @@ function checkForHashingModule() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function checkForMySQLModule() { function checkForMySQLModule() {
if(module.mysql == "undefined") { if(typeof module.mysql == "undefined") {
return false; return false;
} }
@@ -85,8 +86,6 @@ function checkForAllRequiredModules() {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
serverConfig = loadServerConfigFromGameAndPort(server.game, server.port);
applyConfigToServer(serverConfig);
initServerScripts(); initServerScripts();
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -221,7 +221,7 @@ addNetworkHandler("ag.nextCharacter", function(client) {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
async function selectCharacter(client, characterId = -1) { function selectCharacter(client, characterId = -1) {
if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) { if(getServerConfig().useGUI && doesPlayerHaveGUIEnabled(client)) {
triggerNetworkEvent("ag.characterSelectSuccess", client); triggerNetworkEvent("ag.characterSelectSuccess", client);
} }
@@ -230,41 +230,17 @@ async function selectCharacter(client, characterId = -1) {
getPlayerData(client).currentSubAccount = characterId; getPlayerData(client).currentSubAccount = characterId;
} }
let tempSubAccount = getPlayerCurrentSubAccount(client); console.log(`[Asshat.SubAccount] Spawning ${getPlayerDisplayForConsole(client)} with skin ${getPlayerCurrentSubAccount(client).skin}`);
spawnPlayer(client, tempSubAccount.spawnPosition, tempSubAccount.spawnHeading, tempSubAccount.skin); spawnPlayer(client, getPlayerCurrentSubAccount(client).spawnPosition, getPlayerCurrentSubAccount(client).spawnHeading, getPlayerCurrentSubAccount(client).skin);
tempSubAccount.lastLogin = new Date().getTime(); getPlayerCurrentSubAccount(client).lastLogin = new Date().getTime();
messagePlayerAlert(client, `You are now playing as: [#0099FF]${tempSubAccount.firstName} ${tempSubAccount.lastName}`, getColourByName("white"));
messagePlayerNormal(client, "This server is in early development and may restart at any time for updates.", getColourByName("orange"));
messagePlayerNormal(client, "Please report any bugs using /bug and suggestions using /idea", getColourByName("yellow"));
triggerNetworkEvent("ag.restoreCamera", client);
setEntityData(client, "ag.spawned", true, true);
while(client.player == null) {};
setTimeout(function() {
setEntityData(client.player, "ag.spawned", true, true);
//triggerNetworkEvent("ag.restoreCamera", client);
setPlayerPosition(client, tempSubAccount.spawnPosition);
setPlayerHeading(client, tempSubAccount.spawnHeading);
setPlayerInterior(client, tempSubAccount.interior);
setPlayerVirtualWorld(client, tempSubAccount.dimension);
setTimeout(function() {
updatePlayerCash(client);
}, 1000);
}, client.ping+1000);
updateAllPlayerNameTags();
getPlayerData(client).switchingCharacter = false;
triggerNetworkEvent("ag.jobType", client, tempSubAccount.job);
} }
addNetworkHandler("ag.selectCharacter", selectCharacter); addNetworkHandler("ag.selectCharacter", selectCharacter);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function switchCharacterCommand(command, params, client) { function switchCharacterCommand(command, params, client) {
if(isPlayerSpawned(client)) {
getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client); getPlayerCurrentSubAccount(client).spawnPosition = getPlayerPosition(client);
getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client); getPlayerCurrentSubAccount(client).spawnHeading = getPlayerHeading(client);
//getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client); //getPlayerCurrentSubAccount(client).interior = getPlayerInterior(client);
@@ -275,6 +251,7 @@ function switchCharacterCommand(command, params, client) {
resetClientStuff(client); resetClientStuff(client);
client.despawnPlayer(); client.despawnPlayer();
}
showConnectCameraToPlayer(client); showConnectCameraToPlayer(client);
showCharacterSelectToClient(client); showCharacterSelectToClient(client);
} }

View File

@@ -1732,7 +1732,7 @@ function getSkinIdFromName(params, gameId = getServerGame()) {
function getClosestHospital(position) { function getClosestHospital(position) {
let closest = 0; let closest = 0;
for(let i in getServerData().hospitals[getServerGame()]) { for(let i in getServerData().hospitals[getServerGame()]) {
if(getServerData().hospitals[getServerGame()][i].position.distance(position) < getServerData().hospitals[getServerGame()][closest].position) { if(getDistance(getServerData().hospitals[getServerGame()][i].position, position) < getDistance(getServerData().hospitals[getServerGame()][closest].position, position)) {
closest = i; closest = i;
} }
} }

View File

@@ -66,7 +66,7 @@ function saveVehicleToDatabase(vehicleData) {
return false; return false;
} }
console.log(`[Asshat.Vehicle]: Saving vehicle ${vehicleData.vehicle.id} to database ...`); console.log(`[Asshat.Vehicle]: Saving vehicle ${vehicleData.databaseId} to database ...`);
let dbConnection = connectToDatabase(); let dbConnection = connectToDatabase();
if(dbConnection) { if(dbConnection) {
if(!vehicleData.spawnLocked) { if(!vehicleData.spawnLocked) {

View File

@@ -287,12 +287,12 @@ mexui.isAnyWindowShown = function()
mexui.setInput = function(showInput) mexui.setInput = function(showInput)
{ {
gui.showCursor(showInput, !showInput); gui.showCursor(showInput, !showInput);
if(localPlayer) //if(localPlayer)
{ //{
if(showInput) // if(showInput)
gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false); // gta.setCameraLookAtEntity(new Vec3(gta.cameraMatrix.m41, gta.cameraMatrix.m42, gta.cameraMatrix.m43), localPlayer, false);
else // else
gta.restoreCamera(false); // gta.restoreCamera(false);
} //}
}; };