Vehicle list won't show
#1

Hey all,

So I was working on a /vehicles command which shows you all the vehicles you own, but when I had bought the vehicle and used the command it said that my character doesn't own any vehicles, yet I'm sure I did everything right, someone mind showing me what I did wrong and why I did it wrong?

Code:
pawn Код:
CMD:vehicles(playerid, params[])
{
    new bool:found = false, list[512];
    list = "ID\tVehicle\tNumber Plate\n";
   
    for (new i = 0; i < MAX_VEHICLES; i++)
    {
        if(PlayerVehicle[v][pvStatus] == 1)
        {
            if (!strcmp(PlayerVehicle[i][pvOwner], owner, true)) {
                found = true;
                format(list, sizeof(list), "%s%d\t%s\t%s\n", list, v, GetVehicleName(v), PlayerVehicle[v][pvPlate]);
            }
        }
    }
    if(found == true) return ShowPlayerDialog(playerid, DIALOG_MYVEHICLES, DIALOG_STYLE_TABLIST_HEADERS, "Vehicles", list, "Select", "Close");
    else return ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "Vehicles", "{FF0000}No vehicles found!", "Close", "");
}
Reply
#2

Where does "owner" come from in
Код:
if (!strcmp(PlayerVehicle[i][pvOwner], owner, true))
After looking closer at this, you must have either been very tired or copied this from another part of the same or different script.
Код:
if(PlayerVehicle[v][pvStatus] == 1)
should hopefully be "i" instead of "v"? Or is there code I am simply not seeing? : x
Reply
#3

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Where does "owner" come from in
Код:
if (!strcmp(PlayerVehicle[i][pvOwner], owner, true))
After looking closer at this, you must have either been very tired or copied this from another part of the same or different script.
Код:
if(PlayerVehicle[v][pvStatus] == 1)
should hopefully be "i" instead of "v"? Or is there code I am simply not seeing? : x
The "owner" was meant to be a "GetPlayerName(playerid)", I had changed it a little before going straight back to all the other stuff. And the "v" was meant to be a "i", and I'm not sure how I did it, it just came to mind, that or I was half alseep when creating it, how should it really be? Cause I think I tried if(PlayerVehicle[i][pvStatus]) continue;
Reply
#4

Well firstly, what is pvStatus?
Reply
#5

pvStatus is just a thing that will check if the vehicle is in use, so like pvCarID will contain the CreateVehicle on creation and keep the car ID in it, then the pvStatus is to be so when it checks, it checks that vehicle ID is in use, so basically checking if it's being used in the server.
Reply
#6

Код:
CMD:vehicles(playerid, params[])
{
	new bool:found = false, list[512];
	list = "ID\tVehicle\tNumber Plate\n";
	
	new owner[MAX_PLAYER_NAME];
	GetPlayerName(playerid, owner, MAX_PLAYER_NAME);
	
	for (new i = 0; i < MAX_VEHICLES; i++)
	{
	    if(PlayerVehicle[i][pvStatus] && !strcmp(PlayerVehicle[i][pvOwner], owner, true))
	    {
			found = true;
    		format(list, sizeof(list), "%s%d\t%s\t%s\n", list, i, GetVehicleName(i), PlayerVehicle[i][pvPlate]);
		}
	}
	if(found == true) return ShowPlayerDialog(playerid, DIALOG_MYVEHICLES, DIALOG_STYLE_TABLIST_HEADERS, "Vehicles", list, "Select", "Close");
	else return ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "Vehicles", "{FF0000}No vehicles found!", "Close", "");
}
Try this.
Reply
#7

Just tried it, but now, if I do have vehicles, it won't show the dialog, just shows no dialog nor any text or anything
Reply
#8

I have an idea of what it might be, but run this and SS/copy the console result:
Код:
CMD:vehicles(playerid, params[])
{
	new bool:found = false, list[512];
	list = "ID\tVehicle\tNumber Plate\n";
	
	new owner[MAX_PLAYER_NAME];
	GetPlayerName(playerid, owner, MAX_PLAYER_NAME);
	printf("Starting debugging...");
	for (new i = 0; i < MAX_VEHICLES; i++)
	{
	    if(PlayerVehicle[i][pvStatus] && !strcmp(PlayerVehicle[i][pvOwner], owner))
	    {
	    	printf("Listing vehicleid %i", i);
			found = true;
    		format(list, sizeof(list), "%s%d\t%s\t%s\n", list, i, GetVehicleName(i), PlayerVehicle[i][pvPlate]);
		}
	}

	if(found == true) 
	{
		printf("About to post: %s", list);
		return ShowPlayerDialog(playerid, DIALOG_MYVEHICLES, DIALOG_STYLE_TABLIST_HEADERS, "Vehicles", list, "Select", "Close");
	}
	else 
	{
		printf("No vehicles were found.");
		return ShowPlayerDialog(playerid, 9999, DIALOG_STYLE_MSGBOX, "Vehicles", "{FF0000}No vehicles found!", "Close", "");
	}
}
Reply
#9

All it shows is the starting the debugging, nothing else:

http://i.imgur.com/u7yFugw.png
Reply
#10

Good so now we know that "PlayerVehicle[i][pvStatus]" is actually 0 / false. When you buy a vehicle, check so that it will be set to 1. Also make sure that "PlayerVehicle[i][pvOwner]" is actually assigned the correct value.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)