SA-MP Forums Archive
[Help]4 errors on 1 line - 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]4 errors on 1 line (/showthread.php?tid=434777)



[Help]4 errors on 1 line - luis_mendoza - 04.05.2013

So i have made something with random teams, but idk why it dont work.

Код:
D:\samp\gamemodes\z.pwn(704) : error 028: invalid subscript (not an array or too many subscripts): "rand"
D:\samp\gamemodes\z.pwn(704) : warning 215: expression has no effect
D:\samp\gamemodes\z.pwn(704) : error 001: expected token: ";", but found "]"
D:\samp\gamemodes\z.pwn(704) : error 029: invalid expression, assumed zero
D:\samp\gamemodes\z.pwn(704) : fatal error 107: too many error messages on one line
Код:
new RandomTeams[][] =
{
    {TEAM_ZOMBIE},
    {TEAM_HUMAN}
};

new rand = random(sizeof(RandomTeams));
	

SetPlayerTeam(playerid, rand[rand][0]); // 704 line



Re: [Help]4 errors on 1 line - Yashas - 04.05.2013

rand is not an array.

Your code was supposed to be

SetPlayerTeam(playerid, RandomTeams[rand][0]); // 704 line

Even this might cause an error.Tell what are those TEAM defines.


Re: [Help]4 errors on 1 line - luis_mendoza - 04.05.2013

Thank you , I made like that some times I think , and it wont work.

But this is like a miracle , it works now.


Re: [Help]4 errors on 1 line - Yashas - 04.05.2013

Quote:
Originally Posted by luis_mendoza
Посмотреть сообщение
Thank you , I made like that some times I think , and it wont work.

But this is like a miracle , it works now.
Its impossible to work.Please check your code!You might have fixed the error but you will face runtime errors, this is 100%.Because rand may go out of context!! as it is the sizeof the whole array.

Change your random(sizeof(RandomTeams)) to random(MAX_TEAMS); OR random((sizeof(RandomTeams)/sizeof(TEAM_MAX)) OR just do random(2);


Re: [Help]4 errors on 1 line - luis_mendoza - 04.05.2013

@Yashas , I can get it how to make that 2 things what u said.

But I can't get that how to do with random(2); .


Re: [Help]4 errors on 1 line - Yashas - 04.05.2013

random(2) because you have 2 teams in your array you change it as you add more.I just directly gave the value.Its same as random(MAX_TEAMS) but instead of defining the value I gave directly.


Re: [Help]4 errors on 1 line - luis_mendoza - 04.05.2013

This random apsolutelly , don't work , and I used all of that.


Re: [Help]4 errors on 1 line - Yashas - 04.05.2013

What??Tell clearly.What happens??
And show your defines.


Re: [Help]4 errors on 1 line - luis_mendoza - 04.05.2013

Код:
#define MAX_TEAMS 2
and at onplayerspawn

Код:
new rand = random(MAX_TEAMS);
SetPlayerTeam(playerid, RandomTeams[rand][0]);



Re: [Help]4 errors on 1 line - Yashas - 04.05.2013

It should work.
If it doesn't then there's a problem with your array, just show you other defines.