Retrieving the string from the function is blank.
#1

Ok so basically I've got this working with no errors, however, the direction is blank.

Here's what I'm trying to do:
Код:
[CONTROL]: Vehicle was last seen in Ganton traveling north.
However it looks like:

Код:
[CONTROL]: Vehicle was last seen in Ganton traveling .
Here's segments of the code:
pawn Код:
stock GetDirection(Float:Angle)
{
    new direction[30];
    if(350 < Angle <= 10)
    {
        format(direction, sizeof(direction), "North");
    }
    else if(10 < Angle <= 80)
    {
        format(direction, sizeof(direction), "North-East");
    }
    else if(80 < Angle <= 100)
    {
        format(direction, sizeof(direction), "East");
    }
    else if(100 < Angle <= 170)
    {
        format(direction, sizeof(direction), "South-East");
    }
    else if(170 < Angle <= 190)
    {
        format(direction, sizeof(direction), "South");
    }
    else if(190 < Angle <= 260)
    {
        format(direction, sizeof(direction), "East-West");
    }
    else if(260 < Angle <= 280)
    {
        format(direction, sizeof(direction), "West");
    }
    else if(280 < Angle <= 350)
    {
        format(direction, sizeof(direction), "North-West");
    }
    return direction;
}
new Float:Angle;
GetPlayerFacingAngle(i,Angle);
new zone[MAX_ZONE_NAME];
GetPlayer2DRadarZone(i, zone, sizeof(zone));
format(string, sizeof(string), "{39AACC}[CONTROL]: {FFFFFF}Vehicle was last seen in %s traveling %s.",zone,GetDirection(Angle));
Reply
#2

Try this one
pawn Код:
stock GetDirection(Float:Angle)
{
    new direction[30];
    if(350 < Angle <= 10)
    {
        format(direction, sizeof(direction), "North");
    }
    else if(10 < Angle <= 80)
    {
        format(direction, sizeof(direction), "North-East");
    }
    else if(80 < Angle <= 100)
    {
        format(direction, sizeof(direction), "East");
    }
    else if(100 < Angle <= 170)
    {
        format(direction, sizeof(direction), "South-East");
    }
    else if(170 < Angle <= 190)
    {
        format(direction, sizeof(direction), "South");
    }
    else if(190 < Angle <= 260)
    {
        format(direction, sizeof(direction), "East-West");
    }
    else if(260 < Angle <= 280)
    {
        format(direction, sizeof(direction), "West");
    }
    else if(280 < Angle <= 350)
    {
        format(direction, sizeof(direction), "North-West");
    }
    return direction;
}
new Float:Angle;
GetPlayerFacingAngle(i,Angle);
new zone[MAX_ZONE_NAME];
GetPlayer2DRadarZone(i, zone, sizeof(zone));
format(string, sizeof(string), "{39AACC}[CONTROL]: {FFFFFF}Vehicle was last seen in %s traveling %s.",zone, direction);
Reply
#3

pawn Код:
if(350 < Angle <= 10)
Angle cannot be both greater than 350 and lower than 11 so change to:
pawn Код:
if(350 > Angle <= 10)

And by the way, you can assign the text directly without using format for it.
Reply
#4

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
if(350 > Angle <= 10)

And by the way, you can assign the text directly without using format for it.
That will not work.
Reply
#5

Quote:
Originally Posted by Laurey
Посмотреть сообщение
Try this one
pawn Код:
stock GetDirection(Float:Angle)
{
    new direction[30];
    if(350 < Angle <= 10)
    {
        format(direction, sizeof(direction), "North");
    }
    else if(10 < Angle <= 80)
    {
        format(direction, sizeof(direction), "North-East");
    }
    else if(80 < Angle <= 100)
    {
        format(direction, sizeof(direction), "East");
    }
    else if(100 < Angle <= 170)
    {
        format(direction, sizeof(direction), "South-East");
    }
    else if(170 < Angle <= 190)
    {
        format(direction, sizeof(direction), "South");
    }
    else if(190 < Angle <= 260)
    {
        format(direction, sizeof(direction), "East-West");
    }
    else if(260 < Angle <= 280)
    {
        format(direction, sizeof(direction), "West");
    }
    else if(280 < Angle <= 350)
    {
        format(direction, sizeof(direction), "North-West");
    }
    return direction;
}
new Float:Angle;
GetPlayerFacingAngle(i,Angle);
new zone[MAX_ZONE_NAME];
GetPlayer2DRadarZone(i, zone, sizeof(zone));
format(string, sizeof(string), "{39AACC}[CONTROL]: {FFFFFF}Vehicle was last seen in %s traveling %s.",zone, direction);
It's returning strings but not the right ones lol. Is their a more efficient accurate way to do this? I'm confused. I figured GetPlayerFacingAngle would be accurate since the driver is facing the same way as the vehicle.
Reply
#6

pawn Код:
stock GetDirection(Float:Angle)
{
    new direction[12];
    if(Angle >= 350.0 || Angle <= 10.0) direction = "North";
    else if(Angle <= 80.0) direction = "North-West";
    else if(Angle <= 100.0) direction = "West";
    else if(Angle <= 170.0) direction = "South-West";
    else if(Angle <= 190.0) direction = "South";
    else if(Angle <= 260.0) direction = "South-East";
    else if(Angle <= 280.0) direction = "East";
    else if(Angle <= 350.0) direction = "North-East";
    return direction;
}
Meh. Good enough.

EDIT: No, that bracket wasn't meant to be there.
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
if(350 < Angle <= 10)
Angle cannot be both greater than 350 and lower than 11 so change to:
pawn Код:
if(350 > Angle <= 10)

And by the way, you can assign the text directly without using format for it.
Oh i just saw this before my last post. we posted nearly the same time.
Let me give this a shot.
Reply
#8

Half of it works, if the angle is greater than 351.0 will not work (I tested only with values higher than 0.0 only). You can use Threshold's code.
Reply
#9

Quote:
Originally Posted by Threshold
Посмотреть сообщение
pawn Код:
stock GetDirection(Float:Angle)
{
    new direction[12];
    if(Angle >= 350.0 || Angle <= 10.0) direction = "North";
    else if(Angle <= 80.0) direction = "North-West";
    else if(Angle <= 100.0) direction = "West";
    else if(Angle <= 170.0) direction = "South-West";
    else if(Angle <= 190.0) direction = "South";
    else if(Angle <= 260.0) direction = "South-East";
    else if(Angle <= 280.0) direction = "East";
    else if(Angle <= 350.0) direction = "North-East";}
    return direction;
}
Meh. Good enough.
Not sure if the second bracket at the end is necessary?
Just wanted to check. lol
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Half of it works, if the angle is greater than 351.0 will not work (I tested only with values higher than 0.0 only). You can use Threshold's code.
I tried his out, no matter what direction i'm facing or driving, it says I'm going north.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)