[Help]4 errors on 1 line
#1

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
Reply
#2

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.
Reply
#3

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

But this is like a miracle , it works now.
Reply
#4

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);
Reply
#5

@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); .
Reply
#6

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.
Reply
#7

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

What??Tell clearly.What happens??
And show your defines.
Reply
#9

Код:
#define MAX_TEAMS 2
and at onplayerspawn

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)