Posts: 944
Threads: 128
Joined: Sep 2014
Reputation:
0
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?
Posts: 3,133
Threads: 71
Joined: Dec 2013
Reputation:
0
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.
Posts: 2,041
Threads: 97
Joined: Jun 2013
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