problem with a stock
#1

Код:
CMD:rentvehicle(playerid, params[])
{
	new vehicleid, string[256], string2[256], dialog[500];
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
	if(PlayerInfo[playerid][pCash] < 30000) return SendClientMessage(playerid, COLOR_WHITE, "Nu ai suma necesara de bani. (30.000$)");
	if(IsPlayerInVehicle(playerid, vehicleid)) return SendClientMessage(playerid, COLOR_WHITE, "Nu poti inchiria un vehicul atat timp cat tu te afli intr-o masina.");
	if(!IsPlayerInRangeOfPoint(playerid, 10.0, -2240.7644,539.0970,35.1488)) return SendClientMessage(playerid, COLOR_WHITE, "Nu te afli in locatia corecta.");
	format(string, sizeof(string), "Vehicle\tIn Stock\n\n%s\t30\n", VehiculeRent(i));
	strcat(string, dialog);
	
	ShowPlayerDialog(playerid, DIALOG_RENTCAR, DIALOG_STYLE_TABLIST_HEADERS, "RentCar", string2, "Select", "Cancel");

	return 1;
}

stock VehiculeRent(id){
	new string[256];
	switch(id){
		case 0: string = "Infernus";
		case 1: string = "Sultan";
		case 2: string = "Bravura";
		case 3: string = "Perenial";
	}
	return string;
}
D:\server\gamemodes\ExtremeGame.pwn(2557 : error 017: undefined symbol "id"
error line: format(string, sizeof(string), "Vehicle\tIn Stock\n\n%s\t30\n", VehiculeRent(i));

why does it give a error in case the VehiculeRent is a stock?
Reply
#2

You're passing the i variable to the VehiculeRent function but i isn't defined anywhere.

I assume you want to pass i from a loop.

PHP код:
format(stringsizeof(string), "Vehicle\tIn Stock\n");
for(new 
i=0;i<MAX_RENTABLE_CARS;i++)
{
     
format(stringsizeof(string), "%s\t30\n"VehiculeRent(i));

I split up the format because you don't want to add Vehicle\tIn Stock every second line, you only want it at the top.
Also, you add everything to the dialog string but you don't pass it to the dialog, so nothing will show up.
Also, you didn't even add anything to string2 and you're passing it but it's empty, so nothing will show up again.

PHP код:
ShowPlayerDialog(playeridDIALOG_RENTCARDIALOG_STYLE_TABLIST_HEADERS"RentCar"string"Select""Cancel"); 
You don't need string2[256] and dialog[500] as you don't use them. And the line with strcat isn't used as well.

And somewhere, outside of the functions, define how many is the max.

PHP код:
#define MAX_RENTABLE_CARS 4 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)