Pls help me with this error
#1

new countpolicemen=0;
for (new d=0;d<MAX_PLAYERS;d++)if(IsPlayerConnected(d) && PlayerInfo[d][pfaction]==FACTION_POLICE)countpolicemen++; ***
if(countpolicemen<3)return SendClientMessage(playerid,COLOR_NO,"You need 3 cops online in orther to do a robbery.");


ERROR TYPE: : error 001: expected token: ")", but found "-identifier-"
ERROR LINE (THAT ONE WITH AT THE END ***)

Please help me..
Reply
#2

Код:
for(new d = 0; d < MAX_PLAYERS; d++) if(IsPlayerConnected(d)) && PlayerInfo[d][pfaction] == FACTION_POLICE) countpolicemen++;
if(countpolicemen < 3) return SendClientMessage(playerid, COLOR_NO, "You need 3 cops online in orther to do a robbery.");
Reply
#3

Quote:
Originally Posted by sampkinq
Посмотреть сообщение
Код:
for(new d = 0; d < MAX_PLAYERS; d++) if(IsPlayerConnected(d)) && PlayerInfo[d][pfaction] == FACTION_POLICE) countpolicemen++;
if(countpolicemen < 3) return SendClientMessage(playerid, COLOR_NO, "You need 3 cops online in orther to do a robbery.");
At the same line, now there are two errors.
error 029: invalid expression, assumed zero
error 001: expected token: ";", but found "-identifier-"
Reply
#4

You need brackes like

for() {

}
also for the if...
Reply
#5

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
You need brackes like

for() {

}
also for the if...
I used this script also two years ago. In the same status...... and it worked well
Reply
#6

This is how an if statement should look, notice the brackets.
https://sampwiki.blast.hk/wiki/Control_Structures


Here you can find the for loop and see how it looks, notice the brackets.
https://sampwiki.blast.hk/wiki/Loops

Try adding brackets to your code like
PHP код:
for(arguments){
 if(
condition){
 
 }

Reply
#7

Quote:
Originally Posted by xskyowned
Посмотреть сообщение
At the same line, now there are two errors.
error 029: invalid expression, assumed zero
error 001: expected token: ";", but found "-identifier-"
Код:
for(new d = 0; d < MAX_PLAYERS; d++)
{
	if(IsPlayerConnected(d))
	{
		if(PlayerInfo[d][pfaction] == FACTION_POLICE)
		{
			countpolicemen++;
		}
	}
}
if(countpolicemen < 3) return SendClientMessage(playerid, COLOR_NO, "You need 3 cops online in orther to do a robbery.");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)