error 033: array must be indexed (variable "iscrim") - 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 033: array must be indexed (variable "iscrim") (
/showthread.php?tid=603719)
error 033: array must be indexed (variable "iscrim") -
Dinoo - 26.03.2016
Код:
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
Re: error 033: array must be indexed (variable "iscrim") -
Dinoo - 26.03.2016
Forgot to mention, I have new iscrim[MAX_PLAYERS]; at the top of the page
Re: error 033: array must be indexed (variable "iscrim") -
czerwony03 - 26.03.2016
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
.