06.10.2009, 13:37
Ive got this so when you press space it spectates a Shamal when your in the range of it. That works fine, its just getting out that doesnt work. When i try to exit with space it looks like it turns spec off and sets the players pos alittle bit away but then straight after it respawns you. How can this be fixed?
ive tried swapping these around but seems to do the same thing.
pawn Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new InShamal[MAX_PLAYERS];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new Float:X, Float:Y, Float:Z;
if (PRESSED(KEY_SPRINT))
{
if(InShamal[playerid] == 0)
{
GetVehiclePos(Shamal, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 7.0, X, Y, Z))
{
InShamal[playerid] = 1;
TogglePlayerSpectating(playerid, 1);
PlayerSpectateVehicle(playerid, Shamal, 1);
}
}
else if(InShamal[playerid] == 1)
{
GetVehiclePos(Shamal, X, Y, Z);
TogglePlayerSpectating(playerid, 0);
InShamal[playerid] = 0;
SetPlayerPos(playerid, X, Y+3, Z);
}
}
return 1;
}
pawn Код:
GetVehiclePos(Shamal, X, Y, Z);
TogglePlayerSpectating(playerid, 0);
InShamal[playerid] = 0;
SetPlayerPos(playerid, X, Y+3, Z);