SA-MP Forums Archive
Allow only /login (with params!) while player is muted before spawning? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Allow only /login (with params!) while player is muted before spawning? (/showthread.php?tid=274016)



Allow only /login (with params!) while player is muted before spawning? - XpanD - 04.08.2011

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.


Re: Allow only /login (with params!) while player is muted before spawning? - iPLEOMAX - 04.08.2011

Change to this: ( You forgot an ! )

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


Re: Allow only /login (with params!) while player is muted before spawning? - Famalamalam - 04.08.2011

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



Re: Allow only /login (with params!) while player is muted before spawning? - XpanD - 04.08.2011

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


Re: Allow only /login (with params!) while player is muted before spawning? - iPLEOMAX - 04.08.2011

Oh, sorry. Didn't pay much attention.