PDA

View Full Version : This command won't return if the player doesn't have vehicles.


Dokins
17/03/2014, 09:48 PM
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_ST YLE_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?

Calabresi
17/03/2014, 10:00 PM
Does it show anything if player has no vehicles, or NO returns at all?

Dokins
17/03/2014, 10:01 PM
Says server did not recognize command.

Calabresi
17/03/2014, 10:06 PM
Then probably your command processor has a problem with that. Have you tried renaming the command?

iZN
17/03/2014, 10:12 PM
Maybe?


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_ST YLE_MSGBOX,"My Vehicles", string,"Close","");
printf("shown dialog");
return 1;
}

Calabresi
17/03/2014, 10:14 PM
Maybe?


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_ST YLE_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.

Dokins
17/03/2014, 10:16 PM
Yeah It needs to count!

iZN
17/03/2014, 10:16 PM
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.


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_ST YLE_MSGBOX,"My Vehicles", string,"Close","");
printf("shown dialog");
return 1;
}

Dokins
17/03/2014, 10:24 PM
AHHH! For some reason this worked now! Thank you!

iZN
17/03/2014, 10:30 PM
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.

Dokins
17/03/2014, 11:44 PM
Seriously, thank you very much.