Quick help -
Oh - 21.12.2011
pawn Код:
GetPlayerPos(playerid, x, y, z);
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
So basically I just want to know how to make this object get position infront of you about 1 (foot? idk what the measurement system is)
Re: Quick help -
Tee - 21.12.2011
So you want to create the object infront of the player?
Re: Quick help -
FarSe. - 21.12.2011
pawn Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{ // Created by ******
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) {
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}
GetXYInFrontOfPlayer(playerid,x,y,1.0);
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
Re: Quick help -
Oh - 21.12.2011
Quote:
Originally Posted by FarSe.
pawn Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) { // Created by ******
new Float:a;
GetPlayerPos(playerid, x, y, a); GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) { GetVehicleZAngle(GetPlayerVehicleID(playerid), a); }
x += (distance * floatsin(-a, degrees)); y += (distance * floatcos(-a, degrees)); }
GetXYInFrontOfPlayer(playerid,x,y,1.0);
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
|
I've never seen that function, nor know where to put the coding at to be honest. :S
Reading about it saying it's a stock function, still getting errors. Gonna figure this out though.
Re: Quick help -
Tee - 21.12.2011
The function below, put it somewhere above the code you posted. It
must go above that code.
pawn Код:
stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
else GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
return a;
}
Then your code:
pawn Код:
GetPlayerPos(playerid, x, y, z);//This is important
GetXYInFrontOfPlayer(playerid,x,y,1.0);//Make sure this goes below GetPlayerPos (just so it overwrites X and Y because we'll be using Z)
Object[playerid] = CreateObject(1525, x, y, z + 0.2, 0.0, 0.0, a + 90);
Well it would create the object infront of the player.
Re: Quick help -
Joshb93 - 22.12.2011
Can i troll here Oh? Thanks
Re: Quick help - XFlawless - 22.12.2011
Use SA-MP Default Function
GetPlayerCameraFrontVector..