08.12.2017, 21:47
Hey. I tried to make the function of tilting through the timer, but it still does not work correctly. Can you help me?
Anyway, you can go beyond the polygon
PHP код:
SetPlayerTimerEx(playerid, "@@CheckPlayerInPolygons", 250, -1, "d", playerid);
PHP код:
@@CheckPlayerInPolygons(const playerid);
@@CheckPlayerInPolygons(const playerid)
{
new Float: x_pos,
Float: y_pos,
Float: z_pos;
GetPlayerPos(playerid, x_pos, y_pos, z_pos);
if(!IsPointInPolygon(x_pos, y_pos, { 42.0,2336.0,
-1327.0,2601.0,
-1349.0,2675.0,
-1397.0,2712.0,
-1435.0,2728.0,
-1501.0,2737.0,
-1560.0,2740.0,
-1627.0,2734.0,
-1653.0,2718.0,
-1639.0,2654.0,
-1610.0,2604.0,
-1604.0,2547.0,
-1596.0,2499.0,
-1474.0,2486.0,
-1406.0,2521.0,
-1337.0,2523.0,
-1327.0,2601.0}))
{
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
new Float: rZ; // the only angle you can get is rZ
GetPlayerFacingAngle(playerid, rZ); // use 0.0 for rX and rY
// oX (right vector offset) = 0.0, oY (front vector offset) = 5.0, oZ (up vector offset) = 0.0
EulerRotate(0.0, 0.0, rZ, 0.0, -5.0, 0.0, X, Y, Z);
// X, Y, Z should now be 5 units before the player
SetPlayerPos(playerid, X, Y, Z);
}
}
Quote:
Well, it is a bug in your code, no clue how you use GetXYInFrontOfPlayer to determine if the player is outside or not but the correct solution for your problem would be to check if the player is inside a polygon
Refer to IsPlayerInPolygon, it can be found in 3DTryg, it is based on ray-casting (wiki) Still remember that RyDeR`posted the function and ****** said, it has been here for years XD |