Help! + rep!
#1

Hello everyone!

Can someone explain me how can I make that specific ussername can use commands before he's logged in.

I have set that you can't type when you aren't logged in at onplayertext

I made a stock like this

Код:
stock test(playerid)
{
	new pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, sizeof(pName));
	if(!strcmp(pName,"Test_Test",false)) return 0;
}
and added this @ onplayertext

Код:
if(!PlayerLogged(playerid) || test(playerid))
But it's not working
Reply
#2

Show your full OnPlayerText.

But, try this:
pawn Код:
if(!PlayerLogged(playerid) || !test(playerid)) return SendClientMessage(playerid, -1, "You are not logged in.!");
Reply
#3

because stock test always return 0 =.=

Try this:
pawn Код:
stock test(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(strcmp(pName,"Test_Test",false) == 0) return 1;
    return 0;
}
Reply
#4

Nope, this is not working, it still shows me that im not logged in
Reply
#5

You said commands, but OnPlayerText is for when you chat, not perform a command.

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(!PlayerLogged(playerid) && test(playerid)) // && means AND, || means or
    {
        //code
        return 1;
    }
    return 0;
}
Reply
#6

Nope, I'm just using onplayertext to make my life easier.

Код:
	public OnPlayerText(playerid, text[])
	{
		if(!PlayerLogged(playerid) || !test(playerid))
		{
			SCM(playerid, COLOR_GREY, "You're not logged in.");
			return 0;
		}
So basically I want to make that my specific name can enter text even if he's not logged in
Reply
#7

As I said above, "||" means OR, and "&&" means AND, so use &&.

pawn Код:
if(!PlayerLogged(playerid) && test(playerid))
And fix your stock, it's always returning 0, as someone else stated above.
Reply
#8

I think this will work:
pawn Код:
stock test(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(!strcmp(pName,"Test_Test",false)) return 1;
        return 0;
}
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(PlayerLogged(playerid) || test(playerid))
    {
        //code
        return 1;
    }
    return 0;
}
Reply
#9

Quote:
Originally Posted by RenovanZ
Посмотреть сообщение
I think this will work:
pawn Код:
stock test(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(!strcmp(pName,"Test_Test",false)) return 1;
        return 0;
}
pawn Код:
public OnPlayerText(playerid, text[])
{
    if(PlayerLogged(playerid) || test(playerid))
    {
        //code
        return 1;
    }
    return 0;
}
No, it won't. He wants it so that if the players name is "Test_test", that he can use commands even when he's not logged in.

pawn Код:
if(PlayerLogged(playerid) || test(playerid))
Is saying, if the player is logged in, OR if he's name is Test_test, he can use commands.

He wants, if the player is NOT logged in, AND the player's name is Test_test, he can use commands, which is:
pawn Код:
if(!PlayerLogged(playerid) && test(playerid))
|| OR
&& AND


*facepalm*
Reply
#10

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
No, it won't. He wants it so that if the players name is "Test_test", that he can use commands even when he's not logged in.

pawn Код:
if(PlayerLogged(playerid) || test(playerid))
Is saying, if the player is logged in, OR if he's name is Test_test, he can use commands.

He wants, if the player is NOT logged in, AND the player's name is Test_test, he can use commands, which is:
pawn Код:
if(!PlayerLogged(playerid) && test(playerid))
|| OR
&& AND


*facepalm*
Take a look on his post, he wants everyone except Test_test to logged in before he can chat.
Which mean:
Test_Test doesnt need logged in to chat.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)