SA-MP Forums Archive
Command v buy problem - 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: Command v buy problem (/showthread.php?tid=390279)



Command v buy problem - MMickey - 05.11.2012

Hy Everyone, I have this command..

Код:
else if(strcmp(x_nr,"buy",true) == 0)
	        {
	            new idx = 250;
	            new coordsstring[256];
	            if(IsASalesVehicle(idcar))
	            {
					if(IsPlayerInVehicle(playerid, idcar))
					{
		                if(PlayerInfo[playerid][pLevel] < 4)
				    	{
	                    	SendClientMessage(playerid, COLOR_GREY, "You need to be level 4 to buy a vehicle!");
	                    	return 1;
				    	}
				    	if(PlayerInfo[playerid][pPcarkey] == 999 || PlayerInfo[playerid][pPcarkey2] == 999 || PlayerInfo[playerid][pPcarkey3] == 999) { }
				    	else return SendClientMessage(playerid, COLOR_GREY,"* You already own 3 cars!");
						if(GetPlayerMoney(playerid) >= GetVehiclePrice(idcar))
						{
						    if(PlayerInfo[playerid][pCarLic] == 1)
						    {
								new File: file2 = fopen("cfg/cars.cfg", io_read);
								for(new h = 250; h < sizeof(CarInfo); h++)
								{
									if(CarInfo[h][cOwned] == 0)
									{
										idx = h;
										h = 9999;
									}
								}
								if(PlayerInfo[playerid][pPcarkey] != 999 && PlayerInfo[playerid][pPcarkey2] == 999) { PlayerInfo[playerid][pPcarkey2] = idx; }
								else if(PlayerInfo[playerid][pPcarkey] != 999 && PlayerInfo[playerid][pPcarkey2] != 999){ PlayerInfo[playerid][pPcarkey3] = idx; } else { PlayerInfo[playerid][pPcarkey] = idx; }
								CarInfo[idx][cOwned] = 1;
								strmid(CarInfo[idx][cOwner], sendername, 0, strlen(sendername), 999);
								SafeGivePlayerMoney(playerid,-GetVehiclePrice(idcar));
								if(IsModelAPlane(idcar) || IsModelAHeli(idcar))
								{
									CarInfo[idx][cLocationx] = 1432.6451;
									CarInfo[idx][cLocationy] = 1378.7216;
									CarInfo[idx][cLocationz] = 11.5507;
									CarInfo[idx][cAngle] = 359.2072;
									SendClientMessage(playerid, COLOR_YELLOW2, "Your Aircraft has been deliveried to Las Venturas Airport, you can get it there!");
									SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
									SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
									GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~Las Venturas Airport!", 5000, 3);
								}
								else if(IsModelABoat(idcar))
								{
								    CarInfo[idx][cLocationx] = -1568.9614;
									CarInfo[idx][cLocationy] = 169.0118;
									CarInfo[idx][cLocationz] = -0.6016;
									CarInfo[idx][cAngle] = 208.7506;
									SendClientMessage(playerid, COLOR_YELLOW2, "Your Boat has been deliveried to San Fierro Docks, you can get it there!");
									SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
									SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
									GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~San Fierro Docks!", 5000, 3);
								}
								else
								{
	                                CarInfo[idx][cLocationx] = -1589.2644;
									CarInfo[idx][cLocationy] = 106.9119;
									CarInfo[idx][cLocationz] = 3.5495;
									CarInfo[idx][cAngle] = 317.1649;
									SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle has been deliveried to San Fierro Docks, you can get it there!");
									SendClientMessage(playerid, COLOR_YELLOW2, "Your vehicle is unlocked so you can pay someone to deliver it to your new spawn point!");
									SendClientMessage(playerid, COLOR_NICERED, "REMEMBER: Leaving your car in the deliver point can get your car SOLD by an administration without refund!");
									GameTextForPlayer(playerid, "~p~Congratulations~n~~w~Don't forget to pickup your car at the ~b~San Fierro Docks!", 5000, 3);
								}
        						format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d\n",
								CarInfo[idx][cModel],
								CarInfo[idx][cLocationx],
								CarInfo[idx][cLocationy],
								CarInfo[idx][cLocationz],
								CarInfo[idx][cAngle],
								CarInfo[idx][cColorOne],
								CarInfo[idx][cColorTwo]);
								if(idx == 0)
								{
									file2 = fopen("cfg/cars.cfg", io_write);
								}
								else
								{
									file2 = fopen("cfg/cars.cfg", io_append);
								}
								fwrite(file2, coordsstring);
								idx++;

								DestroyVehicle(idx);
								ownedcar[idx] = CreateVehicle(CarInfo[idx][cModel],CarInfo[idx][cLocationx],CarInfo[idx][cLocationy],CarInfo[idx][cLocationz],90.0,1,1,30000);
								PlayerPlayMusic(playerid);
								SendClientMessage(playerid, COLOR_GRAD2, "Congratulations on your new purchase!");
								SendClientMessage(playerid, COLOR_GRAD2, "Type /vehiclehelp to view the vehicle manual!");
								gEngine[playerid] = 0;
								engineOn[GetPlayerVehicleID(playerid)] = false;
								RemovePlayerFromVehicle(playerid);
								DateProp(playerid);
								OnPropUpdate();
								OnPlayerUpdate(playerid);
								fclose(file2);
							}
							else
							{
								SendClientMessage(playerid, COLOR_WHITE, "* For security reasons, a Driving License is needed to buy a car!");
								return 1;
							}
						}
						else
						{
						    SendClientMessage(playerid, COLOR_GREY, "  You don't have enough cash with you ! ");
						    return 1;
						}
					}
					else
					{
					//do nothing
					}
	            }
	        }
that gives me..one warning 219, no errors..and ..ingame, i set a Car to: IsASalesVehicle..and i put the id 250, the first id, and is not create me the "ownedcar[idx] = ..." with the new coordonates ..i've setted..So..where-s the problem..? Replay me in english, romanian, german, or spanish..please..


Re: Command v buy problem - Stu1 - 05.11.2012

What is the warning and the line?


Re: Command v buy problem - MMickey - 05.11.2012

warning 219: local variable "idx" shadows a variable at a preceding level
at
Код:
new idx = 250;
but i delete the line..and is a full compilation..no errors, no warnings..and ingame is not create any car...


Re: Command v buy problem - thefatshizms - 05.11.2012

You can solve this by simply renaming idx to something else.


Re: Command v buy problem - MMickey - 05.11.2012

i know that..I solved that warning anyway..but that does not disturbed me..i want ..ingame to create a new car..with a new coordonates..and the car is not created


Re: Command v buy problem - MMickey - 06.11.2012

up please..


Re: Command v buy problem - MMickey - 07.11.2012

up...


Re: Command v buy problem - MMickey - 10.11.2012

can someone..read this topic..?