Little Help +Rep
#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:

PHP код:
CMD:balloon(playerid,params[])
{
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playeridxyz);
    
DestroyObject(Balloon);
    
DestroyObject(Fire);
    
DestroyObject(Fire1);
    
PlayerIn[playerid][BalloonPlayer] = 0;
    
Balloon CreateObject(19335836.08, -2000.5113.60,   0.000.000.00);
    
Fire CreateObject(186920,0,0,   0.000.000.00);
    
Fire1 CreateObject(186920,0,0,   0.000.000.00);
    
AttachObjectToObject(FireBalloon0.00.02.00.00.00.01);
    
AttachObjectToObject(Fire1Balloon0.00.04.00.00.00.01);
    
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;

Reply
#2

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
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...]
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 код:
new
    
pBalloonObj[MAX_PLAYERS][3// 0 - Balloon, 1 - Fire1, 2 - Fire2
;
CMD:balloon(playerid,params[])
{
    new 
Float:xFloat:yFloat:zFloat:a;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playerida);
    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
    
+= 2.0 floatsin(-adegrees);
    
+= 2.0 floatcos(-adegrees);
    
pBalloonObj[playerid][0] = CreateObject(19335xyz0.00.00.0);
    
pBalloonObj[playerid][1] = CreateObject(186920.00.00.00.00.00.0);
    
pBalloonObj[playerid][2] = CreateObject(186920.00.00.00.00.00.0);
    
AttachObjectToObject(pBalloonObj[playerid][1], Balloon0.00.02.00.00.00.01);
    
AttachObjectToObject(pBalloonObj[playerid][2], Balloon0.00.04.00.00.00.01);
    
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;

Edit: Made minor changes.
Reply
#3

Oops Imma DUMB (Removed as it was incorrect code)
Reply
#4

You just need to edit this line
PHP код:
Balloon CreateObject(19335836.08, -2000.5113.60,   0.000.000.00); 
try to take some help from here:
PHP код:
new Float:xFloat:yFloat:zFloat:a;
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playerida);
        
        
+= (floatsin(-adegrees));
            
+= (floatcos(-adegrees));
        
Rocket[playerid] = CreateDynamicObject(19335xyz0900);
        
      
Balloon CreateDynamicObject(18716xy4000); 
Reply
#5

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
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 код:
new
    
pBaloonObj[MAX_PLAYERS][3// 0 - Baloon, 1 - Fire1, 2 - Fire2
;
CMD:balloon(playerid,params[])
{
    new 
Float:xFloat:yFloat:zFloat:a;
    
GetPlayerPos(playeridxyz);
    
GetPlayerFacingAngle(playerida);
    if (
PlayerIn[playerid][BalloonPlayer])
    {
        if (
IsValidObject(pBaloonObj[playerid][0]))
        {
            
DestroyObject(pBaloonObj[playerid][0]);
            
DestroyObject(pBaloonObj[playerid][1]);
            
DestroyObject(pBaloonObj[playerid][2]);
        }
        
PlayerIn[playerid][BalloonPlayer] = 0;
    }
    
// Spawn the balloon 2.0 m further away in the direction the player is looking at
    
+= 2.0 floatsin(-adegrees);
    
+= 2.0 floatcos(-adegrees);
    
pBaloonObj[playerid][0] = CreateObject(19335xyz0.00.00.0);
    
pBaloonObj[playerid][1] = CreateObject(186920.00,00.00.00.0);
    
pBaloonObj[playerid][2] = CreateObject(186920.00,00.00.00.0);
    
AttachObjectToObject(pBaloonObj[playerid][1], Balloon0.00.02.00.00.00.01);
    
AttachObjectToObject(pBaloonObj[playerid][2], Balloon0.00.04.00.00.00.01);
    
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;

+Rep
Reply
#6

but the balloon does not move when i press keys:

PHP код:
    for(new 0MAX_PLAYERSi++)
    {
    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); }
    }
    } 
Reply
#7

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
but the balloon does not move when i press keys:

PHP код:
    for(new 0MAX_PLAYERSi++)
    {
    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); }
    }
    } 
Did you tried mine one?
Reply
#8

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
but the balloon does not move when i press keys:
Code...
Yes, well, that is due to your coding. Try to code it this way: when a player types the /balloon command set a repeating timer for the player with interval of lets say 500ms.
Then, in the timer callback check for keypresses and use MoveObject accordingly. Don't waste server resources by creating many 30ms timers in such short intervals!
Reply
#9

Now i fixed it by myself by my own way
Reply
#10

Quote:
Originally Posted by Mouiz
Посмотреть сообщение
Now i fixed it by myself by my own way
Congradz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)