Crashing through windshield
#1

Hi, I'm working on my roleplay gamemode and I'm trying to add some nice features to the damage system. My question is how can I make player crash through windshield when he crashes with a vehicle? I'm using Emmet's callbacks include which has OnPlayerCrashVehicle callback. I know I need to use SetPlayerVelocity to do that. I tried doing it myself, but it I couldn't get it work how it's supposed to. Can someone explain me how to do that?
Reply
#2

I don't know if there is actually a way to make the windshield break, but you can play around with different values in SetPlayerVelocity. Sending the player forward from the vehicle would be modifying the y coordinate positively.
Reply
#3

Yes, I don't need the windshield to be broken, all I need is throw the player out of the windshield. I tried adding y to SetPlayerVelocity like you said, but the problem here is that it throws you to north regardless of your facing angle.
That's what I've done so far:
Код:
public OnPlayerCrashVehicle(playerid, vehicleid, Float:damage)
{
	new Float:x, Float:y, Float:z;
				
	GetPlayerPos(playerid, x, y, z);
	SetPlayerPos(playerid, x, y, z + 1.0);			
	SetPlayerVelocity(playerid, 0.0, 1.0, 1.0);
	return 1;
}
So basically all I need is throw player to wherever he is facing.
Reply
#4

You're throwing the player to 0.0, 0.0, 0.0. Try this:

pawn Код:
public OnPlayerCrashVehicle(playerid, vehicleid, Float:damage)
{
    new Float:x, Float:y, Float:z, Float:angle;

    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y, z + 1.0);
    GetVehicleZAngle(vehicleid, angle);
    SetPlayerVelocity(playerid, x + (damage * floatsin(-angle, degrees), y + (damage * floatcos(-angle, degrees), 1.0);
    return 1;
}
That will throw the player in front of him. damage will be the distance that the player will be throwed. You can change it to a constant value if you like.

I don't tested it IG, but I've done some test about that a long time ago. So I think it will work fine
Reply
#5

Quote:
Originally Posted by EnzoMetlc
Посмотреть сообщение
You're throwing the player to 0.0, 0.0, 0.0. Try this:

pawn Код:
public OnPlayerCrashVehicle(playerid, vehicleid, Float:damage)
{
    new Float:x, Float:y, Float:z, Float:angle;

    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y, z + 1.0);
    GetVehicleZAngle(vehicleid, angle);
    SetPlayerVelocity(playerid, x + (damage * floatsin(-angle, degrees), y + (damage * floatcos(-angle, degrees), 1.0);
    return 1;
}
That will throw the player in front of him. damage will be the distance that the player will be throwed. You can change it to a constant value if you like.

I don't tested it IG, but I've done some test about that a long time ago. So I think it will work fine
I tried this and it bugged my screen out. Maybe because you are adding player's position x and y to player's x and y velocity? But I found this https://sampforum.blast.hk/showthread.php?tid=122396 and it works perfectly.
I made it look a little bit better so this is what it looks like now:
Код:
	new Float:x, Float:y, Float:z, Float:angle;

	GetPlayerPos(playerid, x, y, z);
	SetPlayerPos(playerid, x, y, z + 2.0);

	GetVehicleZAngle(vehicleid, angle);
	SetPlayerVelocity(playerid, 0.25 * floatsin(-angle, degrees), 0.25 * floatcos(-angle, degrees), 0.0);
Thank you though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)