08.02.2014, 17:50
(Currently using 0.3z RC2)
SetPlayerCamera is not working at all for me at fast intervals:
https://sampwiki.blast.hk/wiki/SetPlayerCameraPos
https://sampwiki.blast.hk/wiki/GetPlayerCameraPos
"Important Note: Player's camera positions are only updated once a second, unless aiming.
It is recommended to set a 1 second timer if you wish to take action that relies on a player's camera position."
But that only appears at GetPlayerCameraPos and not SetPlayerCameraPos;
I've made a little quick code to test if I could get an earthquake effect by quickly adjusting the camera of a player:
What this code does is practically set the camera of the player each X MS to a random position of the original position during 5 seconds and then at the end set the player camera back to behind the player.
However my camera in game isn't ever changed, and according the debug the script applies the SetPlayerCamera command as it's meant to...
This is with a 100MS delay between each camera position set for 5 seconds. At the end of said interval the camera is set back to the player's back, yet the camera itself is never set.
SetPlayerCamera is not working at all for me at fast intervals:
https://sampwiki.blast.hk/wiki/SetPlayerCameraPos
https://sampwiki.blast.hk/wiki/GetPlayerCameraPos
"Important Note: Player's camera positions are only updated once a second, unless aiming.
It is recommended to set a 1 second timer if you wish to take action that relies on a player's camera position."
But that only appears at GetPlayerCameraPos and not SetPlayerCameraPos;
I've made a little quick code to test if I could get an earthquake effect by quickly adjusting the camera of a player:
What this code does is practically set the camera of the player each X MS to a random position of the original position during 5 seconds and then at the end set the player camera back to behind the player.
pawn Код:
dcmd_debug(playerid, params[])
{
new Float:fPX, Float:fPY, Float:fPZ;
GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
ShakeCamera(playerid, strval(params), gettime()+5, fPX, fPY, fPZ);
return 1;
}
Float:frandom(Float:max, Float:min = 0.0, dp = 4)
{
new
// Get the multiplication for storing fractional parts.
Float:mul = floatpower(10.0, dp),
// Get the max and min as integers, with extra dp.
imin = floatround(min * mul),
imax = floatround(max * mul);
// Get a random int between two bounds and convert it to a float.
return float(random(imax - imin) + imin) / mul;
}
forward ShakeCamera(playerid, interval, time, Float:fPX, Float:fPY, Float:fPZ);
public ShakeCamera(playerid, interval, time, Float:fPX, Float:fPY, Float:fPZ)
{
if(gettime() >= time)
{
SetCameraBehindPlayer(playerid);
print("Stopped");
return 1;
}
new Float:fTPX, Float:fTPY, Float:fTPZ;
fTPX = fPX + frandom(3.0,-3.0,2);
fTPY = fPY + frandom(3.0,-3.0,2);
fTPZ = fPZ + frandom(3.0,-3.0,2);
SetPlayerCameraPos(playerid, fTPX, fTPY, fTPZ);
printf("SetPlayerCameraPos(playerid, %f, %f, %f);",fTPX,fTPY,fTPZ);
SetTimerEx("ShakeCamera", interval, false, "iiifff", playerid, interval, time, fPX, fPY, fPZ);
printf("Called timer: %d %d %d", playerid, interval, time);
return 1;
}
This is with a 100MS delay between each camera position set for 5 seconds. At the end of said interval the camera is set back to the player's back, yet the camera itself is never set.
Код:
[08/02/2014 15:46:41] SetPlayerCameraPos(playerid, -2136.927490, -166.110610, 37.895198); [08/02/2014 15:46:41] SetPlayerCameraPos(playerid, -2136.277587, -170.090606, 35.545200); [08/02/2014 15:46:41] SetPlayerCameraPos(playerid, -2133.597656, -168.830612, 35.995201); [08/02/2014 15:46:41] SetPlayerCameraPos(playerid, -2133.287597, -167.830612, 37.785198); [08/02/2014 15:46:41] SetPlayerCameraPos(playerid, -2136.327636, -168.740600, 37.605197); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2133.577636, -168.900604, 37.595199); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2137.537597, -169.600601, 35.865200); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2135.627685, -169.200607, 35.165199); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2134.037597, -167.270599, 36.715198); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2134.327636, -169.090606, 38.305198); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2134.037597, -170.240600, 36.585201); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2137.847656, -168.440612, 35.785198); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2133.187500, -167.830612, 37.525199); [08/02/2014 15:46:42] SetPlayerCameraPos(playerid, -2137.507568, -166.360610, 36.935199); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2135.917480, -168.000610, 34.625198); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2133.647705, -167.090606, 36.455200); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2137.887695, -168.200607, 34.185199); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2137.687500, -170.900604, 35.205200); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2134.407470, -167.960601, 36.185199); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2132.367675, -169.550613, 39.015197); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2137.837646, -166.840606, 34.735198); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2136.167480, -166.630599, 37.915199); [08/02/2014 15:46:43] SetPlayerCameraPos(playerid, -2134.287597, -168.170608, 37.905200); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2137.767578, -170.710601, 34.135200); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2135.997558, -170.250610, 35.015197); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2137.787597, -166.430603, 36.345199); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2132.077636, -171.880599, 37.955200); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2135.547607, -166.630599, 38.985198); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2132.847656, -170.600601, 36.035198); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2135.277587, -171.440612, 37.415199); [08/02/2014 15:46:44] SetPlayerCameraPos(playerid, -2135.287597, -167.310607, 33.855197); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2136.857666, -171.090606, 36.145198); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2137.977539, -168.020599, 36.905200); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2135.147705, -168.820602, 34.495201); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2134.967529, -170.580612, 37.055198); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2132.247558, -171.620605, 33.915199); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2136.897705, -166.280609, 37.025199); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2136.707519, -166.170608, 36.495201); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2137.217529, -171.120605, 34.225200); [08/02/2014 15:46:45] SetPlayerCameraPos(playerid, -2137.487548, -170.980606, 37.755199);