20.08.2011, 16:05
Quote:
Unfortunately, I'm not the greatest with math and can hardly understand how to properly use half of these functions. I was curious, as you PMed me awhile ago telling me you had a function that could do so, if one of these functions could be manipulated to allow correct vehicle offsets when placing objects on certain areas of the map like slopes. For example, if I wanted to place a trash bin on the side of a trash truck, while it's going uphill, using the default offsets wouldn't work.
Would you mind showing me a short example of how to make that work with one of these functions (of course if it's not already added that would be a possible suggestion)? Thanks. |
pawn Код:
public OnPlayerKeyStateChange(PlayerID, NewKeys, OldKeys) {
// pressing fire key
if ((NewKeys & KEY_FIRE) && !(OldKeys & KEY_FIRE)) {
if (IsPlayerInAnyVehicle(PlayerID)) {
new vehtype;
vehtype = GetVehicleModel(GetPlayerVehicleID(PlayerID));
if (vehtype == 564) {// while in RC tiger
new time;
time = GetPVarInt(PlayerID, "LastTigerShot");
if (time + 500 < TickCount()) {
new Float:turretstart[3];
new Float:inp[3];
inp[0] = 0.000; inp[1] = -1.2559; inp[2] = 0.3384;
MPProjectPointOnVehicle(GetPlayerVehicleID(PlayerID), inp[0], inp[1], inp[2], turretstart[0], turretstart[1], turretstart[2], 1);
CreateObject( 921, turretstart[0], turretstart[1], turretstart[2], 0.0, 0.0, 0.0);
SetPVarInt(PlayerID, "LastTigerShot", TickCount()); // shot time
}
}
}
}
}
When you hit fire key while inside a RC tiger, this will take the turret end point coordinates, and project them thru car's rotations to get exit coordinates in game world space, then create a small light object at those points.
An alternative would be, to extend the exit turret coordinates further, and create a explosion instead, this would make the RC tank able to fire / explode things properly.
Screenshot - notice that objects are placed correctly taking the rc tank's pitch / roll / yaw into account:
You can use this, and get trash van's specific coordinates to place trash cans behind it, it's easy to get coordinates on vehicles - place a car in my map editor at exact 0,0,0 coordinates with no rotation, then click on the vehicle and status bar will show you vehicle-based coordinates.