Can't write until logged in
#1

Hi
I'm trying to create a code that won't allow the player to write text or commands until he is logged in, but it doesn't seem to work so well.
I'd really appreciate it if someone could help me
Код:
public OnPlayerText(playerid, text[])
{
	if (pInfo[playerid][pLogged] == false)
	{
		SendClientMessage(playerid, COLOR_RED, "You must be logged in before writing!");
		return 0;
 	}
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (pInfo[playerid][pLogged] == false)
    {
	SendClientMessage(playerid, COLOR_RED, "You must be logged in before writing!");
	return 1;
     }
	return 0;
}
I use YCMD for the commands, that's why they aren't in the "OnPlayerCommandText" public.

Thank you.
Reply
#2

Hmmmm...A method it's to return at OnPlayerText 0,because,if you return "1" will appear the "original" text(the SA:MP team default text).If you return "0" will appear your message.
Reply
#3

Quote:
Originally Posted by burnfire
Посмотреть сообщение
Hmmmm...A method it's to return at OnPlayerText 0,because,if you return "1" will appear the "original" text(the SA:MP team default text).If you return "0" will appear your message.
Thank you, now players can't write text before logging in, but they CAN write commands. Do you have any suggestion on how I can disable commands as well? I use YCMD.
Reply
#4

pawn Код:
if (pInfo[playerid][pLogged] == false)
{
    return SendClientMessage(playerid, COLOR_RED, "You must be logged in before writing!");
}
Reply
#5

Quote:
Originally Posted by mastermax7777
Посмотреть сообщение
pawn Код:
if (pInfo[playerid][pLogged] == false)
{
    return SendClientMessage(playerid, COLOR_RED, "You must be logged in before writing!");
}
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (pInfo[playerid][pLogged] == false) return SendClientMessage(playerid, COLOR_RED, "You must be logged in before writing!");
	return 1;
}
Still not working.
Reply
#6

can you show us how you set you're variable if player is login. there is should something look like this
pawn Код:
//if player logged in
pInfo[playerid][pLogged] =1; //or you can use true
//if player is not logged in
pInfo[playerid][pLogged] =0; //or you can use false
because those code above are correct. so probably you got something wrong when you're setting it to 1 or 0
Reply
#7

Quote:
Originally Posted by pds2012
Посмотреть сообщение
can you show us how you set you're variable if player is login. there is should something look like this
pawn Код:
//if player logged in
pInfo[playerid][pLogged] =1; //or you can use true
//if player is not logged in
pInfo[playerid][pLogged] =0; //or you can use false
because those code above are correct. so probably you got something wrong when you're setting it to 1 or 0
It works with "OnPlayerText", but doesn't work with "OnPlayerCommandText".
All I did is just, when the player connects, pInfo[playerid][pLogged] = false and when the player login (after the login dialog), pInfo[playerid][pLogged] = true. That's it pretty much
Reply
#8

Instead of checking their var.

Check their getplayerstate. If all of playerstate id is not the result in GetPlayerState.
Then it means he/she still in class selection.

pawn Код:
if(GetPlayerState(playerid) != 1 && GetPlayerState(playerid) != 2 && GetPlayerState(playerid) != 3)
return //do whatever you want.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)