PDA

View Full Version : Weird Error but why?


Sniper Kitty
09/08/2012, 10:40 AM
Edit: Go here instead: http://forum.sa-mp.com/showpost.php?p=2043224&postcount=14

for(new dialogID = 1; dialogID <= MAX_DIALOGS; dialogID++) {
if(Dialog[dialogID][SK94_dialogCreated] == 0) { // Line 535

I'm getting an error with these lines.

C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : error 001: expected token: ")", but found "["
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : error 029: invalid expression, assumed zero
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : warning 215: expression has no effect
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : error 001: expected token: ";", but found "]"
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : fatal error 107: too many error messages on one line

Syntax
09/08/2012, 10:43 AM
Can you paste the whole section of that code, please?

Sniper Kitty
09/08/2012, 10:44 AM
Certainly...

stock CreateDialog(Type, Format[], {Float,_}:...) {
if(Type != DIALOG_STYLE_MSGBOX && Type != DIALOG_STYLE_LIST && Type != DIALOG_STYLE_INPUT && Type != DIALOG_STYLE_PASSWORD) {
return 0;
}

for(new dialogID = 1; dialogID <= MAX_DIALOGS; dialogID++) {
if(Dialog[dialogID][SK94_dialogCreated] == 0) { // Line 535
new Title[MAX_DIALOG_STRING],
Arg = 2;

for(new FormatPos = 0; FormatPos < strlen(Format); FormatPos++) {
if(Format[FormatPos] == '%') {
switch(Format[(FormatPos + 1)]) {
case 's': {
for(new Index = 0; getarg(Arg, Index); Index++) {
Title[strlen(Title)] = getarg(Arg, Index);
}

FormatPos++;
Arg++;
}
case 'd', 'i': {
new Result = getarg(Arg);

if(strlen(Title)) {
format(Title, MAX_DIALOG_STRING, "%s%d", Title, Result);
}
else {
format(Title, MAX_DIALOG_STRING, "%d", Result);
}

FormatPos++;
Arg++;
}
case 'f': {
new Float: Result = Float: getarg(Arg);

if(strlen(Title)) {
format(Title, MAX_DIALOG_STRING, "%s%f", Title, Result);
}
else {
format(Title, MAX_DIALOG_STRING, "%f", Result);
}

FormatPos++;
Arg++;
}
default: {
Title[strlen(Title)] = Format[FormatPos];
}
}
}
else {
Title[strlen(Title)] = Format[FormatPos];
}
}

Dialog[dialogID][SK94_dialogCreated] = true;
Dialog[dialogID][SK94_dialogType] = Type;
format(Dialog[dialogID][SK94_dialogTitle], MAX_DIALOG_STRING, "%s", Title);
return dialogID;
}
}
return 0;
}

IceMeteor
09/08/2012, 11:00 AM
Is it the include? because the error is on your include

Sniper Kitty
09/08/2012, 11:02 AM
you forgot the ;
for(new dialogID = 1; dialogID <= MAX_DIALOGS; dialogID++) {
if(Dialog[dialogID][SK94_dialogCreated] == 0;) {

You don't end a if statement with a ; in any scripting language,
I just tried it incase you were right and I'm still getting the same error.

Is it the include? because the error is on your include

It is my custom include, I've compiled the include and it shows no errors.

So it has to be the gamemode, the gamemode is the one showing the errors when compiling.

IceMeteor
09/08/2012, 11:04 AM
You don't end a if statement with a ; in any scripting language,
I just tried it incase you were right and I'm still getting the same error.

Sorry i made a mistake XD

Sniper Kitty
09/08/2012, 11:05 AM
Sorry i made a mistake XD

It's okay.

IceMeteor
09/08/2012, 11:07 AM
Can you show the line 535 in your include ?

Sniper Kitty
09/08/2012, 11:08 AM
The if statement you tried correcting me on is line 535

leonardo1434
09/08/2012, 11:13 AM
Show us how you have made this array.


Dialog[dialogID][SK94_dialogCreated]

Sniper Kitty
09/08/2012, 11:15 AM
enum SK94_dialogData {
SK94_dialogCreated,
SK94_dialogType,
SK94_dialogTitle[MAX_DIALOG_STRING],
SK94_dialogContent[MAX_DIALOG_STRING],
SK94_dialogButton1[MAX_DIALOG_STRING],
SK94_dialogButton2[MAX_DIALOG_STRING]
};

static Dialog[(MAX_DIALOGS + 1)][SK94_dialogData];

I've used static because it's in the include and not the gamemode.

AntonioStyles
09/08/2012, 11:20 AM
Hmm..There doesnt seem to have any errors in it :/ Well,i'll check it out and tell you what it says to me.

leonardo1434
09/08/2012, 11:26 AM
Well, i've tested your function and don't give me any errors, are you sure you aren't calling it in a wrong way?

See the way i've tested.

http://pastebin.com/6wCcfqw0

Sniper Kitty
09/08/2012, 11:28 AM
Have the whole thing,

enum SK94_dialogData {
SK94_dialogCreated,
SK94_dialogType,
SK94_dialogTitle[MAX_DIALOG_STRING],
SK94_dialogContent[MAX_DIALOG_STRING],
SK94_dialogButton1[MAX_DIALOG_STRING],
SK94_dialogButton2[MAX_DIALOG_STRING]
};

static Dialog[(MAX_DIALOGS + 1)][SK94_dialogData];

stock CreateDialog(Type, Format[], {Float,_}:...) {
if(Type != DIALOG_STYLE_MSGBOX && Type != DIALOG_STYLE_LIST && Type != DIALOG_STYLE_INPUT && Type != DIALOG_STYLE_PASSWORD) {
return 0;
}

for(new dialogID = 1; dialogID <= MAX_DIALOGS; dialogID++) {
if(Dialog[dialogID][SK94_dialogCreated] == 0) {
new Title[MAX_DIALOG_STRING],
Arg = 2;

for(new FormatPos = 0; FormatPos < strlen(Format); FormatPos++) {
if(Format[FormatPos] == '%') {
switch(Format[(FormatPos + 1)]) {
case 's': {
for(new Index = 0; getarg(Arg, Index); Index++) {
Title[strlen(Title)] = getarg(Arg, Index);
}

FormatPos++;
Arg++;
}
case 'd', 'i': {
new Result = getarg(Arg);

if(strlen(Title)) {
format(Title, MAX_DIALOG_STRING, "%s%d", Title, Result);
}
else {
format(Title, MAX_DIALOG_STRING, "%d", Result);
}

FormatPos++;
Arg++;
}
case 'f': {
new Float: Result = Float: getarg(Arg);

if(strlen(Title)) {
format(Title, MAX_DIALOG_STRING, "%s%f", Title, Result);
}
else {
format(Title, MAX_DIALOG_STRING, "%f", Result);
}

FormatPos++;
Arg++;
}
default: {
Title[strlen(Title)] = Format[FormatPos];
}
}
}
else {
Title[strlen(Title)] = Format[FormatPos];
}
}

Dialog[dialogID][SK94_dialogCreated] = true;
Dialog[dialogID][SK94_dialogType] = Type;
format(Dialog[dialogID][SK94_dialogTitle], MAX_DIALOG_STRING, "%s", Title);
return dialogID;
}
}
return 0;
}

stock SetDialogContent(dialogID, Format[], {Float,_}:...) {
if(dialogID < 1 || dialogID > MAX_DIALOGS || Dialog[dialogID][SK94_dialogCreated] == 0) {
return false;
}

new Content[MAX_DIALOG_STRING],
Arg = 2;

for(new FormatPos = 0; FormatPos < strlen(Format); FormatPos++) {
if(Format[FormatPos] == '%') {
switch(Format[(FormatPos + 1)]) {
case 's': {
for(new Index = 0; getarg(Arg, Index); Index++) {
Content[strlen(Content)] = getarg(Arg, Index);
}

FormatPos++;
Arg++;
}
case 'd', 'i': {
new Result = getarg(Arg);

if(strlen(Content)) {
format(Content, MAX_DIALOG_STRING, "%s%d", Content, Result);
}
else {
format(Content, MAX_DIALOG_STRING, "%d", Result);
}

FormatPos++;
Arg++;
}
case 'f': {
new Float: Result = Float: getarg(Arg);

if(strlen(Content)) {
format(Content, MAX_DIALOG_STRING, "%s%f", Content, Result);
}
else {
format(Content, MAX_DIALOG_STRING, "%f", Result);
}

FormatPos++;
Arg++;
}
default: {
Content[strlen(Content)] = Format[FormatPos];
}
}
}
else {
Content[strlen(Content)] = Format[FormatPos];
}
}

format(Dialog[dialogID][SK94_dialogContent], MAX_DIALOG_STRING, "%s", Content);
return true;
}

stock SetDialogButton1(dialogID, Format[], {Float,_}:...) {
if(dialogID < 1 || dialogID > MAX_DIALOGS || Dialog[dialogID][SK94_dialogCreated] == 0) {
return false;
}

new Content[MAX_DIALOG_STRING],
Arg = 2;

for(new FormatPos = 0; FormatPos < strlen(Format); FormatPos++) {
if(Format[FormatPos] == '%') {
switch(Format[(FormatPos + 1)]) {
case 's': {
for(new Index = 0; getarg(Arg, Index); Index++) {
Content[strlen(Content)] = getarg(Arg, Index);
}

FormatPos++;
Arg++;
}
case 'd', 'i': {
new Result = getarg(Arg);

if(strlen(Content)) {
format(Content, MAX_DIALOG_STRING, "%s%d", Content, Result);
}
else {
format(Content, MAX_DIALOG_STRING, "%d", Result);
}

FormatPos++;
Arg++;
}
case 'f': {
new Float: Result = Float: getarg(Arg);

if(strlen(Content)) {
format(Content, MAX_DIALOG_STRING, "%s%f", Content, Result);
}
else {
format(Content, MAX_DIALOG_STRING, "%f", Result);
}

FormatPos++;
Arg++;
}
default: {
Content[strlen(Content)] = Format[FormatPos];
}
}
}
else {
Content[strlen(Content)] = Format[FormatPos];
}
}

format(Dialog[dialogID][SK94_dialogButton1], MAX_DIALOG_STRING, "%s", Content);
return true;
}

stock SetDialogButton2(dialogID, Format[], {Float,_}:...) {
if(dialogID < 1 || dialogID > MAX_DIALOGS || Dialog[dialogID][SK94_dialogCreated] == 0) {
return false;
}

new Content[MAX_DIALOG_STRING],
Arg = 2;

for(new FormatPos = 0; FormatPos < strlen(Format); FormatPos++) {
if(Format[FormatPos] == '%') {
switch(Format[(FormatPos + 1)]) {
case 's': {
for(new Index = 0; getarg(Arg, Index); Index++) {
Content[strlen(Content)] = getarg(Arg, Index);
}

FormatPos++;
Arg++;
}
case 'd', 'i': {
new Result = getarg(Arg);

if(strlen(Content)) {
format(Content, MAX_DIALOG_STRING, "%s%d", Content, Result);
}
else {
format(Content, MAX_DIALOG_STRING, "%d", Result);
}

FormatPos++;
Arg++;
}
case 'f': {
new Float: Result = Float: getarg(Arg);

if(strlen(Content)) {
format(Content, MAX_DIALOG_STRING, "%s%f", Content, Result);
}
else {
format(Content, MAX_DIALOG_STRING, "%f", Result);
}

FormatPos++;
Arg++;
}
default: {
Content[strlen(Content)] = Format[FormatPos];
}
}
}
else {
Content[strlen(Content)] = Format[FormatPos];
}
}

format(Dialog[dialogID][SK94_dialogButton2], MAX_DIALOG_STRING, "%s", Content);
return true;
}

stock DialogShowForPlayer(dialogID, Format[], {Float,_}:...) {
if(! IsPlayerConnected(pID) || dialogID < 1 || dialogID > MAX_DIALOGS || Dialog[dialogID][SK94_dialogCreated] == 0) {
return false;
}

ShowPlayerDialog(pID, dialogID, Dialog[dialogID][SK94_dialogType], Dialog[dialogID][SK94_dialogTitle], Dialog[dialogID][SK94_dialogContent], Dialog[dialogID][SK94_dialogButton1], Dialog[dialogID][SK94_dialogButton2]);
return true;
}

Functions:
new DialogID = CreateDialog(Type, Title[], {Float,_}:...);
SetDialogContent(DialogID, Content[], {Float,_}:...);
SetDialogButton1(DialogID, Button1[], {Float,_}:...);
SetDialogButton2(DialogID, Button2[], {Float,_}:...);
DialogShowForPlayer(playerid, DialogID);

Example:

new Dialog[1];

public OnGameModeInit() {
Dialog[0] = CreateDialog(DIALOG_STYLE_MSGBOX, "Welcometo %s!", "Unknown Gamemode");
SetDialogButton1(Dialog[0], "Thanks");
SetDialogButton2(Dialog[0], "Leave");
return true;
}

public OnPlayerConnect(playerid) {
new Name[MAX_PLAYER_NAME];

GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
SetDialogContent(Dialog[0], "Welcome to %s, %s!", "Unknown Gamemode", Name);
DialogShowForPlayer(playerid, Dialog[0]);
return true;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
switch(dailogid) {
case Dialog[0]: {
if(! response) {
Kick(playerid);
}
return true;
}
}
return false;
}

Works for everyone else except for me...

C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : error 001: expected token: ")", but found "["
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : error 029: invalid expression, assumed zero
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : warning 215: expression has no effect
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : error 001: expected token: ";", but found "]"
C:\Users\TheLazySloth\Desktop\San Andreas Multiplayer\Server\pawno\include\SKFunctions.inc(5 35) : fatal error 107: too many error messages on one line

Line 535 is,
stock CreateDialog(Type, Format[], {Float,_}:...) {
if(Type != DIALOG_STYLE_MSGBOX && Type != DIALOG_STYLE_LIST && Type != DIALOG_STYLE_INPUT && Type != DIALOG_STYLE_PASSWORD) {
return 0;
}

for(new dialogID = 1; dialogID <= MAX_DIALOGS; dialogID++) {
if(Dialog[dialogID][SK94_dialogCreated] == 0) { // Line 535

leonardo1434
09/08/2012, 02:39 PM
Sorry for the late asnwer, i had to go.but now i'm at home and i've tested it, it give me some errors, are you sure this already worked out? Cause these tag mismatch should be a number instead of a array and there's some wrong stuff and unrequired in your function's.

stock DialogShowForPlayer(dialogID, Format[], {Float,_}:...) - : warning 203: symbol is never used: "Format"
SetDialogButton1(Dialog[0], "Thanks",2.0,#WTF); - : error 035: argument type mismatch (argument 1)
SetDialogButton2(Dialog[0], "Leave",2.0,#WTF); - : error 035: argument type mismatch (argument 1)
SetDialogContent(Dialog[0], "Welcome to %s, %s!", "Unknown Gamemode", Name); - : error 035: argument type mismatch (argument 1)
DialogShowForPlayer(playerid, Dialog[0]); -: warning 229: index tag mismatch (symbol "Dialog")
case Dialog1[0] - : error 008: must be a constant expression; assumed zero

Sniper Kitty
09/08/2012, 03:49 PM
I don't get any of those errors only that one line is giving me the error.

leonardo1434
09/08/2012, 04:07 PM
Kinda weird, i'm sorry if i can't help as you wish, but i'm not understanding your code, is kinda messed up and there's some un-required stuff in it.

the only thing i can say is, restart creating your function without these unrequired setarg and getarg.

and, i hope any other guy who get it better than myself help you.

Sniper Kitty
09/08/2012, 06:36 PM
The setarg and getarg is the whole point of the functions...