SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 16/05/2018, 07:36 PM   #1
Vizi10
Little Clucker
 
Join Date: May 2017
Posts: 15
Reputation: 0
Default How To Script..

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

PHP Code:
    if(pickupid == EnterHouse)
    {

    } 
And when I entered the password if it was false, show the message:
PHP Code:
SendClientMessage(playerid,0xFF0000AA,"Wrong Password!"); 
And if it was right, set player pos to:
PHP Code:
SetPlayerPos(playerid,139.4020,1368.8059,1083.8636); 
Does anyone help me?
Vizi10 is offline   Reply With Quote
Old 16/05/2018, 07:53 PM   #2
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 604
Reputation: 18
Default Re: How To Script..

You must first create the pickup..

PHP Code:
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 Code:
enum houseinfo
{
   
housepassword;
}
new 
HouseInfo[MAX_HOUSES][houseinfo]; 
Then do like that..

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

Then the dialog response

PHP Code:
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;

__________________

forum.nc-rp.cf
JasonRiggs is offline   Reply With Quote
Old 16/05/2018, 08:12 PM   #3
Vizi10
Little Clucker
 
Join Date: May 2017
Posts: 15
Reputation: 0
Default Re: How To Script..

Thank you for your answer but, I encounter with this error when compile:
PHP Code:
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

Vizi10 is offline   Reply With Quote
Old 16/05/2018, 08:13 PM   #4
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 604
Reputation: 18
Default Re: How To Script..

Quote:
Originally Posted by Vizi10 View Post
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??
__________________

forum.nc-rp.cf
JasonRiggs is offline   Reply With Quote
Old 16/05/2018, 08:14 PM   #5
Lokii
Big Clucker
 
Join Date: Sep 2017
Posts: 120
Reputation: 59
Default Re: How To Script..

@JasonRiggs

PHP Code:
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 Code:
if(!strcmp(HouseInfo[houseid][hPassword], inputtexttrue)) 
Lokii is offline   Reply With Quote
Old 16/05/2018, 08:25 PM   #6
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 604
Reputation: 18
Default Re: How To Script..

Quote:
Originally Posted by Lokii View Post
@JasonRiggs

PHP Code:
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 Code:
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.
__________________

forum.nc-rp.cf
JasonRiggs is offline   Reply With Quote
Old 16/05/2018, 08:29 PM   #7
Vizi10
Little Clucker
 
Join Date: May 2017
Posts: 15
Reputation: 0
Default Re: How To Script..

Quote:
Originally Posted by JasonRiggs View Post
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
Vizi10 is offline   Reply With Quote
Old 16/05/2018, 08:31 PM   #8
Lokii
Big Clucker
 
Join Date: Sep 2017
Posts: 120
Reputation: 59
Default Re: How To Script..

Quote:
Originally Posted by JasonRiggs View Post
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 Code:
strcmp("test""te"); //will return 2
strcmp("test""tes"); //will return 1 
PHP Code:
strcmp("test""test"); //will return 0 
Lokii is offline   Reply With Quote
Old 17/05/2018, 04:33 AM   #9
GTLS
Huge Clucker
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 484
Reputation: 68
Default Re: How To Script..

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

I don't help for rep. I help cuz I was helped in the past.
GTLS is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Friend gave me his script and has 26 errors please help! (Script is already released public) Mappers4Life Scripting Help 5 15/05/2013 06:58 PM
Hilfe beim script (es geht um nemesuns Script) godaince1 Scripting Help 0 23/09/2012 02:10 PM
laptop script, incorporated to my script. result: can't compile to an amx file.. nikoo Help Archive 1 14/11/2009 02:57 AM
How to script a script??? how do u scripted a script, i have no clue HELP! Badandy Help Archive 10 06/06/2009 07:57 PM


All times are GMT. The time now is 09:54 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.