SA-MP Forums Archive
[HELP]Index array - 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: [HELP]Index array (/showthread.php?tid=462052)



[HELP]Index array - XxXBr0nXxX - 04.09.2013

Hi guys, I need some help.
I did this code: http://pastebin.com/pvdAAE0N
But the compiler tells me that I should index the arrays. How can I fix? Thanks.


Re: [HELP]Index array - Borg - 05.09.2013

pawn Код:
new
    MVP[MAX_PLAYERS],
    WP[MAX_PLAYERS];
pawn Код:
MVP = i;
WP = i;



Re: [HELP]Index array - dusk - 05.09.2013

You need to tell which element of an array you are using...
For example:
pawn Код:
new array[2];
array[0] = 5;



Re: [HELP]Index array - XxXBr0nXxX - 06.09.2013

Borg you answer didn't help too much, because is like the actual code. Dusk, I didn't understand, so I UP the topic. ktm


Re: [HELP]Index array - SuperViper - 06.09.2013

You're declaring the array MVP with 500 indexes but you aren't specifying which index you want to set.

Incorrect:

pawn Код:
new MVP[MAX_PLAYERS];
MVP = 1;
Correct:

pawn Код:
new MVP[MAX_PLAYERS];
MVP[0] = 1;
Replace 0 with the ID of a player to get the result you want.


Re: [HELP]Index array - XxXBr0nXxX - 06.09.2013

Thanks so much, that compiled the GM, but I still have a problem: my message won't send only 1 time, but it will flood and it will send over 15 messages! How can I fix this?


Re: [HELP]Index array - SuperViper - 07.09.2013

Send the message to i rather than to all.


Re: [HELP]Index array - XxXBr0nXxX - 07.09.2013

Already tried, it didn't work.


Re: [HELP]Index array - eemalekorraks - 07.09.2013

Try putting the SendClientMessage outside of the FOR LOOP.


Re: [HELP]Index array - Konstantinos - 07.09.2013

What SuperViper said. If MAX_PLAYERS is 50 (an example), it will send 50 times the message to all players.

Use:
pawn Код:
SendClientMessage(i, -1, stringa);
instead.


Re: [HELP]Index array - XxXBr0nXxX - 07.09.2013

Thanks everybody, exspecially to eemalekorraks and SuperViper who solved the problem. Rep ++!