[SOLVED] command with else etc.
#1

i just started to script again and i tried to do it bymyself and not to take anything of the internet, but my command is little buggy:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/acp", cmdtext, true, 10) == 0)
	{
		IsPlayerAdmin(playerid);
		{
			ShowMenuForPlayer(AdminMenu,playerid);
			return 1;
		}
	}
	else SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
	return 0;
}
when i remove:
Код:
else SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
i can use it only as admin with it as admin and normal player, how to change it? i want a message so if you are a player and you do /acp i want a message: "you need to be.." wo can help me? srry for bad english xD
Reply
#2

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/acp", cmdtext, true,4) == 0) // '/acp' has 4 characters not 10
	{
		if(IsPlayerAdmin(playerid)); //you fogot an 'if'
		{
			ShowMenuForPlayer(AdminMenu,playerid);
			return 1;
		}
		else SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
	}
	//not here lol
	return 0;
}
Reply
#3

SO Thats how u do it thanks for telling man
Reply
#4

Quote:
Originally Posted by GTAguillaume
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/acp", cmdtext, true,4) == 0) // '/acp' has 4 characters not 10
	{
		if(IsPlayerAdmin(playerid)); //you fogot an 'if'
		{
			ShowMenuForPlayer(AdminMenu,playerid);
			return 1;
		}
		else SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
	}
	//not here lol
	return 0;
}
ty
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/acp", cmdtext, true, 4) == 0) // Don't use 10 when the command text is 4 in total with "/".
    {
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
    else
    ShowMenuForPlayer(AdminMenu,playerid);
    return 1;
    }
/*=======================================================================================================================================*/
    }
    return 0;
}
Reply
#6

both give error ? first post:

Код:
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(47) : error 036: empty statement
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(52) : warning 225: unreachable code
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(52) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.

other:


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/acp", cmdtext, true, 4) == 0) // Don't use 10 when the command text is 4 in total with "/".
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
else
ShowMenuForPlayer(AdminMenu,playerid);
return 1;
}
/*=======================================================================================================================================*/
}
return 0;
}
Reply
#7

Quote:
Originally Posted by security
both give error ? first post:

Код:
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(47) : error 036: empty statement
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(52) : warning 225: unreachable code
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(52) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.

other:

Код:


C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(53) : warning 209: function "OnPlayerCommandText" should return a value
C:\Documents and Settings\Doodaapje\Bureaublad\FS & GM\ADMIN\admin.pwn(54) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
srry for dubble post didnt pressed edit but quote i'm sorry
Reply
#8

Show me line 54 and 53 ..
Reply
#9

Quote:
Originally Posted by GTAguillaume
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/acp", cmdtext, true,4) == 0) // '/acp' has 4 characters not 10
	{
		if(IsPlayerAdmin(playerid)); //you fogot an 'if'
		{
			ShowMenuForPlayer(AdminMenu,playerid);
			return 1;
		}
		else SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
	}
	//not here lol
	return 0;
}
alternative

Код:
if(something == something etc etc){
script
}
else
{
script
}
this can also be used
Код:
else if (something == somethingelse etc etc)
Reply
#10

Quote:
Originally Posted by adsy
Quote:
Originally Posted by GTAguillaume
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/acp", cmdtext, true,4) == 0) // '/acp' has 4 characters not 10
	{
		if(IsPlayerAdmin(playerid)); //you fogot an 'if'
		{
			ShowMenuForPlayer(AdminMenu,playerid);
			return 1;
		}
		else SendClientMessage(playerid, 0xFFFFFFFF, "You need to be admin for this command");
	}
	//not here lol
	return 0;
}
alternative

Код:
if(something == something etc etc){
script
}
else
{
script
}
this can also be used
Код:
else if (something == somethingelse etc etc)
sorry i dont understand?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)