This command won't return if the player doesn't have vehicles.
#1

pawn Код:
CMD:myvehicles(playerid, params[])//NEEDS REWRITE
{
    new string[512], name1, am = 0;
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        if(VehOwner[v] == PlayerSQLID[playerid])
        {
            am ++;
            printf("CHECKING IF VEHOWNER");
            name1 = GetVehicleModel(v) - 400;
            printf("VehMODEL %d", VehModel[v]);
            format(string, sizeof(string), "{FFFFFF}%s{FFFFFF}%s - {FFFFFF}ID({33AA33}%d{FFFFFF}) - Plate: {33AA33}%s\n",string, VehicleNames[name1], v, VehPlate[v]);
            printf("%s");
        }

    }
    if(am < 1)return SendClientMessage(playerid, COLOUR_GREY, "You do not own any vehicles");
    ShowPlayerDialog(playerid,DIALOG_SHOWCAR,DIALOG_STYLE_MSGBOX,"My Vehicles", string,"Close","");
    printf("shown dialog");
    return 1;
}
Title says all. I can't seem to get it to work if the player has no vehicles?
Reply
#2

Does it show anything if player has no vehicles, or NO returns at all?
Reply
#3

Says server did not recognize command.
Reply
#4

Then probably your command processor has a problem with that. Have you tried renaming the command?
Reply
#5

Maybe?

pawn Код:
CMD:myvehicles(playerid, params[])//NEEDS REWRITE
{
    new string[512], name1, am = 0;
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(am < 1) return SendClientMessage(playerid, COLOUR_GREY, "You do not own any vehicles");
   
    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        if(VehOwner[v] == PlayerSQLID[playerid])
        {
            am ++;
            printf("CHECKING IF VEHOWNER");
            name1 = GetVehicleModel(v) - 400;
            printf("VehMODEL %d", VehModel[v]);
            format(string, sizeof(string), "{FFFFFF}%s{FFFFFF}%s - {FFFFFF}ID({33AA33}%d{FFFFFF}) - Plate: {33AA33}%s\n",string, VehicleNames[name1], v, VehPlate[v]);
            printf("%s");
        }

    }

    ShowPlayerDialog(playerid,DIALOG_SHOWCAR,DIALOG_STYLE_MSGBOX,"My Vehicles", string,"Close","");
    printf("shown dialog");
    return 1;
}
Reply
#6

Quote:
Originally Posted by iZN
Посмотреть сообщение
Maybe?

pawn Код:
CMD:myvehicles(playerid, params[])//NEEDS REWRITE
{
    new string[512], name1, am = 0;
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(am < 1) return SendClientMessage(playerid, COLOUR_GREY, "You do not own any vehicles");
   
    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        if(VehOwner[v] == PlayerSQLID[playerid])
        {
            am ++;
            printf("CHECKING IF VEHOWNER");
            name1 = GetVehicleModel(v) - 400;
            printf("VehMODEL %d", VehModel[v]);
            format(string, sizeof(string), "{FFFFFF}%s{FFFFFF}%s - {FFFFFF}ID({33AA33}%d{FFFFFF}) - Plate: {33AA33}%s\n",string, VehicleNames[name1], v, VehPlate[v]);
            printf("%s");
        }

    }

    ShowPlayerDialog(playerid,DIALOG_SHOWCAR,DIALOG_STYLE_MSGBOX,"My Vehicles", string,"Close","");
    printf("shown dialog");
    return 1;
}
That will say player has no vehicles EVEN if they have one, since you never let the loop go and count the vehicle count.
Reply
#7

Yeah It needs to count!
Reply
#8

Quote:
Originally Posted by Calabresi
Посмотреть сообщение
That will say player has no vehicles EVEN if they have one, since you never let the loop go and count the vehicle count.
Oh right, I didn't notice that.

pawn Код:
CMD:myvehicles(playerid, params[])//NEEDS REWRITE
{
    new string[512], name1, am = 0;
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command."), true;
   
    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        if(VehOwner[v] == PlayerSQLID[playerid])
        {
            am ++;
            printf("CHECKING IF VEHOWNER");
            name1 = GetVehicleModel(v) - 400;
            printf("VehMODEL %d", VehModel[v]);
            format(string, sizeof(string), "{FFFFFF}%s{FFFFFF}%s - {FFFFFF}ID({33AA33}%d{FFFFFF}) - Plate: {33AA33}%s\n",string, VehicleNames[name1], v, VehPlate[v]);
            printf("%s");
        }

    }
    if(am < 1) return SendClientMessage(playerid, COLOUR_GREY, "You do not own any vehicles"), true;
    ShowPlayerDialog(playerid,DIALOG_SHOWCAR,DIALOG_STYLE_MSGBOX,"My Vehicles", string,"Close","");
    printf("shown dialog");
    return 1;
}
Reply
#9

AHHH! For some reason this worked now! Thank you!
Reply
#10

Quote:
Originally Posted by Dokins
Посмотреть сообщение
AHHH! For some reason this worked now! Thank you!
And I forgot to mention what I've added. Just check that I've returned true at both if statement used to get if the player is admin or the player has no vehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)