1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2024-11-28 09:20:54 +01:00

fix terminal scratch immediately pick up car

This commit is contained in:
ghkkk090 2022-09-03 19:37:54 +07:00
parent ab1ff0fbbd
commit 427c7539af
2 changed files with 155 additions and 0 deletions

View File

@ -11,6 +11,7 @@ import * as wm from "../wmmt/wm.proto";
// Import Util
import * as common from "../util/common";
import * as scratch from "../util/scratch";
import * as terminal from "../util/terminal/check_car";
export default class CarModule extends Module {
@ -275,6 +276,7 @@ export default class CarModule extends Module {
// Get the request body for the create car request
let body = wm.wm.protobuf.CreateCarRequest.decode(req.body);
console.log(body);
// Get the current date/time (unix epoch)
let date = Math.floor(new Date().getTime() / 1000)
@ -408,6 +410,9 @@ export default class CarModule extends Module {
{
// Car is fully tuned
tune = 2;
// Check if created car is from terminal scratch car
await terminal.checkScratchCar(body.userId, body.car.visualModel!)
}
// User item not used, but car has 600 HP by default
else if (body.car &&

View File

@ -0,0 +1,150 @@
import { prisma } from "../..";
// Sends the server response to the client
export async function checkScratchCar(userId: number, visualModel: number)
{
let checkUserItem: any;
if(visualModel === 55) // R2
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 4
}
})
}
else if(visualModel === 73) // Corolla
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 3
}
})
}
else if(visualModel === 98) // HIACE Van
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 1
}
})
}
else if(visualModel === 26) // Pajero Evolution
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 2
}
})
}
else if(visualModel === 118) // GT-R Nismo
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 5
}
})
}
else if(visualModel === 119) // Z34 Nismo
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 6
}
})
}
else if(visualModel === 72) // Aristo Taxi
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 16
}
})
}
else if(visualModel === 11) // Atenza Taxi
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 17
}
})
}
else if(visualModel === 66) // Celsior Taxi
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 18
}
})
}
else if(visualModel === 75) // HIACE Wagon
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 19
}
})
}
else if(visualModel === 132) // GT-R Pure Edition
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 20
}
})
}
else if(visualModel === 129) // NSX-R
{
checkUserItem = await prisma.userItem.findMany({
where:{
userId: userId,
category: 201,
itemId: 21
}
})
}
else
{
checkUserItem = [];
}
// Check if user item is available or not
if(checkUserItem.length > 0)
{
for(let i=0; i<checkUserItem.length; i++)
{
await prisma.userItem.delete({
where:{
userItemId: checkUserItem[i].userItemId
}
})
}
console.log('Item used - ID '+ checkUserItem[0].itemId);
console.log('Item deleted!');
console.log(`Item category was ${checkUserItem[0].category} and item game ID was ${checkUserItem[0].itemId}`);
}
}