Allow only /login (with params!) while player is muted before spawning?
#1

Hello,

I have recently integrated my admin filterscript into my gamemode, in an attempt to make a lot of hybrid admin/non-admin commands. Everything is working pretty well, except for one thing - I have a small piece of code that mutes the player if that player has not spawned yet and prevents him/her from using commands. The aim is to make all commands except for /login throw an error message, but things aren't that easy it seems. Have a look at my code.

On top of the script:
pawn Код:
new MuteSpawn[MAX_PLAYERS];
Under OnPlayerText:
pawn Код:
if(MuteSpawn[playerid] == 1 && AccountInfo[playerid][Register] == 1)
    {
        SendClientMessage(playerid, COLOR_YELLOW,"This account is registered - you must log in before chatting or using commands! Use /login [password].");
        return 0;
    }
This works great, if the player is spawn-muted and has not logged in yet he/she cannot chat.


Under OnPlayerCommandText:
pawn Код:
if(MuteSpawn[playerid] == 1 && strfind("/login", cmdtext, true) == -1 && AccountInfo[playerid][Register] == 1)
    {
        SendClientMessage(playerid, COLOR_YELLOW,"This account is registered - you must log in before chatting or using commands! Use /login [password].");
        return 0;
    }
This doesn't work so well. /login can actually be used without parameters, but the moment a player enters a password it just throws the mute error message again. I've tried both DCMD and STRCMP implementations of the /login command, but the issue remained the same.

So yeah, how do I make it so /login can be sent parameters despite the spawn mute?

Thanks in advance!


PS. I know I could probably fix it with a login dialog, but I'd rather not go that route as all of the players in my server are used to manually typing /login, and it would kinda ruin the purpose of our nice pre-spawn area.
Reply
#2

Change to this: ( You forgot an ! )

strfind("/login", cmdtext, true) != -1
Reply
#3

Top of OnPlayerCommandText:

pawn Код:
if(MuteSpawn[playerid] == 1 && AccountInfo[playerid][Register] == 1)
    {
        if(strcmp(cmd, "/login", true) == 0)
        {
        }
        else
        {
            SendClientMessage(playerid, COLOR_YELLOW,"This account is registered - you must log in before chatting or using commands! Use /login [password].");
             return 1;
        }
    }
    // Rest of commands
Reply
#4

Quote:
Originally Posted by iPLEOMAX
Посмотреть сообщение
Change to this: ( You forgot an ! )

strfind("/login", cmdtext, true) != -1
I have it set as-is so it detects when a player's input does NOT match /login. Your proposed fix would make the error only show when players use /login, so that's not gonna work for me. Thanks for trying to help, though.

Quote:
Originally Posted by Famalamalam
Посмотреть сообщение
Top of OnPlayerCommandText:

pawn Код:
if(MuteSpawn[playerid] == 1 && && AccountInfo[playerid][Register] == 1)
    {
        if(strcmp(cmd, "/login", true) == 0)
        {
        }
        else
        {
            SendClientMessage(playerid, COLOR_YELLOW,"This account is registered - you must log in before chatting or using commands! Use /login [password].");
             return 1;
        }
    }
    // Rest of commands
Hahaha, that is awesome. Simple yet smart. Thanks! +rep
Reply
#5

Oh, sorry. Didn't pay much attention.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)