Problem Get Player in personal vehicle
#1

When I'm in my personal car it goes but
when in another car it does not work..
Image:
and on the server looks: SERVER: Unknown command.

My Code:

Код HTML:
stock CarOwner3(playerid, vehicleid)
{
	if( CarInfo[PlayerInfo[playerid][pCarPers][0]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][0]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][1]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][1]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][2]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][2]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][3]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][3]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][4]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][4]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][5]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][5]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][6]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][6]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][7]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][7]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][8]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][8]][cSpawn])
	{
	    return 1;
	}
	else if( CarInfo[PlayerInfo[playerid][pCarPers][9]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][9]][cSpawn])
	{
	    return 1;
	}
	return 0;
}



CMD:park(playerid, params[])
{
	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not in your personal vehicle!");
	new getcarid = GetPlayerVehicleID(playerid);
	
	if(IsPlayerConnected(playerid))
	{
		if(CarOwner3(playerid, getcarid)) // checking whether the player is in the personal car
	 	{
	    	PersonalCars(playerid, 2, getcarid); // In personal vehicle
		}
		else
		{
			SCM(playerid, -1, "[Personal Car's]: You are not in your personal vehicle!");
		}
	}
	
	return 1;
}
Reply
#2

Help me
Reply
#3

You're accessing an array with an invalid index, show the line number and the line where the backtracke is showing you.
Reply
#4

Код HTML:
enum pInfo
{
	pCarPers[10]
};

new PlayerInfo[MAX_PLAYERS][pInfo];	


enum cInfo
{
	cID,
	cModel,
	cSpawn
};

new CarInfo[2000][cInfo];
Reply
#5

You can write your hole code like this:

That makes it a lot easier.

Код:
stock CarOwner3(playerid, vehicleid)
{
	for(new i,idx; i<10; i++)
	{
		idx = PlayerInfo[playerid][pCarPers][i];
		if(idx != -1 && vehicleid == CarInfo[idx][cSpawn]) return 1;
	}
	return 0;
}


CMD:park(playerid, params[])
{
	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You are not in your personal vehicle!");
	new getcarid = GetPlayerVehicleID(playerid);
	if(CarOwner3(playerid, getcarid)) // checking whether the player is in the personal car
	{
		PersonalCars(playerid, 2, getcarid); // In personal vehicle
	}
	else
	{
		SCM(playerid, -1, "[Personal Car's]: You are not in your personal vehicle!");
	}
	return 1;
}
Reply
#6

I did well?
To return pcarkey id ( PlayerInfo[playerid][pCarPers][0], PlayerInfo[playerid][pCarPers][1], etc.. )
it is possible for multiple players to have trouble checking?

Код HTML:
stock CarOwner2(playerid, vehicleid)
{
	new CarKeY = 0;
	for(new i = 0; i < 10; i++)
	{
		if(CarInfo[PlayerInfo[playerid][pCarPers][i]][cSpawn] > 0 && vehicleid == CarInfo[PlayerInfo[playerid][pCarPers][i]][cSpawn])
		{
		    CarKeY = PlayerInfo[playerid][pCarPers][i];
	  		break;
		}
	}
	return CarKeY;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)