error 033: array must be indexed + Rep
#1

Please help me I have this problem.
error 033: array must be indexed (variable "VehiclePos")
I am trying to make it so when the player buys the vehicle it will spawn it in one the of locations I have set.
Here is my code:
Код:
new Float:Dealership1Pos[2][3] =
	{
	    { 1671.8918,-1072.8073,25.7088 },
	    { 1667.2391,-1124.2771,26.3949 }
	};
Under OnDIalogResponse
Код:
GivePlayerMoney(playerid, -VehicleValue[id]);
			PlayerInfo[playerid][pCash] -= VehicleValue[id];
			format(str, sizeof(str), "MoneyTrace: %s bought a cellphone for $%i", GetName(playerid), VehicleValue[id]);
   			Log("/logs/moneytrace.txt", str);
			new dealerid = strval(VehicleOwner[id]);
            new rand = random(sizeof(Dealership1Pos));
			VehicleCreated[freeid] = VEHICLE_PLAYER;
			VehicleModel[freeid] = VehicleModel[id];
			//VehiclePos[freeid] = DealershipPos[dealerid];
			VehiclePos[freeid] = Dealership1Pos[rand][0], Dealership1Pos[rand][1], Dealership1Pos[rand][2];
			VehicleColor[freeid] = VehicleColor[id];
			VehicleInterior[freeid] = VehicleInterior[id];
			VehicleWorld[freeid] = VehicleWorld[id];
			VehicleValue[freeid] = VehicleValue[id];
			GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));
			VehicleOwner[freeid] = GetPlayerNameEx(playerid);
			VehicleNumberPlate[freeid] = DEFAULT_NUMBER_PLATE;
Reply
#2

pawn Код:
new Float:Dealership1Pos[][3] =
{
    { 1671.8918,-1072.8073,25.7088 },
    { 1667.2391,-1124.2771,26.3949 }
};
I don't think Dealership1Pos[rand][] will give you the correct random location unless you've specified a random number generator somewhere else.
Reply
#3

Tried that exactly the same problem
Reply
#4

Oh, misread your topic, sorry.

Instead of:
pawn Код:
VehiclePos[freeid] = Dealership1Pos[rand][0], Dealership1Pos[rand][1], Dealership1Pos[rand][2];
Do:
pawn Код:
new rand = random(sizeof(Dealership1Pos));
VehiclePos[freeid] = Dealership1Pos[rand][0], Dealership1Pos[rand][1], Dealership1Pos[rand][2];
This will give you a random number correctly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)