A problem
#1

Can someone tell me why this code doesn't show the SpawnpointTD even if i'm at the spawnpoint?

pawn Code:
for(new j; j < MAX_RANDOM_SPAWNS; j++)
{
    if(IsPlayerInRangeOfPoint(i, 3, RandomSpawn[j][0], RandomSpawn[j][1], RandomSpawn[j][2]) && Player[i][PlayerSpawned] == true)
    {
        PlayerTextDrawShow(i, SpawnpointTD[i]);
    }
    else
    {
        PlayerTextDrawHide(i, SpawnpointTD[i]);
    }
}
RandomSpawn:

pawn Code:
static const Float:RandomSpawn[][4] =
{
    {1320.7914,1262.0884,10.8203,357.0813},
    {408.3192,2452.5623,16.5000,5.9386},
    {-1321.2762,-219.7926,14.1484,12.5747 },
    {1910.8484,-2419.6887,13.5391,182.4597},
    {-2310.8376,-1616.5333,483.8190,176.1664},
    {-2416.7188,332.4720,34.9688,240.4801},
}
I tried with a simple SendClientMessage and it says i'm not at the spawnpoint, even if i spawn at RandomSpawn coordinates.
Reply
#2

What your loop does is repeatedly show and hide it for every spawn point.

Assume you're at Spawn Point ID 2, the loop will hide the TD for ID 0 and 1, then show it for 2 and then hide it again at 3, 4 and 5. So in the end it will still be hidden. Theoretically only the last one works at the moment.

What you need to do is stop the loop when a Spawn Point was found, and only hide it if none of the Spawn Points are near the player (so after the loop finished).
You can use a variable declared before the loop to keep track of which one was found, and if one was found at all, then act accordingly.

Sorry for the earlier replies, I mistook i for j in the TD code.
Reply
#3

use break;
Reply
#4

Any example?
Reply
#5

Code:
for(new j; j < MAX_RANDOM_SPAWNS; j++)
{
    if(IsPlayerInRangeOfPoint(i, 3, RandomSpawn[j][0], RandomSpawn[j][1], RandomSpawn[j][2]) && Player[i][PlayerSpawned] == true)
    {
        PlayerTextDrawShow(i, SpawnpointTD[i]);
        break;
    }
    else
    {
        PlayerTextDrawHide(i, SpawnpointTD[i]);
        break;
    }
}
Reply
#6

Thanks but doesn't work.



As you can see, i'm at a random spawnpoint (random spawn), and the textdraw is supposed to show above the radar, but nothing.

This is the textdraw code:

pawn Code:
SpawnpointTD[playerid] = CreatePlayerTextDraw(playerid, 28.000000, 305.000000, "You're near a ~s~spawnpoint~w~!~n~~r~Spawnkill ~w~is ~r~forbidden ~w~here!");
    PlayerTextDrawBackgroundColor(playerid, SpawnpointTD[playerid], 255);
    PlayerTextDrawFont(playerid, SpawnpointTD[playerid], 2);
    PlayerTextDrawLetterSize(playerid, SpawnpointTD[playerid], 0.140000, 1.100000);
    PlayerTextDrawColor(playerid, SpawnpointTD[playerid], -1);
    PlayerTextDrawSetOutline(playerid, SpawnpointTD[playerid], 1);
    PlayerTextDrawSetProportional(playerid, SpawnpointTD[playerid], 1);
    PlayerTextDrawSetSelectable(playerid, SpawnpointTD[playerid], 0);
Reply
#7

Quote:
Originally Posted by Kasichok
View Post
Code:
for(new j; j < MAX_RANDOM_SPAWNS; j++)
{
    if(IsPlayerInRangeOfPoint(i, 3, RandomSpawn[j][0], RandomSpawn[j][1], RandomSpawn[j][2]) && Player[i][PlayerSpawned] == true)
    {
        PlayerTextDrawShow(i, SpawnpointTD[i]);
        break;
    }
    else
    {
        PlayerTextDrawHide(i, SpawnpointTD[i]);
        break;
    }
}
You only need a break when a Spawn Point was found. Otherwise this loop will always stop after the first iteration...
Reply
#8

Switch to areas.
Reply
#9

Nas thank you, i removed the second break and it works, thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)