Errors
#1

Getting this error and i can't see why it's doing it.

Код:
error 028: invalid subscript (not an array or too many subscripts): "pFactionRank"

format(L_sz_Rank, 56, "%s", pFactionRank[PlayerData[playerid][pFaction], PlayerData[playerid][pFactionRank]));
Full command.

Код:
CMD:toll(playerid, params[])
{


	new L_sz_Input[256],
	L_sz_CopName[MAX_PLAYER_NAME],
	L_sz_MessageString[256],
	L_sz_Rank[56],
	L_sz_Faction[8];

	if (GetFactionType(playerid) != FACTION_POLICE)
	return SendErrorMessage(playerid, "You must be a police officer.");

	format(L_sz_Rank, 56, "%s", pFactionRank[PlayerData[playerid][pFaction], PlayerData[playerid][pFactionRank]));
	format(L_sz_Faction, 8, "%s", FactionData[PlayerData[playerid][pFaction]][pFactionID]);
	format(L_sz_Rank, 56, "Rank");
	format(L_sz_Faction, 8, "Faction");
	format(L_sz_CopName, MAX_PLAYER_NAME, GetICName(playerid));


	if(IsNull(L_sz_Input))
	{
	    SendClientMessage(playerid, COLOR_YELLOW, "Toll barrier command central for Los Santos");
	    SendClientMessage(playerid, COLOR_GRAD2, "emergency/release - (Un)Locks all the barriers.");
	    SendClientMessage(playerid, COLOR_GRAD2, "flint - (Un)locks flint tolls.");
	    SendClientMessage(playerid, COLOR_GRAD2, "richman - (Un)locks Richman tunnel tolls.");
	    SendClientMessage(playerid, COLOR_GRAD2, "lv - (Un)locks the Las Venturas Highway tolls.");
	    return 1;
	}

	if(!Toll_TimePassedCops(playerid))
	    return 1;

    if(strcmp(L_sz_Input, "emergency", true, strlen(L_sz_Input)) == 0)
	{
	    aTolls[FlintToll][E_tLocked] = 1;
	    aTolls[RichmanToll][E_tLocked] = 1;
	    aTolls[LVToll][E_tLocked] = 1;
	    Toll_CloseToll(FlintToll);
	    Toll_CloseToll(RichmanToll);
	    Toll_CloseToll(LVToll);
	    new L_i_Time = (GetUnixTime() + TollTimerEmergency);
	    aTolls[FlintToll][E_tTimer] = L_i_Time;
	    aTolls[RichmanToll][E_tTimer] = L_i_Time;
	    aTolls[LVToll][E_tTimer] = L_i_Time;
	    format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were LOCKED by %s %s (%s)! **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
	    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
	}
	else if(strcmp(L_sz_Input, "release", true, strlen(L_sz_Input)) == 0)
	{
	    aTolls[FlintToll][E_tLocked] = 0;
	    aTolls[RichmanToll][E_tLocked] = 0;
	    aTolls[LVToll][E_tLocked] = 0;
	    format(L_sz_MessageString, 256, "** HQ Announcement: All toll booths were UNLOCKED by %s %s (%s)! **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
	    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
	}

	else if(strcmp(L_sz_Input, "flint", true, strlen(L_sz_Input)) == 0)
	{
	    if(aTolls[FlintToll][E_tLocked] == 0)
	    {
	        aTolls[FlintToll][E_tLocked] = 1;
	        aTolls[FlintToll][E_tTimer] = (GetUnixTime() + TollTimer);
	        Toll_CloseToll(FlintToll);
		    format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were LOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
		    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
		}
		else
		{
		    aTolls[FlintToll][E_tLocked] = 0;
		    format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Flint County were UNLOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
		    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
		}
	}

	else if(strcmp(L_sz_Input, "richman", true, strlen(L_sz_Input)) == 0)
	{
	    if(aTolls[RichmanToll][E_tLocked] == 0)
	    {
	        aTolls[RichmanToll][E_tLocked] = 1;
	        aTolls[RichmanToll][E_tTimer] = (GetUnixTime() + TollTimer);
	        Toll_CloseToll(RichmanToll);
		    format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were LOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
		    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
	    }
	    else
	    {
	        aTolls[RichmanToll][E_tLocked] = 0;
		    format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Richman were UNLOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
		    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
	    }
	}

	else if(strcmp(L_sz_Input, "lv", true) == 0)
	{
	    if(aTolls[LVToll][E_tLocked] == 0)
	    {
	        aTolls[LVToll][E_tLocked] = 1;
	        aTolls[LVToll][E_tTimer] = (GetUnixTime() + TollTimer);
	        Toll_CloseToll(LVToll);
		    format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were LOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
		    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
	    }
	    else
	    {
	        aTolls[LVToll][E_tLocked] = 0;
		    format(L_sz_MessageString, 256, "** HQ Announcement: Toll booths at Las Venturas were UNLOCKED by %s %s (%s). **", L_sz_Rank, L_sz_CopName, L_sz_Faction);
		    SendTeamTypeMessage(1, TEAM_BLUE_COLOR, L_sz_MessageString);
	    }
	}
	return 1;
}
Reply
#2

your mistakes in this line:
pawn Код:
format(L_sz_Rank, 56, "%s", pFactionRank[PlayerData[playerid][pFaction], PlayerData[playerid][pFactionRank]));
1. you used 2 floats in format but you use 1 "%s"

2. you have a Additional useless ")" at the end of your format function

pawn Код:
format(L_sz_Rank, 56, "%s%d", pFactionRank[PlayerData[playerid][pFaction], PlayerData[playerid][pFactionRank]);
Reply
#3

Oh but it still didn't work.

error 028: invalid subscript (not an array or too many subscripts): "pFactionRank"

This code gives me a error as well

format(L_sz_Faction, 8, "%s", FactionData[PlayerData[playerid][pFaction]][pFactionID]);

error 032: array index out of bounds (variable "FactionData")
Reply
#4

pawn Код:
PlayerData[playerid][pFaction]
This variable is greater than the size of FactionData.

Also look for this line:
pawn Код:
format(L_sz_Rank, 56, "%s", pFactionRank[PlayerData[playerid][pFaction], PlayerData[playerid][pFactionRank]));
and replace it with:
pawn Код:
format(L_sz_Rank, 56, "%s", PlayerData[playerid][pFactionRank]));
Reply
#5

Okay maybe not but you forgot to remove the ); because it was ));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)