Genuine Confusion
#1

I am genuinely baffled about how I'd go about doing this in my code, I have the code below, for displaying a dialog for the cars the player owns:

Код:
VehicleMenu(playerid)
{
	new str[500], cars = 0;
	for(new i = 0; i < sizeof(vInfo); i++)
	{
	    if(vInfo[i][vOwnerID] == pInfo[playerid][ID])
	    {
	        if(IsAnyPlayerInVehicle(vInfo[i][vCarID]) == 1) format(str, sizeof(str), "%s\n(%d): %s (In Use)", str, cars, vInfo[i][vName]);
	        else format(str, sizeof(str), "%s\n(%d): %s", str, cars, vInfo[i][vName]);
	        cars++;
	    }
	}
	if(cars == 0) SPD(playerid, dCars, DSM, "Vehicles", "You currently own no cars!", "Close", "");
	else SPD(playerid, dCars, DSL, "Vehicles", str, "Close", "");
}
(Apologies for any problems with indentation shown here, just because I copied it from my code.)

The issue I'm having, is not a 'code' syntax issue per se, I'm trying to reference each vehicle, but the problem I have, is that the player can own a LOT of vehicles (in excess of 10-20, even up to 100) the vehicles display fine on the menu from my knowledge on the matter, but because it's all procedural, how would I go about referencing any list items here? since I have no solid ones, but since all the basic formatting would be identical, would I do something like this?

Код:
switch(listitem)
{
    case 1..100:
    {
        // Code here
    }
}
I'm not entirely sure, I just need some guidance here.

The second question I have, is actually to do with the vehicles themselves, if that switch method IS the right way, how on Earth do I go about referencing the correct vehicle? This is my vehicle enumerator:

Код:
enum vData
{
	vID, // The vehicle ID ingame for reference in the script
	vCarID, // The vehicle ID ingame for reference in the script
	vModel, // The vehicle's model
	vName[60], // The vehicle's name
	vOwner[24], // Who owns the vehicle?
	vOwnerID, // What's the ID of the owner?
	Float:vLoc[4], // The 4 positions of the vehicle (X Y Z A)
	vCol1, // Car color 1
	vCol2, // Car color 2
	Text3D:vtextid,
	bool:vLocked
}
new vInfo[MAX_VEHICLES][vData]; // Variable for referencing the enumerator above
I would normally loop through all the vehicles until I found the one that matched the vehicle the player was in, and make sure they owned it, since the player has to be in the vehicle to do most other commands, but for this command, I can't really do that, since the player is rarely going to be in the cars they're looking at on the list, and the player can own multiple cars, the vID is more for the mysql database to uniquely reference each vehicle, and don't represent the vehicle ID for the player, and thus, I don't know how I'd go about doing this.

Now, don't get me wrong here. I don't want it done for me, not in the slightest, I just want some guidance.

Any help would be handy,
Thanks,
Zonoya.
Reply


Messages In This Thread
Genuine Confusion - by Zonoya - 30.08.2015, 18:23
Re: Genuine Confusion - by Zonoya - 31.08.2015, 17:20
Re: Genuine Confusion - by Marricio - 31.08.2015, 17:53
Re: Genuine Confusion - by Zonoya - 31.08.2015, 18:05
Re: Genuine Confusion - by Marricio - 31.08.2015, 18:12
Re: Genuine Confusion - by Zonoya - 31.08.2015, 18:14

Forum Jump:


Users browsing this thread: 1 Guest(s)