SA-MP Forums Archive
CMD:vpark issue - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD:vpark issue (/showthread.php?tid=436879)



CMD:vpark issue - UnknownGamer - 13.05.2013

pawn Код:
CMD:vpark(playerid, params[])
{
    new Float:x,Float:y,Float:z;
    new Float:a;
    new Float:health;
    new carid;
    new getcarid;
    if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { carid = PlayerInfo[playerid][pPcarkey]; }
    else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { carid = PlayerInfo[playerid][pPcarkey2]; }
    else { return 1; }
    getcarid = GetPlayerVehicleID(playerid);
    new playername[MAX_PLAYER_NAME];
    new vhealth = GetVehicleHealth(carid, health);
    GetPlayerName(playerid, playername, sizeof(playername));
    GetVehiclePos(carid, x, y, z);
    GetVehicleZAngle(carid, a);
    if(IsPlayerInVehicle(playerid,carid) && CarInfo[carid][cOwned] == 1)
    {
        if(PlayerInfo[playerid][pPcarkey] == 9999  && PlayerInfo[playerid][pPcarkey2] == 9999)
        {
            SCM(playerid, COLOR_GREY, "You don't own a car.");
            return 1;
        }
        if(getcarid == carid)
        {
            CarInfo[carid][cLocationx] = x;
            CarInfo[carid][cLocationy] = y;
            CarInfo[carid][cLocationz] = z;
            CarInfo[carid][cAngle] = a;
            new area[35];
            GetPlayer2DZone(playerid, area, sizeof(area));
            OnPropUpdate(4,carid);
            DestroyVehicle(carid);
            ownedcar[carid] = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz],CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
            if(CarInfo[carid][cPaintjob] != 999)
            {
                ChangeVehiclePaintjob(carid, CarInfo[carid][cPaintjob]);
            }
            if(CarInfo[carid][cLock] == 1)
            {
                new e,l,a77,d77,b,bo,o;
                GetVehicleParamsEx(carid,e,l,a77,d77,b,bo,o);
                SetVehicleParamsEx(carid,e,l,a77,1,b,bo,o);
            }
            if(CarInfo[carid][cPlate] != 999)
            {
                SetVehicleNumberPlate(carid, CarInfo[carid][cPlate]);
            }
            SetVehicleVirtualWorld(carid, CarInfo[carid][cVirWorld]);
            SetVehicleModifications(carid);
            TogglePlayerControllable(playerid, 1);
            SetVehicleHealth(carid, vhealth);
            PutPlayerInVehicle(playerid, carid, 0);
            new lights, alarm, doors, bonnet, boot, objective;
            SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, lights, alarm, doors, bonnet, boot, objective);
            engineOn[GetPlayerVehicleID(playerid)] = false;
        }
    }
    return 1;
}
Why does that set my car hp to 1.0 when i vpark.

It is 1000 before vpark, and then on vpark car goes boom

i want it to vpark at the health it was before destroy and recreate


Re: CMD:vpark issue - [HiC]TheKiller - 13.05.2013

The function GetVehicleHealth doesn't return a specific value but the second parameter saves the vehicle health. You're trying to set the vehicles health as the value that GetVehicleHealth returns, probably is one. The variable health is what the vehicles health is actually saved into. Change

pawn Код:
SetVehicleHealth(carid, vhealth);
to

pawn Код:
SetVehicleHealth(carid, health);