local g_LocalVehicle = null;
local g_SpeedTableLerpTime = 0.2;
local g_ZeroVector = VectorScreen(0, 0);
local g_FullColour = Colour(255, 255, 255, 255);
local g_StatsLabel = null;
local g_StatsLabelShadow = null;
local g_StatsBg = null;
local g_DefaultColour = Colour(255, 255, 255, 255);
local g_SpeedHint = null;
sX <- GUI.GetScreenSize().X;
sY <- GUI.GetScreenSize().Y;
local sprite_logo, label_name;
function CenterStatsLabels() {
if (g_StatsLabel) {
local pos = VectorScreen(10, sY - 30);
g_StatsLabel.Pos = pos;
if (g_StatsLabelShadow) {
g_StatsLabelShadow.Pos = VectorScreen(10 + 1, sY - 30 + 1);
}
}
}
function Script::ScriptLoad() {
g_StatsLabelShadow = GUILabel(VectorScreen(11, 11), Colour(0, 0, 0, 255), "Loading stats...");
g_StatsLabelShadow.FontSize = 14;
g_StatsLabelShadow.FontFlags = GUI_FFLAG_BOLD;
g_StatsLabel = GUILabel(VectorScreen(10, 10), g_DefaultColour, "Loading stats...");
g_StatsLabel.FontSize = 14;
g_StatsLabel.FontFlags = GUI_FFLAG_BOLD;
g_StatsLabel.TextColour = Colour(224,255,255);
CenterStatsLabels();
}
function Script::ScriptProcess() {
CheckAndUpdateVehicleTableProc();
}
function GUI::GameResize(width, height) {
sX = width;
sY = height;
CheckAndUpdateVehicleTableUI();
CenterStatsLabels();
}
function Server::ServerData(stream) {
local cmd = stream.ReadString();
switch (cmd) {
case "stats":
local kills = stream.ReadInt();
local deaths = stream.ReadInt();
local gwWins = stream.ReadInt();
local headshots = stream.ReadInt();
local duelWins = stream.ReadInt();
if (g_StatsLabel) {
local newText = format(
"Kills: %d Deaths: %d Gangwar Wins: %d Headshots: %d Duel Wins: %d",
kills, deaths, gwWins, headshots, duelWins
);
g_StatsLabel.Text = newText;
if (g_StatsLabelShadow) g_StatsLabelShadow.Text = newText;
CenterStatsLabels();
}
break;
case "onPlayerEnterVehicle":
g_LocalVehicle = World.FindVehicle(stream.ReadInt());
CreateSpeedTableElements();
break;
case "onPlayerExitVehicle":
g_LocalVehicle = null;
RemoveSpeedTableElements();
break;
}
}
SpeedTableElement <- {
Ring = null
Needle = null
}
function CreateSpeedTableElements(posX = 25, posY = 25) {
SpeedTableElement.Ring = GUISprite("Ring.png", g_ZeroVector, g_FullColour);
SpeedTableElement.Needle = GUISprite("Needle.png", VectorScreen(posX, posY), g_FullColour);
SpeedTableElement.Ring.AddChild(SpeedTableElement.Needle);
SpeedTableElement.Needle.Pos = g_ZeroVector;
local tempScale = SpeedTableElement.Ring.Size;
SpeedTableElement.Needle.RotationCentre = VectorScreen(tempScale.X / 2, tempScale.Y / 2);
g_SpeedHint = GUILabel(VectorScreen(0,0), Colour(255,255,255,255), "Booster: G \n Stop: H");
g_SpeedHint.FontSize = 13.5;
g_SpeedHint.TextAlignment = GUI_ALIGN_CENTER;
CheckAndUpdateVehicleTableUI();
}
function RemoveSpeedTableElements() {
SpeedTableElement.Ring = null;
SpeedTableElement.Needle = null;
if (g_SpeedHint) g_SpeedHint = null;
}
function CheckAndUpdateVehicleTableProc() {
if (g_LocalVehicle) {
local speedMagnitude = sqrt(
g_LocalVehicle.Speed.X * g_LocalVehicle.Speed.X +
g_LocalVehicle.Speed.Y * g_LocalVehicle.Speed.Y +
g_LocalVehicle.Speed.Z * g_LocalVehicle.Speed.Z
);
if (SpeedTableElement.Ring) {
SpeedTableElement.Needle.Rotation = Lerp(SpeedTableElement.Needle.Rotation,
speedMagnitude * 100,
g_SpeedTableLerpTime);
}
}
}
function CheckAndUpdateVehicleTableUI() {
if (!SpeedTableElement.Ring) return;
local tempScale = SpeedTableElement.Ring.Size;
local width = GUI.GetScreenSize().X;
local height = GUI.GetScreenSize().Y;
SpeedTableElement.Ring.Pos = VectorScreen((width - tempScale.X) - 25, (height - tempScale.Y) - 25);
if (g_SpeedHint) {
local ringPos = SpeedTableElement.Ring.Pos;
local hintWidth = g_SpeedHint.Size.X;
local hintHeight = g_SpeedHint.Size.Y;
local hintX = ringPos.X + (tempScale.X / 2) - (hintWidth / 2);
local hintY = ringPos.Y - hintHeight - 5;
g_SpeedHint.Pos = VectorScreen(hintX, hintY);
}
}
function Lerp(a, b, t) {
return a + (b - a) * t;
}And I want to bring the speedometer from this to my server (no need speed hint and stat text). But, I try copy and paste, editing the code but not bring me a answer (doesnt work).function onPlayerEnterVehicle( player, vehicle, door )
{
local stream = Stream();
stream.WriteInt(1);
stream.WriteString(vehicle.ID.tostring());
stream.SendStream(player);
local vehID = vehicle.ID;
local vehName = GetVehicleNameFromModel( vehicle.Model );
local vehHealth = vehicle.Health;
ClientMessage("Phuong tien dang lai co ten: " + vehName + " [ID: " + vehID + "] Hien tai xe nay dang co: " + vehHealth + " mau", player, 255, 255, 255);
}
function onPlayerExitVehicle( player, vehicle )
{
local stream = Stream();
stream.WriteInt(2);
stream.SendStream(player);
}and the begin the file:function SendDataToClient( player, ... )
{
if( vargv.len() > 0 && vargv[0] )
{
local byte = vargv[0],
len = vargv.len();
if( 1 > len ) Message( "ToClient <" + byte + "> No params specified." );
else
{
Stream.StartWrite();
Stream.WriteByte( byte );
for( local i = 1; i < len; i++ )
{
switch( typeof( vargv[i] ) )
{
case "integer": Stream.WriteInt( vargv[i] ); break;
case "string": Stream.WriteString( vargv[i] ); break;
case "float": Stream.WriteFloat( vargv[i] ); break;
case "bool": Stream.WriteBool( vargv[i] ); break;
}
}
if( player == null ) Stream.SendStream( null );
else if( typeof( player ) == "instance" ) Stream.SendStream( player );
else Message( "ToClient <" + byte + "> Player is not online." );
}
}
}
// B?ng Byte đ?nh danh
enum StreamType {
Speedo = 0x01
}local g_LocalVehicle = null;
local g_SpeedTableLerpTime = 0.2;
local g_ZeroVector = VectorScreen(0, 0);
local g_FullColour = Colour(255, 255, 255, 255);
local g_SpeedHint = null;
sX <- GUI.GetScreenSize().X;
sY <- GUI.GetScreenSize().Y;
function Script::ScriptLoad() {
Console.Print("[CLIENT] Loaded ClientSide Successfully!!!");
}
function Script::ScriptProcess() {
CheckAndUpdateVehicleTableProc();
}
function GUI::GameResize(width, height) {
sX = width;
sY = height;
CheckAndUpdateVehicleTableUI(); // Đã xóa CenterStatsLabels() bị lỗi!
}
function Server::ServerData(stream) {
local packetID = stream.ReadInt();
switch (packetID) {
case 1: // Lên xe
local vehID_str = stream.ReadString();
local vehID = vehID_str.tointeger();
g_LocalVehicle <- World.FindVehicle(vehID);
CreateSpeedTableElements();
break;
case 2: // Xuống xe
g_LocalVehicle = null;
RemoveSpeedTableElements();
break;
}
}
SpeedTableElement <- {
Ring = null,
Needle = null
}
function CreateSpeedTableElements(posX = 25, posY = 25) {
try {
SpeedTableElement.Ring = GUISprite("sprites/Ring.png", g_ZeroVector, g_FullColour);
SpeedTableElement.Needle = GUISprite("sprites/Needle.png", VectorScreen(posX, posY), g_FullColour);
SpeedTableElement.Ring.AddChild(SpeedTableElement.Needle);
SpeedTableElement.Needle.Pos = g_ZeroVector;
local tempScale = SpeedTableElement.Ring.Size;
SpeedTableElement.Needle.RotationCentre = VectorScreen(tempScale.X / 2, tempScale.Y / 2);
g_SpeedHint = GUILabel(VectorScreen(0,0), Colour(255,255,255,255), "Booster: G \n Stop: H");
g_SpeedHint.FontSize = 13.5;
g_SpeedHint.TextAlignment = GUI_ALIGN_CENTER;
CheckAndUpdateVehicleTableUI();
Console.Print("[SPEEDO] Dong ho Speedometer da load thanh cong!");
}
catch(err) {
Console.Print("[SPEEDO ERROR] -> " + err);
}
}
function RemoveSpeedTableElements() {
SpeedTableElement.Ring = null;
SpeedTableElement.Needle = null;
if (g_SpeedHint) g_SpeedHint = null;
}
function CheckAndUpdateVehicleTableProc() {
if (g_LocalVehicle) {
local speedMagnitude = sqrt(
g_LocalVehicle.Speed.X * g_LocalVehicle.Speed.X +
g_LocalVehicle.Speed.Y * g_LocalVehicle.Speed.Y +
g_LocalVehicle.Speed.Z * g_LocalVehicle.Speed.Z
);
if (SpeedTableElement.Ring && SpeedTableElement.Needle) {
SpeedTableElement.Needle.Rotation = Lerp(SpeedTableElement.Needle.Rotation,
speedMagnitude * 100,
g_SpeedTableLerpTime);
}
}
}
function CheckAndUpdateVehicleTableUI() {
if (!SpeedTableElement.Ring) return;
local tempScale = SpeedTableElement.Ring.Size;
local width = GUI.GetScreenSize().X;
local height = GUI.GetScreenSize().Y;
SpeedTableElement.Ring.Pos = VectorScreen((width - tempScale.X) - 25, (height - tempScale.Y) - 25);
if (g_SpeedHint) {
local ringPos = SpeedTableElement.Ring.Pos;
local hintWidth = g_SpeedHint.Size.X;
local hintHeight = g_SpeedHint.Size.Y;
local hintX = ringPos.X + (tempScale.X / 2) - (hintWidth / 2);
local hintY = ringPos.Y - hintHeight - 5;
g_SpeedHint.Pos = VectorScreen(hintX, hintY);
}
}
function Lerp(a, b, t) {
return a + (b - a) * t;
}Fluxer.SendMessage(...)
Fluxer.SendPayload(...)
Fluxer.EditMessage(...)
Fluxer.DeleteMessage(...)
Fluxer.Get(...)
Fluxer.Post(...)onFluxerReady(bot)
onFluxerMessage(message)
onFluxerEvent(eventName, jsonData)
onFluxerDispatch(event)
onFluxerResponse(response)
onFluxerError(message)
const FLUXER_TOKEN = "YOUR_BOT_TOKEN";
function onScriptLoad() {
Fluxer.ConfigureGateway(0, 1);
if (!Fluxer.Connect(FLUXER_TOKEN))
print("Could not start the Fluxer connector.");
}Fluxer.Connect() starts the connector, but that does not necessarily mean Gateway authentication has already completed.function onFluxerReady(bot) {
print(format("Fluxer authenticated as %s (%s)", bot.Username, bot.UserID));
}if (Fluxer.IsRunning()) print("Fluxer connector is running.");
if (Fluxer.IsReady()) print("Fluxer Gateway is ready.");function onScriptUnload() {
Fluxer.Disconnect();
}const FLUXER_CHANNEL_ID = "YOUR_CHANNEL_ID";
Fluxer.SendMessage(FLUXER_CHANNEL_ID, "Hello from VC:MP!");
function onPlayerJoin(player) {
Fluxer.SendMessage(FLUXER_CHANNEL_ID, format("%s joined the VC:MP server.", player.Name));
}
function onPlayerPart(player, reason) {
Fluxer.SendMessage(FLUXER_CHANNEL_ID, format("%s left the server.", player.Name));
}
function onPlayerChat(player, message) {
Fluxer.SendMessage(FLUXER_CHANNEL_ID, format("**%s:** %s", player.Name, message));
return 1;
}function onFluxerMessage(message) {
if (message.ChannelID != FLUXER_CHANNEL_ID) return;
if (message.AuthorBot) return;
Message(format("[#7C3AED][Fluxer][#FFFFFF] %s: %s", message.AuthorName, message.Content));
}local payload = "{\"content\":\"Server status\",\"embeds\":[{\"title\":\"VC:MP\",\"description\":\"The server is online\",\"color\":8134381}]}";
Fluxer.SendPayload(FLUXER_CHANNEL_ID, payload);
Fluxer.EditMessage("CHANNEL_ID", "MESSAGE_ID", "{\"content\":\"Updated VC:MP server status\"}");Fluxer.DeleteMessage("CHANNEL_ID", "MESSAGE_ID");Fluxer.Request(method, path[, jsonBody])Fluxer.Get(path[, jsonBody])
Fluxer.Post(path[, jsonBody])
Fluxer.Put(path[, jsonBody])
Fluxer.Patch(path[, jsonBody])
Fluxer.Delete(path[, jsonBody])Fluxer.Get("/users/@me");Fluxer.Get(
"/channels/CHANNEL_ID/messages?limit=25"
);Fluxer.Post("/channels/CHANNEL_ID/messages", "{\"content\":\"Hello from the REST API\"}");local requestId = Fluxer.SendMessage(
FLUXER_CHANNEL_ID,
"Hello!"
);function onFluxerResponse(response) {
print(format("Request %d returned HTTP %d", response.RequestID, response.StatusCode));
}local myRequest = Fluxer.Get("/users/@me");
function onFluxerResponse(response) {
if (response.RequestID != myRequest) return;
if (response.StatusCode >= 200 && response.StatusCode < 300) {
print("Authenticated user: " + response.Data.username);
}
else {
print(format("HTTP %d: %s", response.StatusCode, response.Body));
}
}function onFluxerMessage(message) {
if (message.AuthorBot) return;
print(format("[Fluxer] %s: %s", message.AuthorName, message.Content));
}function onFluxerMessage(message) {
if (message.AuthorBot) return;
if (message.Content == "!players") {
Fluxer.SendMessage(message.ChannelID, format("There are currently %d players online.", GetPlayers()));
}
}function onFluxerEvent(eventName, jsonData) {
print("Gateway event: " + eventName);
}function onFluxerDispatch(event) {
print(format("Dispatch %s, sequence %d", event.Name, event.Sequence));
// event.Data contains the parsed data.
}MESSAGE_CREATE -> onFluxerMessageCreate(data)
MESSAGE_UPDATE -> onFluxerMessageUpdate(data)
MESSAGE_DELETE -> onFluxerMessageDelete(data)
MESSAGE_REACTION_ADD -> onFluxerMessageReactionAdd(data)
GUILD_MEMBER_ADD -> onFluxerGuildMemberAdd(data)
GUILD_MEMBER_REMOVE -> onFluxerGuildMemberRemove(data)
CHANNEL_CREATE -> onFluxerChannelCreate(data)
CHANNEL_UPDATE -> onFluxerChannelUpdate(data)
TYPING_START -> onFluxerTypingStart(data)
VOICE_STATE_UPDATE -> onFluxerVoiceStateUpdate(data)function onFluxerGuildMemberAdd(data) {
print("A member joined guild " + data.guild_id);
}
function onFluxerMessageReactionAdd(data) {
print("Reaction added to message " + data.message_id);
}function onFluxerDispatch(event) {
print(event.Name);
// Original JSON:
print(event.Raw);
// Parsed Squirrel value:
local data = event.Data;
}Fluxer.SetPresence("{\"since\":null,\"activities\":[{\"name\":\"VC:MP\",\"type\":0}],\"status\":\"online\",\"afk\":false}");
VC:MP | 12 players
Vice City Multiplayer
Server Online
Waiting for players...local payload = "{\"content\":\"Latest server screenshot\",\"attachments\":[{\"id\":\"0\",\"filename\":\"server.png\"}]}";
Fluxer.Multipart("POST", "/channels/CHANNEL_ID/messages", payload, "screenshots/server.png", "server.png");
function onFluxerError(message) {
print("Fluxer error: " + message);
}function onFluxerResponse(response) {
if (response.StatusCode < 200 || response.StatusCode >= 300) {
print(format("Fluxer request %d failed: HTTP %d: %s", response.RequestID, response.StatusCode, response.Body));
}
}function onFluxerDisconnect(reason) {
print("Fluxer Gateway disconnected.");
}const FLUXER_TOKEN = "YOUR_BOT_TOKEN";
const FLUXER_CHANNEL_ID = "YOUR_CHANNEL_ID";
function onScriptLoad() {
Fluxer.ConfigureGateway(0, 1);
if (!Fluxer.Connect(FLUXER_TOKEN)) throw "Could not start Fluxer";
}
function onFluxerReady(bot) {
print(format("Fluxer authenticated as %s (%s)", bot.Username, bot.UserID));
Fluxer.SendMessage(FLUXER_CHANNEL_ID, "VC:MP server is online.");
}
function onPlayerJoin(player) {
Fluxer.SendMessage(FLUXER_CHANNEL_ID, format("%s joined the server.", player.Name));
}
function onPlayerChat(player, message) {
Fluxer.SendMessage(FLUXER_CHANNEL_ID, format("**%s:** %s", player.Name, message));
return 1;
}
function onFluxerMessage(message) {
if (message.ChannelID != FLUXER_CHANNEL_ID) return;
if (message.AuthorBot) return;
Message(format("[#7C3AED][Fluxer][#FFFFFF] %s: %s", message.AuthorName, message.Content));
}
function onFluxerResponse(response) {
if (response.StatusCode < 200 || response.StatusCode >= 300) {
print(format("Fluxer HTTP error %d: %s", response.StatusCode, response.Body));
}
}
function onFluxerError(message) {
print("Fluxer error: " + message);
}
function onScriptUnload() {
Fluxer.Disconnect();
}SpeedTimer <- array(100, null);
function onPlayerEnterVehicle( player, vehicle, door )
{
SpeedTimer[ player.ID ] = NewTimer( "UpdateSpeedometer", 1, 0, player.ID );
}
function onPlayerExitVehicle( player, vehicle )
{
if ( SpeedTimer[ player.ID ] != null )
{
SpeedTimer[ player.ID ].Delete();
SpeedTimer[ player.ID ] = null;
}
}
function UpdateSpeedometer( playerID )
{
local player = FindPlayer( playerID );
if ( player && player.Vehicle )
{
local vehicle = player.Vehicle;
local kmh = GetVehicleKMH( player.Vehicle );
local hp = GetVehicleHealthPercent( vehicle );
Announce( "~w~Speed: ~g~" + kmh + " ~w~KM/H. ~r~HP: "+ hp + " percent", player, 1 );
}
}
function GetVehicleKMH( vehicle )
{
if ( vehicle )
{
local speed = vehicle.Speed;
local velocity = sqrt( (speed.x * speed.x) + (speed.y * speed.y) + (speed.z * speed.z) );
return ( velocity * 180 ).tointeger();
}
return 0;
}
function GetVehicleHealthPercent( vehicle )
{
if ( vehicle )
{
local hp = vehicle.Health;
// Máu dư?i 250 là xe n?/cháy, coi như 0%
if ( hp < 250 ) return 0;
// Quy đ?i t? kho?ng [250 -> 1000] v? [0% -> 100%]
local percent = ( (hp - 250) / 7.5 ).tointeger();
return percent;
}
return 0;
}(Some line have Vietnamese text, sorry)Quote from: Necroso on Jul 31, 2026, 03:02 AMQuote from: LamFloGaming on Jul 24, 2026, 08:12 AMHello, I have a big problem: I copy a code in here: https://forum.vc-mp.org/?topic=4353.0, but I launched my server, server console is warning me: The Index 'GUI' does not exist.That's because the second part is a client-side script. You need to place it in store/script/somescript.nut
I need solution to solve this error
Version of my server: 0.4.7.1
Quote from: LamFloGaming on Jul 24, 2026, 08:12 AMHello, I have a big problem: I copy a code in here: https://forum.vc-mp.org/?topic=4353.0, but I launched my server, server console is warning me: The Index 'GUI' does not exist.That's because the second part is a client-side script. You need to place it in store/script/somescript.nut
I need solution to solve this error
Version of my server: 0.4.7.1
Quote from: Yankee on May 27, 2017, 09:00 AMIn GTA SA skin sites,there are a lot of skins and i love these skins.How can I convert them to GTA VC.Only .dff and .txd files,should I edit the XML file or what should I do ?