How To Script..
#1

I want to enter a dialog when I go to the pickup dialog. Type "Enter the password to enter the house"

PHP код:
    if(pickupid == EnterHouse)
    {
    } 
And when I entered the password if it was false, show the message:
PHP код:
SendClientMessage(playerid,0xFF0000AA,"Wrong Password!"); 
And if it was right, set player pos to:
PHP код:
SetPlayerPos(playerid,139.4020,1368.8059,1083.8636); 
Does anyone help me?
Reply
#2

You must first create the pickup..

PHP код:
OnGameModeInIt()
{
   
EnterHouse CreatePickup(Model IDtypeXYZvirtual world //By the way you can also create Dynamic one...

And need a house enum that saves the password
PHP код:
enum houseinfo
{
   
housepassword;
}
new 
HouseInfo[MAX_HOUSES][houseinfo]; 
Then do like that..

PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{
     if(
pickupid == EnterHouse)
     {
          
ShowPlayerDialog(playerid1000DIALOG_STYLE_PASSWORD"House Password""Enter the house password below:""Enter""Close");
     }

Then the dialog response

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 1000)
    {
        if(!
response// That's if he pressed ESC or Cancel button.
        
{
            
SendClientMessage(playerid,0xFF0000AA,"Wrong Password!");  
        }
        else 
// That's if he pressed Okay or ENTER button.
        
{
            if(
strcmp(HouseInfo[houseid][hPassword], inputtexttrue32)
            {
                
SetPlayerPos(playerid,139.4020,1368.8059,1083.8636);  
            }
            else
            {
                
SendClientMessage(playerid,0xFF0000AA,"Wrong Password!"); 
 
                
// Re-show the login dialog
                
ShowPlayerDialog(playerid1000DIALOG_STYLE_PASSWORD"House Password""Please enter your house password:""Login""Cancel");
            }
        }
        return 
1;
    }
 
    return 
0;

Reply
#3

Thank you for your answer but, I encounter with this error when compile:
PHP код:
C:\Users\Desktop\gm9\filterscripts\House_h.pwn(76) : error 001expected token"}"but found ";"
C:\Users\Desktop\gm9\filterscripts\House_h.pwn(78) : error 017undefined symbol "MAX_HOUSES"
C:\Users\Desktop\gm9\filterscripts\House_h.pwn(444) : error 017undefined symbol "houseid"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
3 Errors

Reply
#4

Quote:
Originally Posted by Vizi10
Посмотреть сообщение
Thank you for your answer but, I encounter with this error when compile
I didn't give you the exact code tho, You need also to adapt it with your script, I won't feed you in mouth, If I've got to give you the full code, then what is your use??
Reply
#5

@JasonRiggs

PHP код:
if(strcmp(HouseInfo[houseid][hPassword], inputtexttrue32)
            {
                
SetPlayerPos(playerid,139.4020,1368.8059,1083.8636);  
            }
            else
            {
                
SendClientMessage(playerid,0xFF0000AA,"Wrong Password!"); 
 
                
// Re-show the login dialog
                
ShowPlayerDialog(playerid1000DIALOG_STYLE_PASSWORD"House Password""Please enter your house password:""Login""Cancel");
            } 
that means if the password is wrong = right and if its right = wrong!

you should check if strcmp equal to 0

PHP код:
if(!strcmp(HouseInfo[houseid][hPassword], inputtexttrue)) 
Reply
#6

Quote:
Originally Posted by Lokii
Посмотреть сообщение
@JasonRiggs

PHP код:
if(strcmp(HouseInfo[houseid][hPassword], inputtexttrue32)
            {
                
SetPlayerPos(playerid,139.4020,1368.8059,1083.8636);  
            }
            else
            {
                
SendClientMessage(playerid,0xFF0000AA,"Wrong Password!"); 
 
                
// Re-show the login dialog
                
ShowPlayerDialog(playerid1000DIALOG_STYLE_PASSWORD"House Password""Please enter your house password:""Login""Cancel");
            } 
that means if the password is wrong = right and if its right = wrong!

you should check if strcmp equal to 0

PHP код:
if(!strcmp(HouseInfo[houseid][hPassword], inputtexttrue)) 
I believe that you are the wrong one, As I'm checking that if the strcmp is equal to 1 then teleport the player, Else, then send the wrong password message.
Reply
#7

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
I didn't give you the exact code tho, You need also to adapt it with your script, I won't feed you in mouth, If I've got to give you the full code, then what is your use??
thanks
Reply
#8

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
I believe that you are the wrong one, As I'm checking that if the strcmp is equal to 1 then teleport the player, Else, then send the wrong password message.
That's not how strcmp works

if the string match strcmp will sub -1 so if strcmp is not equal to 0 strings not match

PHP код:
strcmp("test""te"); //will return 2
strcmp("test""tes"); //will return 1 
PHP код:
strcmp("test""test"); //will return 0 
Reply
#9

In short, what Lokii is trying to say is if, Strings match, strcmp will return 0 instead of 1.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)