Can't write until logged in -
Xeiss - 17.03.2013
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.
Re: Can't write until logged in -
burnfire - 17.03.2013
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.
Re: Can't write until logged in -
Xeiss - 17.03.2013
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.
Re: Can't write until logged in -
mastermax7777 - 17.03.2013
pawn Код:
if (pInfo[playerid][pLogged] == false)
{
return SendClientMessage(playerid, COLOR_RED, "You must be logged in before writing!");
}
Re: Can't write until logged in -
Xeiss - 17.03.2013
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.
Re: Can't write until logged in - Patrick - 17.03.2013
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
Re: Can't write until logged in -
Xeiss - 17.03.2013
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
Re: Can't write until logged in -
JaKe Elite - 17.03.2013
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.