Vehicle Velocity
#1

Is there any way to prevent vehicle to stop, when someone teleports to it?

I tried with PutPlayerInVehicle and SetPlayerVelocity but if the player teleports to a car as a passenger, the car will be stopped (will not have the same velocity as before). Any ideas?

This is my code:
pawn Код:
Player[playerid][pVehicle] = CreateVehicle(ModelID,xPos,yPos,zPos + 1,Ang,VehicleColors[Color1],VehicleColors[Color2],0);
        SetVehicleVirtualWorld(Player[playerid][pVehicle],Player[playerid][pWorld]);
        PlayerPlaySound(playerid,1056,0,0,0);

        new Count;

        for(new PlayerNumber;PlayerNumber < MAX_PLAYERS;PlayerNumber++)
        {
            if(IsPlayerConnected(PlayerNumber))
            {
                if(PlayerNumber != playerid)
                {
                    if(PlayersInVehicle[PlayerNumber] == TRUE)
                    {
                        if(VehicleSeats[ModelID - 400] > Count)
                        {
                            Count++;
                            PlayerPlaySound(PlayerNumber,1056,0,0,0);
                            PutPlayerInVehicle(PlayerNumber,Player[playerid][pVehicle],Count);
                            SetPlayerVelocity(PlayerNumber,xVel,yVel,zVel);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
       
        PutPlayerInVehicle(playerid,Player[playerid][pVehicle],0);
        SetPlayerVelocity(playerid,xVel,yVel,zVel);
        SetVehicleVelocity(Player[playerid][pVehicle],xVel,yVel,zVel);
Reply
#2

Do you even use GetVehicleVelocity before putting the player in the vehicle? because in your current code xVel, yVel and zVel appears to be 0.0 0.0 0.0 .. and don't set the player's velocity after putting them in the vehicle, thats a waste.

And try putting them in as a driver then settings velocity then putting them in as a passenger
Reply
#3

I am using GetVehicleVelocity. I just pasted main piece of code. Please ignore SetPlayerVelocity because I had just playing and messing my code if I would get better results, but I hadn't. I think that the problem is, that the player who warp as passenger don't stream so quick in drivers car, so car is pushed away because of passenger speed which is zero at that moment. Any idea how to fix that (maybe timer for 10ms and then apply car speed, but I want more accurate)?
Reply
#4

Hi! Today I was messing with my code again and I found one strange 'bug':

I add this code:
pawn Код:
//code to spawn vehicle blah blah...
        KillTimer(Player[playerid][pTimer_UpdateVehicle]);
        Player[playerid][pTimer_UpdateVehicle] = SetTimerEx("UpdateSpawnedVehicle",1000,0,"dfff",playerid,xVel,yVel,zVel);
    }

    return 1;
}

forward UpdateSpawnedVehicle(playerid,xVel,yVel,zVel);
public UpdateSpawnedVehicle(playerid,xVel,yVel,zVel)
{
    PutPlayerInVehicle(playerid,Player[playerid][pVehicle],0);
    SetVehicleVelocity(Player[playerid][pVehicle],xVel,yVel,zVel);
    return 1;
}
The strange bug is that when I spawn the vehicle, the screen goes white and it shows Loading... at center of the screen (I've seen this before), but when I spawn the vehicle several times, the screen goes normal and then when I press LMB, it shows me in center of the screen BOMB ARMED (note: I dont have this code in my script). Why is my code messing with singleplayer functions now? I really need help, please.

EDIT: Nevermind, I forgot to add float mark in parameters.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)