SA-MP Forums Archive
Dynamic textlabel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Dynamic textlabel (/showthread.php?tid=660301)



Dynamic textlabel - KinderClans - 30.10.2018

I want to make a loop through this coordinates and create a textlabel for every of them. (With same text ofc).

pawn Код:
static const Float:FishingPoints[][] =
{
    {403.8615, -2088.7983, 7.8359},
    {398.6964, -2088.7981, 7.8359},
    {396.1438, -2088.7981, 7.8359},
    {391.0257, -2088.7983, 7.8359},
    {383.4240, -2088.7983, 7.8359},
    {374.9918, -2088.7983, 7.8359},
    {369.8525, -2088.7981, 7.8359},
    {367.2137, -2088.7954, 7.8359},
    {362.1895, -2088.7983, 7.8359},
    {354.3215, -2088.6377, 7.8359}
};
How to?


Re: Dynamic textlabel - TheToretto - 30.10.2018

There you go:

pawn Код:
#include <a_samp>

enum g_FishingPos
{
    Float:fishX,
    Float:fishY,
    Float:fishZ
}

new const Float:FishingPoints[][g_FishingPos] =
{
    {403.8615, -2088.7983, 7.8359},
    {398.6964, -2088.7981, 7.8359},
    {396.1438, -2088.7981, 7.8359},
    {391.0257, -2088.7983, 7.8359},
    {383.4240, -2088.7983, 7.8359},
    {374.9918, -2088.7983, 7.8359},
    {369.8525, -2088.7981, 7.8359},
    {367.2137, -2088.7954, 7.8359},
    {362.1895, -2088.7983, 7.8359},
    {354.3215, -2088.6377, 7.8359}
};

public OnFilterScriptInit()
{
    for(new i = 0; i < sizeof(FishingPoints); i++)
    {
        Create3DTextLabel("Fishing Point", 0x008080FF, FishingPoints[i][fishX], FishingPoints[i][fishY], FishingPoints[i][fishZ], 40.0, 0, 0);
    }
    return 1;
}



Re: Dynamic textlabel - Riddick94 - 30.10.2018

Don't listen to @TheToretto.

First of all - what you trying to achieve is not going to be dynamic at all. But if I would go for the solution like the user above did, then there's a simpler solution without using enumerator.

pawn Код:
static const Float:FishingPoints[][3] =
{
    {403.8615, -2088.7983, 7.8359},
    {398.6964, -2088.7981, 7.8359},
    {396.1438, -2088.7981, 7.8359},
    {391.0257, -2088.7983, 7.8359},
    {383.4240, -2088.7983, 7.8359},
    {374.9918, -2088.7983, 7.8359},
    {369.8525, -2088.7981, 7.8359},
    {367.2137, -2088.7954, 7.8359},
    {362.1895, -2088.7983, 7.8359},
    {354.3215, -2088.6377, 7.8359}
};

public OnGameModeInit()
{
    for(new i = 0; i != sizeof(FishingPoints); i++)
    {
        Create3DTextLabel("Fishing Point", 0x008080FF, FishingPoints[i][0], FishingPoints[i][1], FishingPoints[i][2], 40.0, 0, 0);
    }
    return 1;
}



Re: Dynamic textlabel - iAmir - 30.10.2018

But what makes u call it dynamic ... ?


Re: Dynamic textlabel - TheToretto - 30.10.2018

It's quite the same, except that I used the enumerator for a better comprehension for anyone reading the code. Even the author.

And what do you mean by "dynamic" ? He just want to make TextLabels on the coordinates he has, it's loaded only one time when the script executes, there's no need to look no further.

Edit:

Quote:
Originally Posted by iAmir
Посмотреть сообщение
But what makes u call it dynamic ... ?
Same question.


Re: Dynamic textlabel - Kane - 30.10.2018

If you want to make it "dynamic" and adjustable in game you should create it as you would, for example, a property system. Load on init, save and et cetera.


Re: Dynamic textlabel - KinderClans - 30.10.2018

Thank you everyone.


Re: Dynamic textlabel - GTLS - 31.10.2018

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
And what do you mean by "dynamic" ? He just want to make TextLabels on the coordinates he has, it's loaded only one time when the script executes, there's no need to look no further.
Its not the definition of Dynamic. OP has topic labled, Dynamic textlabel. His code is simply isnt dynamic. It would be dynamic if the array could be modified without changing code anytime. Using SQL here is a key. You can use file based system if you want to aswell.


Re: Dynamic textlabel - TheToretto - 31.10.2018

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Its not the definition of Dynamic. OP has topic labled, Dynamic textlabel. His code is simply isnt dynamic. It would be dynamic if the array could be modified without changing code anytime. Using SQL here is a key. You can use file based system if you want to aswell.
I didn't say my code was dynamic ^^ And if he's planning to make it daynamik better start by defining variables non-constant values.