error 001: expected token: ")", but found "[" - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: error 001: expected token: ")", but found "[" (
/showthread.php?tid=581477)
error 001: expected token: ")", but found "[" -
alexanderjb918 - 13.07.2015
Code:
C:\Users\ii\Desktop\roleplay.pwn(26201) : warning 217: loose indentation
C:\Users\ii\Desktop\roleplay.pwn(26280) : error 001: expected token: ")", but found "["
C:\Users\ii\Desktop\roleplay.pwn(26280) : error 029: invalid expression, assumed zero
C:\Users\ii\Desktop\roleplay.pwn(26280) : warning 215: expression has no effect
C:\Users\ii\Desktop\roleplay.pwn(26280) : error 001: expected token: ";", but found "]"
C:\Users\ii\Desktop\roleplay.pwn(26280) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Code:
public ViewPlayer(extraid, name[])
{
if (GetFactionType(extraid) != FACTION_POLICE)
return 0;
new sex[18];
if(PlayerData[extraid][pMDCPlayer][pGender] == 1) { sex = "Male"; }
if(PlayerData[extraid][pMDCPlayer][pGender] == 2) { sex = "Female"; }
SendClientMessageEx(extraid, COLOR_GREEN, "------------------------_POLICE DATABASE_----------------------");
SendClientMessageEx(extraid, COLOR_GREEN, "Logged in as %s", ReturnName(extraid, 1));
SendClientMessageEx(extraid, COLOR_GREEN, "------------------------_POLICE DATABASE_-----------------------");
SendClientMessageEx(extraid, COLOR_WHITE, "------------------------_PERSON CHECK_----------------------");
SendClientMessageEx(extraid, COLOR_WHITE, "Name: %s", ReturnName(PlayerData[extraid][pMDCPlayer], 1));
SendClientMessageEx(extraid, COLOR_WHITE, "Date Of Birth: %s", PlayerData[PlayerData[extraid][pMDCPlayer]][pBirthdate]);
SendClientMessageEx(extraid, COLOR_WHITE, "Driving License: %s", PlayerData[PlayerData[extraid][pMDCPlayer]][pDrivingTest]);
SendClientMessageEx(extraid, COLOR_WHITE, "Time in Los Santos: %d", PlayerData[PlayerData[extraid][pMDCPlayer]][pPlayingHours]);
SendClientMessageEx(extraid, COLOR_WHITE, "Phone Number: %s", PlayerData[PlayerData[extraid][pMDCPlayer]][pPhone]);
SendClientMessageEx(extraid, COLOR_WHITE, "---------------------------------------------------------------");
return 1;
}
Re: error 001: expected token: ")", but found "[" -
Virtual1ty - 13.07.2015
You should label the line numbers in the code, otherwise it's hard for us to find the problem.
Edit: this is where your problems are, "PlayerData" is a 3D array, however you're using it as a 2D array sometimes.
(Errors are marked in red, the first faulty line in green)
Code:
public ViewPlayer(extraid, name[])
{
if (GetFactionType(extraid) != FACTION_POLICE) return 0;
new sex[18];
if(PlayerData[extraid][pMDCPlayer][pGender] == 1) { sex = "Male"; }
if(PlayerData[extraid][pMDCPlayer][pGender] == 2) { sex = "Female"; }
SendClientMessageEx(extraid, COLOR_GREEN, "------------------------_POLICE DATABASE_----------------------");
SendClientMessageEx(extraid, COLOR_GREEN, "Logged in as %s", ReturnName(extraid, 1));
SendClientMessageEx(extraid, COLOR_GREEN, "------------------------_POLICE DATABASE_-----------------------");
SendClientMessageEx(extraid, COLOR_WHITE, "------------------------_PERSON CHECK_----------------------");
SendClientMessageEx(extraid, COLOR_WHITE, "Name: %s", ReturnName(PlayerData[extraid][pMDCPlayer], 1));
SendClientMessageEx(extraid, COLOR_WHITE, "Date Of Birth: %s", PlayerData[PlayerData[extraid][pMDCPlayer]][pBirthdate]); // wasn't PlayerData a 3D array??
SendClientMessageEx(extraid, COLOR_WHITE, "Driving License: %s", PlayerData[PlayerData[extraid][pMDCPlayer]][pDrivingTest]);
SendClientMessageEx(extraid, COLOR_WHITE, "Time in Los Santos: %d", PlayerData[PlayerData[extraid][pMDCPlayer]][pPlayingHours]);
SendClientMessageEx(extraid, COLOR_WHITE, "Phone Number: %s", PlayerData[PlayerData[extraid][pMDCPlayer]][pPhone]);
SendClientMessageEx(extraid, COLOR_WHITE, "---------------------------------------------------------------");
return 1;
}
Also, a word to the wise - avoid using 3D arrays. In most of the cases, they're unnecessary.