public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(newkeys & KEY_WALK))
{
if(gettime() - 6 < Abilitys[playerid][SuperPower])return GameTextForPlayer(playerid,"~w~ Power Recharging!",1000,5);
ApplyAnimation(playerid,"ped","Shove_Partial",3.9,0,1,1,1,1,1);
SetPlayerAttachedObject(playerid,0,18683,6);
SetPlayerAttachedObject(playerid,1,18728,6);
SetPlayerAttachedObject(playerid,2,338,6);
new Float:x,Float:y,Float:z,Float:Angle;
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
GetPlayerFacingAngle(playerid,Float:Angle);
Abilitys[playerid][SuperPower] = gettime();
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 6.0)
{
new Float:vec[4];
GetPlayerFacingAngle(i,Float:Angle);
GetPlayerVelocity(i,Float:x,Float:y,Float:z);
SetPlayerVelocity(i,Float:x+0.3,Float:y+0.3,Float:z+0.2);
SetPlayerFacingAngle(i,Float:Angle);
GetPlayerVelocity(i,vec[0],vec[1],vec[2]); GetPlayerFacingAngle(i,vec[3]);
}
}
}
return 1;
}
Try removing the GetPlayerPos and FacingAngle from playerid and ony have it for the distance player.
|
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(newkeys & KEY_WALK))
{
if(gettime() - 6 < Abilitys[playerid][SuperPower])return GameTextForPlayer(playerid,"~w~ Power Recharging!",1000,5);
ApplyAnimation(playerid,"ped","Shove_Partial",3.9,0,1,1,1,1,1);
SetPlayerAttachedObject(playerid,0,18683,6);
SetPlayerAttachedObject(playerid,1,18728,6);
SetPlayerAttachedObject(playerid,2,338,6);
new Float:x,Float:y,Float:z,Float:Angle;
Abilitys[playerid][SuperPower] = gettime();
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(GetDistanceBetweenPlayers(playerid,i) < 6.0)
{
new Float:vec[4];
GetPlayerVelocity(i,Float:x,Float:y,Float:z);
SetPlayerVelocity(i,Float:x+0.3,Float:y+0.3,Float:z+0.2);
GetPlayerVelocity(i,vec[0],vec[1],vec[2]); GetPlayerFacingAngle(i,vec[3]);
}
}
}
return 1;
}
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(i==playerid) continue;
if(GetDistanceBetweenPlayers(playerid,i) < 6.0)
{
new Float:vec[4];
GetPlayerFacingAngle(i,Float:Angle);
GetPlayerVelocity(i,Float:x,Float:y,Float:z);
SetPlayerVelocity(i,Float:x+0.3,Float:y+0.3,Float:z+0.2);
SetPlayerFacingAngle(i,Float:Angle);
GetPlayerVelocity(i,vec[0],vec[1],vec[2]); GetPlayerFacingAngle(i,vec[3]);
}
}
for(new i; i < MAX_PLAYERS; i++)
{
if(i != playerid && GetDistanceBetweenPlayers(playerid, i) < 6.0)
{
new
Float:vec[4]
;
GetPlayerVelocity(i, x, y, z);
SetPlayerVelocity(i, x + 0.3, y + 0.3, z + 0.2);
GetPlayerVelocity(i, vec[0], vec[1], vec[2]);
GetPlayerFacingAngle(i, vec[3]);
}
}
You're not checking if the loop is finding your playerid or not. This should fix it.
PHP код:
|