CMD:balloon(playerid,params[])
{
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);
DestroyObject(Balloon);
DestroyObject(Fire);
DestroyObject(Fire1);
PlayerIn[playerid][BalloonPlayer] = 0;
Balloon = CreateObject(19335, 836.08, -2000.51, 13.60, 0.00, 0.00, 0.00);
Fire = CreateObject(18692, 0,0,0, 0.00, 0.00, 0.00);
Fire1 = CreateObject(18692, 0,0,0, 0.00, 0.00, 0.00);
AttachObjectToObject(Fire, Balloon, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 1);
AttachObjectToObject(Fire1, 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;
}
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...] |
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;
}
Balloon = CreateObject(19335, 836.08, -2000.51, 13.60, 0.00, 0.00, 0.00);
new Float:x, Float:y, Float:z, Float:a;
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
x += (2 * floatsin(-a, degrees));
y += (2 * floatcos(-a, degrees));
Rocket[playerid] = CreateDynamicObject(19335, x, y, z, 0, 90, 0);
Balloon = CreateDynamicObject(18716, x, y, z - 4, 0, 0, 0);
Yeah, sure, but keep in mind that the current system you have would only spawn 1 balloon at a time, and if another player spawns a balloon (by typing the command) and you just happen to be flying in one, it would get destroyed and you will drop.
Here's how it should look like: PHP код:
|
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerIn[i][BalloonPlayer] == 1)
{
new Float:X,Float:Y,Float:Z;
GetObjectPos(Balloon,X,Y,Z);
if(PRESSED(KEY_YES | KEY_WALK)) { TimerUP = SetTimer("MoveBalloonUp",30,1); }
if(RELEASED(KEY_YES | KEY_WALK)) { KillTimer(TimerUP); }
if(PRESSED(KEY_NO | KEY_WALK)) { TimerDown = SetTimer("MoveBalloonDown",30,1); }
if(RELEASED(KEY_NO | KEY_WALK)) { KillTimer(TimerDown); }
if(PRESSED(KEY_SECONDARY_ATTACK | KEY_YES)) { TimerForward = SetTimer("MoveBalloonForward",30,1); }
if(RELEASED(KEY_SECONDARY_ATTACK | KEY_YES)) { KillTimer(TimerForward); }
if(PRESSED(KEY_SECONDARY_ATTACK | KEY_NO)) { TimerBack = SetTimer("MoveBalloonBack",30,1); }
if(RELEASED(KEY_SECONDARY_ATTACK | KEY_NO)) { KillTimer(TimerBack); }
if(PRESSED(KEY_CROUCH | KEY_YES)) { TimerRight = SetTimer("MoveBalloonRight",30,1); }
if(RELEASED(KEY_CROUCH | KEY_YES)) { KillTimer(TimerRight); }
if(PRESSED(KEY_CROUCH | KEY_NO)) { TimerLeft = SetTimer("MoveBalloonLeft",30,1); }
if(RELEASED(KEY_CROUCH | KEY_NO)) { KillTimer(TimerLeft); }
}
}
but the balloon does not move when i press keys:
PHP код:
|