array must be indexed, Help please.
#1

coding problems? :S help please, Thanks in advance.

Код:
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8698 -- 8700) : error 008: must be a constant expression; assumed zero
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8702) : error 033: array must be indexed (variable "giveplayerid")
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8707) : error 033: array must be indexed (variable "giveplayerid")
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8708) : error 035: argument type mismatch (argument 1)
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8708) : warning 215: expression has no effect
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8708) : error 001: expected token: ";", but found ")"
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8708) : error 029: invalid expression, assumed zero
C:\Network Game Servers\GTA\DEBUG\gamemodes\lvcrs.pwn(8708) : fatal error 107: too many error messages on one line


Код:
stock closestplayer(playerid) {  <<<< this is line 8684
	for(new i=0; i<MAX_PLAYERS; i++) {
		if(GetDistanceBetweenPlayers(playerid, i) < 6 && i != playerid && IsPlayerConnected(i)) { //Distance of 5 in-game meters
			new string[256];
			format(string, sizeof(string), "%d", i);
			return SendClientMessageToAll(COLOR_YELLOW,string);
		}
 	}
	return 0;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {  <<This is line 8696
new string[256];
new giveplayerid[MAX_PLAYERS] = closestplayer(playerid)

if(newkeys == KEY_SUBMISSION) {

	if (closestplayer(playerid) && (cuffed[giveplayerid] == 0) {   <<<<< 8702
		format(string, sizeof(string), "/cuff %d", closestplayer(playerid));
		playercommandtext(playerid, string);
	}

	else if (closestplayer(playerid) && (cuffed[giveplayerid] == 1) {
		if(GetPlayerWantedLevel(giveplayerid) = 0) {
			format(string, sizeof(string), "/uncuff %d", closestplayer(playerid));
			playercommandtext(playerid, string);
		}
		else if (GetPlayerWantedLevel(giveplayerid) <= 3) {
			format(string, sizeof(string), "/fine %d", closestplayer(playerid));
			playercommandtext(playerid, string);
		}
		else if (GetPlayerWantedLevel(giveplayerid) >= 4) {
			format(string, sizeof(string), "/arrest %d", closestplayer(playerid));
			playercommandtext(playerid, string);
		}
	}

}
}
Reply
#2

FYI, please use Pawn tags when posting pawn code, makes things a little easier with coloring. Anyway, the lines you pointed out in your code were not actual errors in your log, so not sure why you pointed those out, but anway...

This is your problem child
pawn Код:
new giveplayerid[MAX_PLAYERS] = closestplayer(playerid)
giveplayerid does not need to be an array in this case. Simply remove the [MAX_PLAYERS] and you should be fine.

pawn Код:
new giveplayerid = closestplayer(playerid)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)