PDA

View Full Version : warning 202: number of arguments does not match definition


TomRedlake
08/08/2013, 02:40 PM
Hello all I have problem.
When i compile my script i got this:

warning 202: number of arguments does not match definition

Here is line:

public RandomZombie() return EvenTeams();

Konstantinos
08/08/2013, 02:52 PM
Does EvenTeams have no parameters?

TomRedlake
09/08/2013, 09:37 AM
Here is EvenTeams its stock.
stock EvenTeams(playerid)
{
new Humans, Zombies, rand = random(2);
if(rand == 0) // Setting ID 0 to Human and continuing with the cycle
{
foreach(Player, i)
{
if(Humans == Zombies)
{
HumanSetup2(i);
Humans ++;
}
else
{
ZombieSetup2(playerid);
Zombies ++;
}
}
}
else // Setting ID 0 to Zombie and continuing with the cycle
{
foreach(Player, i)
{
if(Humans == Zombies)
{
ZombieSetup2(i);
Zombies ++;
}
else
{
HumanSetup2(i);
Humans ++;
}
}
}
return 1;
}

Konstantinos
09/08/2013, 09:47 AM
EvenTeams function has playerid as a parameters, but you do not use the parameter at all here:


public RandomZombie() return EvenTeams();


You need to pass a player's ID.

What do you want to do with the above code?

TomRedlake
09/08/2013, 09:51 AM
just fix warning

Iron3man
09/08/2013, 09:52 AM
just replace the line with this
public RandomZombie() return EvenTeams(playerid);

Konstantinos
09/08/2013, 09:53 AM
I cannot just fix the warning like that, if I do not know what you want to do with it.

Okay, I can stop the compiler from giving you the warning by adding a random playerid, but that's not the point and it's a really bad idea.

May you tell us what RandomZombie is and when do you use EvenTeams?

just replace the line with this
public RandomZombie() return EvenTeams(playerid);

playerid is not defined..

TomRedlake
09/08/2013, 10:02 AM
@Iron3Man now i got error that playerid is not defined.

@Konstantinos

Here is code:
forward RandomZombie();
OnMapStart function
SetTimer("RandomZombie",5000,false);

Konstantinos
09/08/2013, 10:11 AM
Where do you use OnMapStart function? Let me explain you. EvenTeams needs a player's id in order to work.

If OnMapStart uses a player's id, then you need to assign it to the timer. For example, it would be:

SetTimerEx("RandomZombie",5000,false, "i", playerid); // an example

// somewhere else
public RandomZombie(playerid) return EvenTeams(playerid);

That would work, if OnMapStart uses player's ID.

On the other hand, if this function is in OnGameModeInit for example or somewhere else, you will need to use a random ID.

But..

if you don't want this line:

ZombieSetup2(playerid);


Then it can be used like:

stock EvenTeams()
{
new Humans, Zombies, rand = random(2);
if(rand == 0) // Setting ID 0 to Human and continuing with the cycle
{
foreach(Player, i)
{
if(Humans == Zombies)
{
HumanSetup2(i);
Humans ++;
}
}
}
else // Setting ID 0 to Zombie and continuing with the cycle
{
foreach(Player, i)
{
if(Humans == Zombies)
{
ZombieSetup2(i);
Zombies ++;
}
else
{
HumanSetup2(i);
Humans ++;
}
}
}
return 1;
}

// Somewhere else
public RandomZombie() return EvenTeams();

It's up to you.

TomRedlake
09/08/2013, 10:20 AM
thank you for help :)