unable to park vehicle in other virtual world
#1

Hello, I'm trying to make it possible to park vehicles in another VW but it isn't working see park command:



PHP код:
CMD:park(playeridparams[])
{
    if(
PlayerInfo[playerid][pVehicleKeysFrom] != INVALID_PLAYER_ID)
    {
        new 
ownerid PlayerInfo[playerid][pVehicleKeysFrom];
        if(
IsPlayerConnected(ownerid))
        {
            new 
PlayerInfo[playerid][pVehicleKeys];
            if(
IsPlayerInVehicle(playeridPlayerVehicleInfo[ownerid][d][pvId]))
            {
                if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_GREY"You must be in the driver seat.");
                new 
Float:xFloat:yFloat:zFloat:angleFloat:health;
                
GetVehicleHealth(PlayerVehicleInfo[ownerid][d][pvId], health);
                if(
health 800) return SendClientMessage(playeridCOLOR_GREY" Your vehicle is too damaged to park it.");
                if(
PlayerInfo[playerid][pLockCar] == GetPlayerVehicleID(playerid)) PlayerInfo[playerid][pLockCar] = INVALID_VEHICLE_ID;
                if(
IsARC(GetPlayerVehicleID(playerid))) // RC Vehicles
                
{
                    new 
Float:vehPos[3];
                    
GetVehiclePos(GetPlayerVehicleID(playerid),vehPos[0], vehPos[1], vehPos[2]);
                    
SetPlayerPos(playerid,vehPos[0], vehPos[1]+0.5vehPos[2]+0.5);
                }
                new 
vw;
                
vw PlayerInfo[playerid][pVW];
                
GetVehiclePos(PlayerVehicleInfo[ownerid][d][pvId], xyz);
                
GetVehicleZAngle(PlayerVehicleInfo[ownerid][d][pvId], angle);
                
SurfingCheck(GetPlayerVehicleID(playerid));
                
UpdatePlayerVehicleParkPosition(owneriddxyzanglehealth);
                
PutPlayerInVehicle(playeridGetPlayerVehicleID(playerid), 0);
                
SetPlayerArmedWeapon(playerid0);
                
SetVehicleVirtualWorld(PlayerVehicleInfo[ownerid][d][pvId], vw);
                new 
string[29 + (MAX_PLAYER_NAME 2)];
                
format(stringsizeof(string), "* %s has parked %s's vehicle."GetPlayerNameEx(playerid), GetPlayerNameEx(ownerid));
                
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                return 
1;
            }
        }
    }
    for(new 
MAX_PLAYERVEHICLESd++)
    {
        if(
IsPlayerInVehicle(playeridPlayerVehicleInfo[playerid][d][pvId]))
        {
            new 
Float:xFloat:yFloat:zFloat:angleFloat:health;
            
GetVehicleHealth(PlayerVehicleInfo[playerid][d][pvId], health);
            if(
GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_GREY"You must be in the driver seat.");
            if(
health 800) return SendClientMessage(playeridCOLOR_GREY" Your vehicle is too damaged to park it.");
            if(
PlayerInfo[playerid][pLockCar] == GetPlayerVehicleID(playerid)) PlayerInfo[playerid][pLockCar] = INVALID_VEHICLE_ID;
            
GetVehiclePos(PlayerVehicleInfo[playerid][d][pvId], xyz);
            
GetVehicleZAngle(PlayerVehicleInfo[playerid][d][pvId], angle);
            
SurfingCheck(GetPlayerVehicleID(playerid));
            
UpdatePlayerVehicleParkPosition(playeriddxyzanglehealth);
            
PutPlayerInVehicle(playeridPlayerVehicleInfo[playerid][d][pvId], 0);
            
SetPlayerArmedWeapon(playerid0);
            new 
string[30 + (MAX_PLAYER_NAME 2)];
            
format(stringsizeof(string), "* %s has parked their vehicle."GetPlayerNameEx(playerid));
            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            return 
1;
        }
    }
    
SendClientMessage(playeridCOLOR_GREY"You need to be inside a vehicle that you own.");
    return 
1;

Reply
#2

Make a new variable inside PlayerVehicleInfo enum to save vehicle virtual world, and set vehicle virtual world using that variable once the vehcle respawned.
Reply
#3

Quote:
Originally Posted by X337
Посмотреть сообщение
Make a new variable inside PlayerVehicleInfo enum to save vehicle virtual world, and set vehicle virtual world using that variable once the vehcle respawned.
I do not understand what you mean by that ? little example ?
Reply
#4

Can you show command / function to respawn parked vehicle?
Reply
#5

Quote:
Originally Posted by X337
Посмотреть сообщение
Can you show command / function to respawn parked vehicle?
Its on the /park command, I can use /setvw inside a car to get in another VW but I cant park it there it needs to be added on /park command I dont have a respawn function
Reply
#6

bump
Reply
#7

Apparently you aren't saving the virtual world the vehicle is in, so it's only logical that when vehicles load they will be put into the default virtual world.
Reply
#8

Find this Enum PlayerVehicleInfo and add virtual_world to it.

Then add the parameter vw to UpdatePlayerVehicleParkPosition and pass to it your vw var. Now remember to add virtual_world to any function you delete / save / create.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)