Vice City: Multiplayer

VC:MP Discussion => Support => Tutorials => Topic started by: KrOoB_ on Jan 13, 2021, 12:29 PM

Title: [LiveMap] Server to Website
Post by: KrOoB_ on Jan 13, 2021, 12:29 PM
Vice City LiveMap (http://193.111.77.123/)
(https://i.ibb.co/pdWDm30/image.png)

Website
Install XAMPP
You need a website so you have to install XAMPP (https://www.apachefriends.org/tr/index.html)

[After Installation]
Download this (https://www.mediafire.com/file/5t8k3ptjnnkf5wl/htdocs.rar/file) and extract to X:\xampp\htdocs\ (delete everything in htdocs before)

VC:MP
Download this (https://git.doszgep.hu/vcmp/json/-/releases) plugin(json) and move it to plugins folder then add the plugin's name to server.cfg
After that place this code to your main.nut (you can add more features)
function onScriptLoad()
{
  NewTimer("LiveMap", 1000, 0);
}

function LiveMap()
{
   local i = 0, ii = 0, plrveh = null, plrspec = null;
    local players = [];
    if (GetPlayers() > 0) {
        while ((i < GetMaxPlayers()) && (ii < GetPlayers())) {
            local plr = FindPlayer(i++);
            if (!plr) continue;

            if (plr.Vehicle) plrveh = {
                model = plr.Vehicle.Model,
                color = [plr.Vehicle.Colour1, plr.Vehicle.Colour2],
                health = plr.Vehicle.Health
            }
            else plrveh = null;

            players.push({
                id = plr.ID,
                name = plr.Name,
                skin = plr.Skin,
                team = plr.Team,
                hp = plr.Health,
                ap = plr.Armour,
                score = plr.Score,
                cash = plr.Cash,
                ping = plr.Ping,
                weapon = plr.Weapon,
                vehicle = plrveh,
                pos = {
                    x = plr.Pos.x,
                    y = plr.Pos.y
                },
                spawned = plr.IsSpawned,
                spectating = plrspec
            });
            ii++;
        }
    }
    local export = {
        hostname = GetServerName(),
        weather = GetWeather(),
        hour = GetHour(),
        minute = GetMinute(),
        numplayers = GetPlayers(),
        maxplayers = GetMaxPlayers(),
        players = players
    }

    try {
        toJSONFile("C:/xampp/htdocs/data.json", export, JSON_C_TO_STRING_PRETTY);
    }
    catch (e) {
        print("Export failed: " + e);
    }

}

Start the server and open your website
CREDITS
huncrys (Kristóf Bach)
Gudio
Their github link (https://github.com/huncrys/vcmp-livemap)