PDA

View Full Version : Dialog errors.. help


aCloudy
04/02/2015, 12:33 PM
Hi, I got two errors in scripted a dialog.
This dialog is "input", And the typed word in the input dialog will be the "passwordET", passwordET is a password for a gate.
The problem is in (new password[50] = ...) and that (passwordET = password) , Please someone help.

MY QUESTION: HOW TO REPLACE A STRING WITH ANOTHER STRING ?
C:\Program Files\lvcnrr\gamemodes\SFCNR1.pwn(13257) : error 008: must be a constant expression; assumed zero
C:\Program Files\lvcnrr\gamemodes\SFCNR1.pwn(13267) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


if(dialogid == DIALOG_ETPW)
{
new string[128];
if(response == 1)
{
new password[50] =strval(inputtext); // This is well, But go down to "passwordET = password" and see..
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,DIALOG_ETPW,DIALOG_STYLE _INPUT,"{FFFFFF}ET Gate Password","{FFFFFF}Please enter a new password.","Ok","Cancel");
return 1;
}
format(string,sizeof(string),""COL_ADMIN"[ADMIN] {FFFFFF}You have changed {AFAFAF}[ET]{FFFFFF} gate password to %s!",password);
SCM(playerid,COLOR_WHITE,string);
format(string,sizeof(string),"%s(%d) has changed [ET] gate password.",PlayerName(playerid),playerid);
SendALogMessage(string);
passwordET = password; // HERE IS THE PROBLEM, I want to set a string to string.
return 1;
}
}

denNorske
04/02/2015, 12:55 PM
if(dialogid == DIALOG_ETPW)
{
new string[128];
if(response == 1)
{
new password[50];
format(password, sizeof(password), "%s, inputtext); //change this aswell
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,DIALOG_ETPW,DIALOG_STYLE _INPUT,"{FFFFFF}ET Gate Password","{FFFFFF}Please enter a new password.","Ok","Cancel");
return 1;
}
format(string,sizeof(string),""COL_ADMIN"[ADMIN] {FFFFFF}You have changed {AFAFAF}[ET]{FFFFFF} gate password to %s!",password);
SCM(playerid,COLOR_WHITE,string);
format(string,sizeof(string),"%s(%d) has changed [ET] gate password.",PlayerName(playerid),playerid);
SendALogMessage(string);
//passwordET = password; // HERE IS THE PROBLEM, I want to set a string to string.
format(passwordET, sizeof(passwordET) , "%s", password); //use this to set one string as another.
return 1;
}
}


Use "format" to format other text-strings. Read more here:

http://wiki.sa-mp.com/wiki/Format

Dutheil
04/02/2015, 12:57 PM
new password[50] =strval(inputtext);

http://wiki.sa-mp.com/wiki/Strval

denNorske
04/02/2015, 12:58 PM
new password[50] =strval(inputtext);

http://wiki.sa-mp.com/wiki/Strval

Read the wiki yourself:
...The string you want to convert to an integer.

As he is not trying to do here

Edit; i did understand your post now. Sorry about my comment

As for the Thread starter; read about "strval" and what it does. It converts a string into a number, and that is not what you should do here.

Read my post above and try to understand the changes i've made.