Faction Cars = Server Log problems
#1

after i made few faction cars it shows me in "server log" BUT ONLY IF I+M TRYING TO GET INTO FACTION CARS

Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 11 past array upper bound 10
[debug] AMX backtrace:
[debug] #0 00096130 in public OnPlayerEnterVehicle (0, 36, 0) from kucni.amx
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 11 past array upper bound 10
[debug] AMX backtrace:
[debug] #0 00096130 in public OnPlayerEnterVehicle (0, 44, 0) from kucni.amx
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	for(new i = 0; i < 12; i++) //Loop.  It counts to 11
	{ //Open Bracket
	    if(vehicleid == GSFcar[i]) //If the vehicleid is an LSPD vehicle
	    { //Open Bracket
	        if(pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
	        { //Open Bracket
	            ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
	            SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
	        } //Closed Bracket
	    } //Closed Bracket
	} //Closed Bracket
Reply
#2

GSFcar likely only goes up to 10, yet you're looping to 11. So change i < 12 down to i < 11.
Reply
#3

Код:
	for(new i = 0; i < 11; i++) //Loop.  It counts to 11
	{
	    if(vehicleid == GSFcar[i]) //If the vehicleid is an LSPD vehicle
	    { 
	        if(pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
	        { 
	            ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
	            SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
	        } 
	    } 
 	for(new i = 0; i < 7; i++) //Loop.  
	{
	    if(vehicleid == Pizzacar[i]) //If the vehicleid 
	    {
	        if(PlayerInfo[i][team] != TEAM_LSDOS)
	        {
         	ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
          	SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //
			}
		}
	}
Much errors... I can't use foreach twice?
Reply
#4

Код:
[debug] #0 000962c4 in public OnPlayerEnterVehicle (0, 215, 0) from kucni.amx
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 7 past array upper bound 6
[debug] AMX backtrace:
[debug] #0 000962c4 in public OnPlayerEnterVehicle (0, 213, 0) from kucni.amx
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 7 past array upper bound 6
[debug] AMX backtrace:
[debug] #0 000962c4 in public OnPlayerEnterVehicle (0, 213, 0) from kucni.amx
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 7 past array upper bound 6
[debug] AMX backtrace:
[debug] #0 000962c4 in public OnPlayerEnterVehicle (0, 213, 0) from kucni.amx
now same.. prolly bcs "pizzacar"
Reply
#5

Don't use numbers like this as it causes more problems in the long run. Use sizeof operator. You also forgot to close a bracket on the first loop.

Код:
for (new i = 0; i < sizeof GSFcar; i++)
{
    if (vehicleid == GSFcar[i]) //If the vehicleid is an LSPD vehicle
    {
        if (pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
        {
            ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
            SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
        }
    }
}

for (new i = 0; i < sizeof Pizzacar; i++)
{
    if (vehicleid == Pizzacar[i]) //If the vehicleid 
    {
        if (PlayerInfo[i][team] != TEAM_LSDOS)
        {
            ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
            SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //
        }
    }
}
Reply
#6

Still I can take other vehicles:

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	for (new i = 0; i < sizeof GSFcar; i++)
	{
    	if (vehicleid == GSFcar[i]) //If the vehicleid is an LSPD vehicle
	    {
        	if (pData[playerid][Faction] != 1) //If the player is not in faction 1 (LSPD, in this case)
        	{
            	ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
            	SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //Sends a message to the player that he cannot enter it.
        	}
    	}
	}
	for (new i = 0; i < sizeof Pizzacar; i++)
	{
	    if (vehicleid == Pizzacar[i]) //If the vehicleid
	    {
   	 		if (PlayerInfo[i][team] != TEAM_LSDOS)
        	{
            	ClearAnimations(playerid); //Clears their animation, preventing them from entering the vehicle.
            	SendClientMessage(playerid, -1, "You don`t have the keys for this car."); //
        	}
    	}
	}
Код:
public OnPlayerRequestClass(playerid, classid) {
    if(IsPlayerNPC(playerid)) return 1;
	SetPlayerClass(playerid, classid);
	switch (classid)
	{
		//-------------------------------
		case 0:
		{
			GameTextForPlayer(playerid, "~r~Pizzaboy", 500, 6);
			SetPlayerInterior(playerid,14);
			SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
			SetPlayerFacingAngle(playerid, 90.0);
			SetPlayerCameraPos(playerid,256.0815,-43.0475,1003.0234);
			SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
			SetPlayerTeam(playerid, TEAM_LSDOS);
		}
Код:
SetPlayerClass(playerid, classid)
{
	switch(classid) {
		case 0:
		{
			SetPlayerTeam(playerid, TEAM_LSDOS);
			PlayerInfo[playerid][team] = TEAM_LSDOS;
		}
Код:
Pizzacar[0] = AddCar(448,2099.1370,-1784.7839,12.9992,351.3911,3,3); // pizzaboy1
Pizzacar[1] = AddCar(448,2103.1619,-1784.9354,12.9936,351.3617,3,3); // pizzaboy2
Pizzacar[2] = AddCar(448,2107.0249,-1784.9683,12.9887,351.8490,3,3); // pizzaboy
Pizzacar[3] = AddCar(448,2111.1370,-1784.7839,12.9992,351.3911,3,3); // pizzaboy1
Pizzacar[4] = AddCar(448,2115.1370,-1784.7839,12.9992,351.3911,3,3); // pizzaboy1
Pizzacar[5] = AddCar(448,2119.1370,-1784.7839,12.9992,351.3911,3,3); // pizzaboy1
Pizzacar[6] = AddCar(448,2123.1370,-1784.7839,12.9992,351.3911,3,3); // pizzaboy1
Reply
#7

+ some of "pizzacars" i can drive, some of them I "dont have keys"

that's really wierd
Reply
#8

Код:
[debug] #0 000986b0 in public OnPlayerEnterVehicle (0, 212, 0) from kucni.amx
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 7 past array upper bound 6
[debug] AMX backtrace:
[debug] #0 000986b0 in public OnPlayerEnterVehicle (0, 212, 0) from kucni.amx
Foreach uploaded, Streamer plugin too....
Reply
#9

I didn't notice this earlier, change this line from the code inside the loop:
pawn Код:
if (PlayerInfo[i][team] != TEAM_LSDOS)
to:
pawn Код:
if (PlayerInfo[playerid][team] != TEAM_LSDOS)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)