Random Cords when i Park Vehicle(YCMD)
#1

hello , can someone tell me what's wrong with my code of parking ..
apark used for admins only , and there is vpark used for users to park their vehicles

but when im doing apark or vpark , it parks the vehicle in bleuberry(0.0.0) and the car getting destroyed as i wrote in code but it wont respawn again .. something wrong ?



PHP код:

YCMD
:vpark(playeridparams[], help)
{
    if(
help) return SCM(playeridCOLOR_GREY"Not supported");
    new 
Float:x,Float:y,Float:z;
    new 
Float:a;
    new 
Float:health;
    new 
carid;
    new 
vmodel;
    new 
panels,doors,lights,tires;
    new 
getcarid GetPlayerVehicleID(playerid);
    if(
getcarid == PlayerInfo[playerid][pPcarkey]) { carid PlayerInfo[playerid][pPcarkey]; }
    else if(
getcarid == PlayerInfo[playerid][pPcarkey2]) { carid PlayerInfo[playerid][pPcarkey2]; }
    else return 
1;
    new 
playername[MAX_PLAYER_NAME];
    
GetVehicleHealth(caridhealth);
    
GetPlayerName(playeridplayernamesizeof(playername));
    
GetVehiclePos(caridxyz);
    
GetVehicleZAngle(carida);
    
vmodel GetVehicleModel(carid);
    
GetVehicleDamageStatus(getcarid,panels,doors,lights,tires);
    if(
IsPlayerInVehicle(playerid,carid))
    {
        
CarInfo[carid][cLocationx] = x;
        
CarInfo[carid][cLocationy] = y;
        
CarInfo[carid][cLocationz] = z;
        
CarInfo[carid][cAngle] = a;
        new 
area[35];
        
GetPlayer2DZone(playeridareasizeof(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(caridCarInfo[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(!
isnull(CarInfo[carid][cPlate]))
        {
            
SetVehicleNumberPlate(caridCarInfo[carid][cPlate]);
        }
        
SetVehicleVirtualWorld(caridCarInfo[carid][cVirWorld]);
        
SetVehicleModifications(carid);
        
TogglePlayerControllable(playerid1);
        
SetVehicleHealth(caridhealth);
        
UpdateVehicleDamageStatus(getcaridpanelsdoorslightstires);
        
PutPlayerInVehicle(playeridcarid0);
        if(
IsModelABycicle(vmodel))
        {
            new 
alarmbonnetbootobjective;
            
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1lightsalarmdoorsbonnetbootobjective);
            
engineOn[GetPlayerVehicleID(playerid)] = true;
        }
        else
        {
            new 
alarmbonnetbootobjective;
            
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0lightsalarmdoorsbonnetbootobjective);
            
engineOn[GetPlayerVehicleID(playerid)] = false;
        }
    }
    return 
1;

PHP код:
YCMD:apark(playeridparams[], help)
{
    if(
help) return SCM(playeridCOLOR_GREY"Not supported");
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:x,Float:y,Float:z,Float:a,carid,string[256];
        
carid GetPlayerVehicleID(playerid);
        
GetVehiclePos(caridxyz);
        
GetVehicleZAngle(carida);
        if(
PlayerInfo[playerid][pAdmin] >= 1)
        {
            if(
IsAnOwnableCar(carid))
            {
                
CarInfo[carid][cLocationx] = x;
                
CarInfo[carid][cLocationy] = y;
                
CarInfo[carid][cLocationz] = z;
                
CarInfo[carid][cAngle] = a;
                
format(stringsizeof(string), "~n~ You have parked your car in this location. ~n~");
                
GameTextForPlayer(playerid"You have parked this car in this position. It will respawn here."100003);
                
OnPropUpdate(4,carid);
                
DestroyVehicle(carid);
                
ownedcar[carid] = CreateVehicle(CarInfo[carid][cModel],CarInfo[carid][cLocationx],CarInfo[carid][cLocationy],CarInfo[carid][cLocationz]+1.0,CarInfo[carid][cAngle],CarInfo[carid][cColorOne],CarInfo[carid][cColorTwo],60000);
                if(
CarInfo[carid][cPaintjob] != 999)
                {
                    
ChangeVehiclePaintjob(caridCarInfo[carid][cPaintjob]);
                }
                
SetVehicleModifications(carid);
                
PutPlayerInVehicle(playeridcarid0);
                new 
lightsalarmdoorsbonnetbootobjective;
                
SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1lightsalarmdoorsbonnetbootobjective);
                  
engineOn[GetPlayerVehicleID(playerid)] = true;
                  
TogglePlayerControllable(playerid1);
                return 
1;
            }
            else
            {
                
SCM(playeridCOLOR_GREY"* You can only do this on ownable cars!");
                return 
1;
            }
        }
        else
        {
            
SCM(playeridCOLOR_GREY"* You are not authorized to use that command !");
            return 
1;
        }
    }
    return 
1;

Reply
#2

anyone ?
Reply
#3

pawn Код:
YCMD:vpark(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SCM(playerid, COLOR_GREY, "You must be in a vehicle to use this command.");
    new getcarid = GetPlayerVehicleID(playerid);
    if(getcarid != PlayerInfo[playerid][pPcarkey] && getcarid != PlayerInfo[playerid][pPcarkey2]) return SCM(playerid, COLOR_GREY, "You must be in your own vehicle to park it.");
    new Float:health, panels, doors, lights, tires;
    GetVehicleHealth(getcarid, health);
    GetVehiclePos(getcarid, CarInfo[getcarid][cLocationx], CarInfo[getcarid][cLocationy], CarInfo[getcarid][cLocationz]);
    GetVehicleZAngle(getcarid, CarInfo[getcarid][cAngle]);
    GetVehicleDamageStatus(getcarid, panels, doors, lights, tires);
    OnPropUpdate(4, getcarid);
    new newcar = ownedcar[getcarid] = CreateVehicle(CarInfo[getcarid][cModel], CarInfo[getcarid][cLocationx], CarInfo[getcarid][cLocationy], CarInfo[getcarid][cLocationz] + 1.0, CarInfo[getcarid][cAngle], CarInfo[getcarid][cColorOne], CarInfo[getcarid][cColorTwo], 60000);
    if(CarInfo[getcarid][cPaintjob] != 999) ChangeVehiclePaintjob(newcar, CarInfo[getcarid][cPaintjob]);
    if(CarInfo[getcarid][cLock])
    {
        new e, l, a77, d77, b, bo, o;
        GetVehicleParamsEx(getcarid, e, l, a77, d77, b, bo, o);
        e = (IsModelABycicle(GetVehicleModel(getcarid))) ? (1) : (0);
        SetVehicleParamsEx(newcar, e, l, a77, 1, b, bo, o);
        engineOn[newcar] = (e) ? (true) : (false);
    }
    if(!isnull(CarInfo[getcarid][cPlate])) SetVehicleNumberPlate(newcar, CarInfo[getcarid][cPlate]);
    SetVehicleVirtualWorld(newcar, CarInfo[getcarid][cVirWorld]);
    SetVehicleModifications(newcar);
    SetVehicleHealth(newcar, health);
    UpdateVehicleDamageStatus(newcar, panels, doors, lights, tires);
    DestroyVehicle(getcarid);
    PutPlayerInVehicle(playerid, newcar, 0);
    GameTextForPlayer(playerid, "You have parked your car in this location~n~It will respawn here.", 10000, 3);
    return 1;
}

YCMD:apark(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");
    if(!PlayerInfo[playerid][pAdmin]) return SCM(playerid, COLOR_GREY, "* You are not authorized to use that command !");
    new carid = GetPlayerVehicleID(playerid);
    if(!carid || !IsAnOwnableCar(carid)) return SCM(playerid, COLOR_GREY, "* You can only do this on ownable cars!");
    GetVehiclePos(carid, CarInfo[carid][cLocationx], CarInfo[carid][cLocationy], CarInfo[carid][cLocationz]);
    GetVehicleZAngle(carid, CarInfo[carid][cAngle]);
    GameTextForPlayer(playerid, "You have parked this car in this location~n~It will respawn here.", 10000, 3);
    OnPropUpdate(4, carid);
    DestroyVehicle(carid);
    new newcar = ownedcar[carid] = CreateVehicle(CarInfo[carid][cModel], CarInfo[carid][cLocationx], CarInfo[carid][cLocationy], CarInfo[carid][cLocationz] + 1.0, CarInfo[carid][cAngle], CarInfo[carid][cColorOne], CarInfo[carid][cColorTwo], 60000);
    if(CarInfo[carid][cPaintjob] != 999) ChangeVehiclePaintjob(newcar, CarInfo[carid][cPaintjob]);
    SetVehicleModifications(newcar);
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(newcar, 1, lights, alarm, doors, bonnet, boot, objective);
    engineOn[newcar] = true;
    DestroyVehicle(carid);
    PutPlayerInVehicle(playerid, newcar, 0);
    return 1;
}
Reply
#4

same problem but now the vpark doesnt work , and if im in my car and i typed vpark nothing happens , if im on foot , he says i need to be invehicle to use the Vpark ... but the apark the same bug , parking in Bleuberry(0.0.0 cords) , and i cant go to it , if player reconnect , the vehicle remains in the first position (before i'll do anycommand )
Reply
#5

Tested this:
pawn Код:
YCMD:vpark(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SCM(playerid, COLOR_GREY, "You must be in a vehicle to use this command.");
    new getcarid = GetPlayerVehicleID(playerid);
    if(getcarid != PlayerInfo[playerid][pPcarkey] && getcarid != PlayerInfo[playerid][pPcarkey2]) return SCM(playerid, COLOR_GREY, "You must be in your own vehicle to park it.");
    new Float:health, panels, doors, lights, tires;
    GetVehicleHealth(getcarid, health);
    GetVehiclePos(getcarid, CarInfo[getcarid][cLocationx], CarInfo[getcarid][cLocationy], CarInfo[getcarid][cLocationz]);
    GetVehicleZAngle(getcarid, CarInfo[getcarid][cAngle]);
    GetVehicleDamageStatus(getcarid, panels, doors, lights, tires);
    CarInfo[getcarid][cModel] = GetVehicleModel(getcarid);
    OnPropUpdate(4, getcarid);
    new newcar = ownedcar[getcarid] = CreateVehicle(CarInfo[getcarid][cModel], CarInfo[getcarid][cLocationx], CarInfo[getcarid][cLocationy], CarInfo[getcarid][cLocationz] + 1.0, CarInfo[getcarid][cAngle], CarInfo[getcarid][cColorOne], CarInfo[getcarid][cColorTwo], 60000);
    if(getcarid == PlayerInfo[playerid][pPcarkey]) PlayerInfo[playerid][pPcarkey] = newcar;
    else PlayerInfo[playerid][pPcarkey2] = newcar;
    if(CarInfo[getcarid][cPaintjob] != 999) ChangeVehiclePaintjob(newcar, CarInfo[getcarid][cPaintjob]);
    if(CarInfo[getcarid][cLock])
    {
        new e, l, a77, d77, b, bo, o;
        GetVehicleParamsEx(getcarid, e, l, a77, d77, b, bo, o);
        e = (IsModelABycicle(GetVehicleModel(getcarid))) ? (1) : (0);
        SetVehicleParamsEx(newcar, e, l, a77, 1, b, bo, o);
        engineOn[newcar] = (e) ? (true) : (false);
    }
    if(!isnull(CarInfo[getcarid][cPlate])) SetVehicleNumberPlate(newcar, CarInfo[getcarid][cPlate]);
    SetVehicleVirtualWorld(newcar, CarInfo[getcarid][cVirWorld]);
    SetVehicleModifications(newcar);
    SetVehicleHealth(newcar, health);
    UpdateVehicleDamageStatus(newcar, panels, doors, lights, tires);
    DestroyVehicle(getcarid);
    PutPlayerInVehicle(playerid, newcar, 0);
    GameTextForPlayer(playerid, "You have parked your car in this location~n~It will respawn here.", 10000, 3);
    return 1;
}

YCMD:apark(playerid, params[], help)
{
    if(help) return SCM(playerid, COLOR_GREY, "Not supported");
    if(!PlayerInfo[playerid][pAdmin]) return SCM(playerid, COLOR_GREY, "* You are not authorized to use that command !");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SCM(playerid, COLOR_GREY, "You must be in a vehicle to use this command.");
    new carid = GetPlayerVehicleID(playerid);
    if(!carid || !IsAnOwnableCar(carid)) return SCM(playerid, COLOR_GREY, "* You can only do this on ownable cars!");
    GetVehiclePos(carid, CarInfo[carid][cLocationx], CarInfo[carid][cLocationy], CarInfo[carid][cLocationz]);
    GetVehicleZAngle(carid, CarInfo[carid][cAngle]);
    CarInfo[carid][cModel] = GetVehicleModel(carid);
    GameTextForPlayer(playerid, "You have parked this car in this location~n~It will respawn here.", 10000, 3);
    OnPropUpdate(4, carid);
    new newcar = ownedcar[carid] = CreateVehicle(CarInfo[carid][cModel], CarInfo[carid][cLocationx], CarInfo[carid][cLocationy], CarInfo[carid][cLocationz] + 1.0, CarInfo[carid][cAngle], CarInfo[carid][cColorOne], CarInfo[carid][cColorTwo], 60000);
    if(CarInfo[carid][cPaintjob] != 999) ChangeVehiclePaintjob(newcar, CarInfo[carid][cPaintjob]);
    SetVehicleModifications(newcar);
    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(carid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(newcar, 1, lights, alarm, doors, bonnet, boot, objective);
    engineOn[newcar] = true;
    DestroyVehicle(carid);
    PutPlayerInVehicle(playerid, newcar, 0);
    return 1;
}
And it seems to work fine. With the vehicles being in their original position when a player reconnects, that's because you're not saving the vehicles information properly when they disconnect. This isn't something I can fix from my end, you'll have to do that yourself.
Reply
#6

aight ty mate for your help , i know the problem from where i variable was declared with same previos work .. ty brother
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)