22.08.2017, 14:53
So I've wrote up some messy code but I don't understand how SetPlayerVelocity works
Basically the player shoots this object then the other players should be dragged into the object with SetPlayerVelocity not SetPlayerPos
what I've tried (KEWL LOL)
Would appreciate any help, thanks.
PHP код:
#include <a_samp>
#include <foreach>
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new Wreckball[MAX_PLAYERS];
new CountWreck[MAX_PLAYERS];
new Float:MoveToTargetX[MAX_PLAYERS];
new Float:MoveToTargetY[MAX_PLAYERS];
new Float:MoveToTargetZ[MAX_PLAYERS];
public OnFilterScriptExit()
{
for(new o = 0; o < MAX_PLAYERS; o++)
{
DestroyObject(Wreckball[o]);
}
return 1;
}
public OnPlayerDisconnect(playerid)
{
DestroyObject(Wreckball[playerid]);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED(KEY_FIRE))
{
if(CountWreck[playerid] == 0)
{
CountWreck[playerid] = 1;
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
Wreckball[playerid] = CreateObject(18845, X, Y, Z+2, 0, 180, 0, 300);
GetPlayerCameraLookAt(playerid, X, Y, Z);
MoveToTargetX[playerid] = X;
MoveToTargetY[playerid] = Y;
MoveToTargetZ[playerid] = Z;
SetTimerEx("MoveFuckingObject", 750, 0, "i", playerid);
}
return 1;
}
return 1;
}
forward MoveFuckingObject(playerid);
public MoveFuckingObject(playerid)
{
MoveObject(Wreckball[playerid], MoveToTargetX[playerid], MoveToTargetY[playerid], MoveToTargetZ[playerid], 100.0, 0, 180, 0);
// foreach(Player,i)
{
// if(team[i] == TEAM_ZOMBIE)
// GetPlayerPos(i, X, Y, Z);
//GetXYInFrontOfPlayer(i, X, Y, 0.2);
// SetPlayerVelocity(i, 0.0, 0.0, 0.2);
}
return 1;
}
stock GetXYInFrontOfPlayer(playerid, &Float:x2, &Float:y2, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x2, y2, a);
GetPlayerFacingAngle(playerid, a);
x2 += (distance * floatsin(-a, degrees));
y2 += (distance * floatcos(-a, degrees));
}
stock GetXYBackOfPlayer(const playerid, &Float:x, &Float:y, const Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
x -= (distance * floatsin(-a, degrees));
y -= (distance * floatcos(-a, degrees));
}
stock GetXYBackOfObject(const playerid, &Float:x, &Float:y, const Float:distance)
{
new Float:a;
GetPlayerFacingAngle(playerid, a);
x -= (distance * floatsin(-a, degrees));
y -= (distance * floatcos(-a, degrees));
}
stock GetXYRightOfPlayer(playerid, &Float:X, &Float:Y, Float:distance)
{
new Float:Angle;
GetPlayerFacingAngle(playerid, Angle); Angle -= 90.0;
X += floatmul(floatsin(-Angle, degrees), distance);
Y += floatmul(floatcos(-Angle, degrees), distance);
}
GetPlayerCameraLookAt(playerid, &Float:X, &Float:Y, &Float:Z)
{
new Float:Destination[3], Float:Camera[3], Float:Vector[3];
GetPlayerPos(playerid, Destination[0], Destination[1], Destination[2]);
GetPlayerCameraPos(playerid, Camera[0], Camera[1], Camera[2]);
GetPlayerCameraFrontVector(playerid, Vector[0], Vector[1], Vector[2]);
new Float: posAngle = atan2(floatsub(Destination[1],Camera[1]),floatsub(Destination[0],Camera[0]));
if(posAngle > 360) posAngle-=360; posAngle+=270; posAngle *= -1;
Destination[0] += 50.0 * floatsin(posAngle, degrees);
Destination[1] += 50.0 * floatcos(posAngle, degrees);
new Float:dis = floatsqroot((Camera[0] - Destination[0]) * (Camera[0] - Destination[0]) + (Camera[1] - Destination[1]) * (Camera[1] - Destination[1]) + (Camera[2] - Destination[2]) * (Camera[2] - Destination[2]));
X = Vector[0] * dis + Camera[0]; Y = Vector[1] * dis + Camera[1]; Z = Vector[2] * dis + Camera[2];
}
what I've tried (KEWL LOL)
PHP код:
forward MoveFuckingObject(playerid);
public MoveFuckingObject(playerid)
{
MoveObject(Wreckball[playerid], MoveToTargetX[playerid], MoveToTargetY[playerid], MoveToTargetZ[playerid], 100.0, 0, 180, 0);
// foreach(Player,i)
{
// if(team[i] == TEAM_ZOMBIE)
// GetPlayerPos(i, X, Y, Z);
//GetXYInFrontOfPlayer(i, X, Y, 0.2);
// SetPlayerVelocity(i, 0.0, 0.0, 0.2);
}
return 1;
}