-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.mjs
99 lines (89 loc) · 3.11 KB
/
client.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import game from 'natives';
import alt from 'alt'
game.setPedDefaultComponentVariation(game.playerPedId());
alt.on('consoleCommand', function(...args) { // client side console
switch (args[0]) {
case "max":
alt.log('v:' + game.getVehicleMaxSpeed(player.vehicle.scriptID) + ' c:' + game.getVehicleClassMaxSpeed(player.vehicle.scriptID))
return;
break;
case "c":
case "cloth": // set cloth on Player
alt.log("cloth " + (+args[1]) + " " + (+args[2]))
game.setPedComponentVariation(game.playerPedId(), +args[1], +args[2], 0, 0); // Set CLoth
return;
case "clothCEF": // open/close clothCEF
if(!clothCef)
openClothCef()
else
closeClothCef()
return;
case "settime": // set cloth on Player
if(+args[1]<0) return
let hour=(+args[1])%24
let min=0
if(+args[2]>0) {
min=(+args[2])%60
}
game.advanceClockTimeTo(hour, min, 0)
alt.log("Set Gametime: "+hour+":"+min)
alt.setMsPerGameMinute(60000)
return;
default: // send command to server
let argsArr = Array.from(args)
if (argsArr.join(' ').trim().length < 1) return;
alt.log(`You Typed: ${argsArr.join(' ')}`);
alt.emitServer("execCmd", argsArr)
break;
}
});
let localPlayer = alt.Player.local;
let speed = 0
alt.setInterval(() => { // onRender
//### Tacho
if (localPlayer.vehicle) {
speed = localPlayer.vehicle.speed
speed = speed * 3.6;
drawText(`${Math.round(speed)} km/h`, 0.90, 0.85, 0.6, 255, 255, 255, 255) // 7, false, false, true, false
}
//### Tacho ENDE
game.invalidateIdleCam()
}, 0)
//Helper to draw text on hud
//wordwrap not implemented
function drawText(text, xPos, yPos, scale, r, g, b, alpha) { //font, justify, shadow, outline, wordwrap
game.setTextScale(1.0, scale);
game.setTextFont(7);
game.setTextColour(r, g, b, alpha);
//graphics.setTextJustification(justify);
//if (justify == 2) graphics.setTextWrap(0.0, xPos);
//if (shadow) graphics.setTextDropshadow(0, 0, 0, 0, 255);
//if (outline)
game.setTextOutline();
game.beginTextCommandDisplayText("STRING");
game.addTextComponentSubstringPlayerName(text);
game.endTextCommandDisplayText(xPos, yPos,0);
}
let clothCef=null
function openClothCef(){
clothCef= new alt.WebView("https://matze.space/gta5/clothView/index.html")
clothCef.focus()
alt.toggleGameControls(false)
alt.showCursor(true)
clothCef.on("setCamPosition",(rot)=>{
game.setEntityRotation( game.playerPedId(), 0, 0, rot, 2, false ); // set rotation - becaus we are frezzed we can not turn
game.setPedDesiredHeading( game.playerPedId(), rot ); // this is to stop ped try to rotate and twich around
})
clothCef.on("setCloth",(slot,draw,tex,pallet)=>{
game.isPedComponentVariationValid(alt.Player.local.scriptID, slot, draw, tex);
game.setPedComponentVariation(alt.Player.local.scriptID, slot, draw, tex, pallet);
})
}
function closeClothCef() {
if(clothCef){
clothCef.destroy()
clothCef=null
}
alt.toggleGameControls(true)
alt.showCursor(false)
}