error 033: array must be indexed (variable "iscrim")
#1

Код:
public StartingGame2(playerid, vehicleid, seatid)
{
   	iscrim[Players] = 1;
   	if(iscrim == 1){
   	SetPlayerHealth(playerid, 50);
   	SendClientMessage(playerid, 0xE85C20FF, "You are the criminal!");
   	
   	
   	}
	else
	
   	
	SetPlayerPos(playerid,2138.9658,1463.4701,10.8203);
	SetPlayerHealth(playerid, 100);

	
	
}
This part of the code is selecting a random person to be the criminal out of everyone that is online

"Players" is the amount of people online which is done through Players++ and Players-- when user connects and disconnects



After that I will have to check if that player id is in the game and reselect a new random ID, I feel like I am over complicating things but it's the only way I could of
Reply
#2

Forgot to mention, I have new iscrim[MAX_PLAYERS]; at the top of the page
Reply
#3

Before executing this public you should do somethong like this:
PHP код:
for(new i=0;i<MAX_PLAYERS;i++)
{
iscrim[i]=0;
}
if(
Players>0)
{
new 
setcrim=0,cridrandom;
while()
{
cridrandom=random(Players);
if(
IsPlayerConnected(cridrandom))
{
iscrim[cridrandom]=1;
break;
}
}

than in public change
PHP код:
if(iscrim == 1){
to
if(iscrim[playerid] == 1){

and 
delete
iscrim
[Players] = 1
And it should work .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)