SA-MP Forums Archive
This command won't return if the player doesn't have vehicles. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: This command won't return if the player doesn't have vehicles. (/showthread.php?tid=501390)



This command won't return if the player doesn't have vehicles. - Dokins - 17.03.2014

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?


Re: This command won't return if the player doesn't have vehicles. - Calabresi - 17.03.2014

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


Re: This command won't return if the player doesn't have vehicles. - Dokins - 17.03.2014

Says server did not recognize command.


Re: This command won't return if the player doesn't have vehicles. - Calabresi - 17.03.2014

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


Re: This command won't return if the player doesn't have vehicles. - iZN - 17.03.2014

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;
}



Re: This command won't return if the player doesn't have vehicles. - Calabresi - 17.03.2014

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.


Re: This command won't return if the player doesn't have vehicles. - Dokins - 17.03.2014

Yeah It needs to count!


Re: This command won't return if the player doesn't have vehicles. - iZN - 17.03.2014

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;
}



Re: This command won't return if the player doesn't have vehicles. - Dokins - 17.03.2014

AHHH! For some reason this worked now! Thank you!


Re: This command won't return if the player doesn't have vehicles. - iZN - 17.03.2014

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.