gate password not working
#1

When i do my gate command any password will work just not the real one.

Код:
#define NEWSGATE_PASSWORD  "password21" // This is where i put the password"
#define error 0xFF0000FF
#define normal 0xFFFFFFFF
forward GateClose(playerid);
new newsgate1;
new newsgate;
#define NEWSGATEMENU 1325
The menu now
Код:
if(dialogid == NEWSGATEMENU)//if dont work
	{
	    if(!response)
		{
			SendClientMessage(playerid, error, " Okay Access Denied Have a Nice Day!");
		}
		if(!strcmp(inputtext, NEWSGATE_PASSWORD, true))
		{
            SendClientMessage(playerid, error, "Invalid Passcode");
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Security Gate", "One More Chance, Please Punch In Your Passcode", "Open", "Cancel");
		}
		else
		{
			if(newsgate == 1) { SendClientMessage(playerid, error, "**  Security Gate is Allready Opened"); return 1; }
		  	MoveDynamicObject(newsgate1,769.52178955078, -1384.7537841797, 14.225526809692, 0.97); // to open the gate
		    SetTimer("GateClose", 12000, 0); /// timer to close in 7 seconds
		    SendClientMessage(playerid, normal,"Security Gate will close in 7 seconds.");
		   	PlayerPlaySound(playerid, 1153, 1589.053344,-1638.123168,14.122960);
		    newsgate = 1;
		}
	}
object now

Код:
newsgate1 = CreateDynamicObject(975, 777.52178955078, -1384.7537841797, 14.225526809692, 0, 0, 180.09997558594);//
command
Код:
if(strcmp(cmdtext, "/gate", true) == 0)
{
(IsPlayerInRangeOfPoint(playerid, 15.0,777.52178955078, -1384.7537841797, 14.225526809692)) // This is where player is in range of gate
	    {
               ShowPlayerDialog(playerid,NEWSGATEMENU, DIALOG_STYLE_INPUT, "Security Gate", "Hello How Are you Today, Please Punch In Your Passcode", "Open", "Cancel");
		}


i know some of it is not all close off on the command but it is just how i copy it.



SO the gate dose work but it will work with any thing that i type into the menu but when i put the real password in the menu it will say wrong password and i can not work out how to fix this please help.
Reply
#2

Simple, strcmp dosent work like that, you are checking if the password entered is NOT the correct one
Change
Код:
if(!strcmp(inputtext, NEWSGATE_PASSWORD, true))
to
Код:
if(strcmp(inputtext, NEWSGATE_PASSWORD, true))
- [FF]Cody_Beer
Reply
#3

pawn Код:
if(dialogid == NEWSGATEMENU)//if dont work
    {
        if(!response)
        {
            SendClientMessage(playerid, error, " Okay Access Denied Have a Nice Day!");
        }
        if(strcmp(inputtext, NEWSGATE_PASSWORD, false))
        {
            SendClientMessage(playerid, error, "Invalid Passcode");
            ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Security Gate", "One More Chance, Please Punch In Your Passcode", "Open", "Cancel");
        }
        else
        {
            if(newsgate == 1) { SendClientMessage(playerid, error, "**  Security Gate is Allready Opened"); return 1; }
            MoveDynamicObject(newsgate1,769.52178955078, -1384.7537841797, 14.225526809692, 0.97); // to open the gate
            SetTimer("GateClose", 12000, 0); /// timer to close in 7 seconds
            SendClientMessage(playerid, normal,"Security Gate will close in 7 seconds.");
            PlayerPlaySound(playerid, 1153, 1589.053344,-1638.123168,14.122960);
            newsgate = 1;
        }
    }
Reply
#4

Apparently someone didnt see my post, either way changing the way i said would have the same effect

- [FF]Cody_Beer
Reply
#5

Doing it your way will show the error message and not open the gate when he types the right password, my way works fine and he doesnt have to modify it any further.
Reply
#6

Try like this
pawn Код:
if(dialogid == NEWSGATEMENU)//if dont work
{
    if(!response)
    {
        SendClientMessage(playerid, error, " Okay Access Denied Have a Nice Day!"); return 1;
    }
    if(strcmp(NEWSGATE_PASSWORD,inputtext,true) == 0)
    {
        if(newsgate == 1) { SendClientMessage(playerid, error, "**  Security Gate is Allready Opened"); return 1; }
        MoveDynamicObject(newsgate1,769.52178955078, -1384.7537841797, 14.225526809692, 0.97); // to open the gate
        SetTimer("GateClose", 12000, 0); /// timer to close in 7 seconds
        SendClientMessage(playerid, normal,"Security Gate will close in 7 seconds.");
        PlayerPlaySound(playerid, 1153, 1589.053344,-1638.123168,14.122960);
        newsgate = 1;
    }
    else
    {
        SendClientMessage(playerid, error, "Invalid Passcode");
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Security Gate", "One More Chance, Please Punch In Your Passcode", "Open", "Cancel");
    }
    return 1;
}
Reply
#7

Ok it works better now But if i spam the wrong password 33 times it will open .
Reply
#8

Quote:
Originally Posted by Crodox RP
Посмотреть сообщение
Simple, strcmp dosent work like that, you are checking if the password entered is NOT the correct one
Change
Код:
if(!strcmp(inputtext, NEWSGATE_PASSWORD, true))
to
Код:
if(strcmp(inputtext, NEWSGATE_PASSWORD, true))
- [FF]Cody_Beer
Quote:
Originally Posted by Crodox RP
Посмотреть сообщение
Apparently someone didnt see my post, either way changing the way i said would have the same effect

- [FF]Cody_Beer
Sorry, but both of those statements are wrong. "strcmp" returns 0 if the strings match therefore they will receive the "incorrect password" message when doing it your way. The correct way would be doing:

pawn Код:
if(!strcmp(NEWSGATE_PASSWORD, inputtext, true))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)