SA-MP Forums Archive
if(inputtext == "hi") doesnt work - 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)
+--- Thread: if(inputtext == "hi") doesnt work (/showthread.php?tid=440856)



if(inputtext == "hi") doesnt work - NicholasA - 31.05.2013

Код:
if(dialogid == 283) // Admin verify
    {
        if(!response)
        {
            SendClientMessage(playerid, -1, "Nice try idiot!");
            Kick(playerid);
        }
        else // login
        {
            if(inputtext == "password")
            {
                SendClientMessage(playerid, -1, "{00EEFF}Welcome back! /help for admin cmds!");
            }
            else
            {
                SendClientMessage(playerid, -1, "Nice try idiot!");
				Kick(playerid);
            }
        }
        return 1; 
    }



Re: if(inputtext == "hi") doesnt work - Stefand - 31.05.2013

pawn Код:
if(dialogid == 283) // Admin verify
    {
        if(!response)
        {
            SendClientMessage(playerid, -1, "Nice try idiot!");
            Kick(playerid);
        }
        else // login
        {
            if(strcmp(inputtext, "password", true) == 0)
            {
                SendClientMessage(playerid, -1, "{00EEFF}Welcome back! /help for admin cmds!");
            }
            else
            {
                SendClientMessage(playerid, -1, "Nice try idiot!");
                Kick(playerid);
            }
        }
        return 1;
    }



Re: if(inputtext == "hi") doesnt work - [ABK]Antonio - 31.05.2013

pawn Код:
if(!strcmp(inputtext, "password", false))
https://sampwiki.blast.hk/wiki/Strcmp


EDIT: Just noticed you created another thread on the same type of thing. When comparing strings you need (well, not need) to use strcmp.


Re: if(inputtext == "hi") doesnt work - Stefand - 31.05.2013

Quote:
Originally Posted by [ABK]Antonio
Посмотреть сообщение
pawn Код:
if(!strcmp(inputtext, "password", false))
https://sampwiki.blast.hk/wiki/Strcmp
That checks if its NOT "password", Try mine


Re: if(inputtext == "hi") doesnt work - Delta 4 - 31.05.2013

Use strcmp instead:

Код:
 if(strcmp(inputtext, "password", true) == 0)



Re: if(inputtext == "hi") doesnt work - [ABK]Antonio - 31.05.2013

Quote:
Originally Posted by Stefand
Посмотреть сообщение
That checks if its NOT "password", Try mine
Uhh? What's the difference? Aside from you don't check case sensitivity.


Re: if(inputtext == "hi") doesnt work - Konstantinos - 31.05.2013

Quote:
Originally Posted by Stefand
Посмотреть сообщение
That checks if its NOT "password", Try mine
Wrong! That checks if it's the same and the case matters.

!strcmp is equal to 0 which is returned if the two strings are the same. The false is about "password" is not same string as "PassWord".