SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)

 Face9000 26/03/2017 10:50 PM

CreateDynamicMapIcon

I have this coordinates:

pawn Code:
`new Float: WepShop[MAX_WEP_SHOPS][e_shops] = {{-85.2422, -1165.0312, 2.6328},{-90.1406, -1176.6250, 2.6328},{-92.1016, -1161.7891, 2.9609},{1941.6562, -1778.4531, 14.1406}        {2645.2500, 1111.7500, 11.2500}};`

I wanna use CreateDynamicMapIcon to create a map icon on all this coordinates without repeating code. How?

 Dayrion 26/03/2017 11:01 PM

Re: CreateDynamicMapIcon

You can use a loop for that.

 Face9000 26/03/2017 11:16 PM

Re: CreateDynamicMapIcon

Care to explain?

 GoldenLion 27/03/2017 05:40 AM

Re: CreateDynamicMapIcon

Loop through all the elements of the array like this:
Code:

```for (new i; i < sizeof(WepShop); i++) {     //get the coordinates using WepShop[i][the thing from the enumerator here] }```

 Face9000 28/03/2017 07:43 PM

Re: CreateDynamicMapIcon

Can you show me an example on how to use that loop?

 jasperschellekens 28/03/2017 09:26 PM

Re: CreateDynamicMapIcon

Whats the point of it?
What will be different from 5 lines with coords and 5 lines with coords + CreateDynamicMapIcon?
I mean... Why?

Edit:

Try this:
PHP Code:

``` for (new i; i < sizeof(WepShop); i++) {     new Float:X, Float:Y, Float:Z;     CreateDynamicMapIcon(X, Y, Z,-1,-1,-1,-1,300); }  ```

 jlalt 29/03/2017 08:18 AM

Re: CreateDynamicMapIcon

Well, when you do what you've did above you are actually inserting your data inside an enum variables.

so for example if you got:

PHP Code:

``` enum e_shops{    Float:MapX,    Float:MapY,    Float:MapZ,};  ```
and then you insert the data into them like that:
PHP Code:

``` new Float: WepShop[][e_shops] ={    {-85.2422, -1165.0312, 2.6328},    {-90.1406, -1176.6250, 2.6328},    {-92.1016, -1161.7891, 2.9609},    {1941.6562, -1778.4531, 14.1406},    {2645.2500, 1111.7500, 11.2500}};  ```
you would be able to loop by the size of WepShop, and use MapX, MapY, MapZ, to get the coords example:
PHP Code:

``` for(new i = 0; i < sizeof WepShop; i++){    printf("%f | %f | %f",WepShop[i][MapX],WepShop[i][MapY],WepShop[i][MapZ]);}  ```
Result you would get:
PHP Code:

``` -85.242202 | -1165.031250 | 2.632800-90.140602 | -1176.625000 | 2.632800-92.101600 | -1161.789062 | 2.9609001941.656250 | -1778.453125 | 14.1406002645.250000 | 1111.750000 | 11.250000  ```

 All times are GMT. The time now is 03:05 AM.