13.07.2015, 12:37
Quote:
I have a balloon system by the balloon spawns at different location,can anyone help to change the balloon spawn location to the player location:
[code...] |
Here's how it should look like:
PHP код:
new
pBalloonObj[MAX_PLAYERS][3] // 0 - Balloon, 1 - Fire1, 2 - Fire2
;
CMD:balloon(playerid,params[])
{
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
if (PlayerIn[playerid][BalloonPlayer])
{
if (IsValidObject(pBalloonObj[playerid][0]))
{
DestroyObject(pBalloonObj[playerid][0]);
DestroyObject(pBalloonObj[playerid][1]);
DestroyObject(pBalloonObj[playerid][2]);
}
PlayerIn[playerid][BalloonPlayer] = 0;
}
// Spawn the balloon 2.0 m further away in the direction the player is looking at
x += 2.0 * floatsin(-a, degrees);
y += 2.0 * floatcos(-a, degrees);
pBalloonObj[playerid][0] = CreateObject(19335, x, y, z, 0.0, 0.0, 0.0);
pBalloonObj[playerid][1] = CreateObject(18692, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
pBalloonObj[playerid][2] = CreateObject(18692, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToObject(pBalloonObj[playerid][1], Balloon, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 1);
AttachObjectToObject(pBalloonObj[playerid][2], Balloon, 0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 1);
SendClientMessage(playerid,GREEN,"Enter the following keys to control the hot air balloon");
SendClientMessage(playerid,GREEN,"Alt+Y (Move Balloon Up)");
SendClientMessage(playerid,GREEN,"Alt+N (Move Balloon Down)");
SendClientMessage(playerid,GREEN,"F+Y (Move Balloon Forward)");
SendClientMessage(playerid,GREEN,"F+N (Move Balloon Back)");
SendClientMessage(playerid,GREEN,"C+Y (Move Balloon Right)");
SendClientMessage(playerid,GREEN,"C+N (Move Balloon Left)");
PlayerIn[playerid][BalloonPlayer] = 1;
return 1;
}