Dealership car limit
#1

I got to ask something, how I do to limit personal cars in dealership for example 3 cars per model, and when is 0 and somebody wants to buy it to say something like: "No cars from this model left"
Sorry for my bad english.

Код:
 	if(strcmp(cmd, "/buyveh", true) == 0)
 	{
	if(PlayerData[playerid][pLevel] < 2)
	{
	SendClientMessage(playerid,COLOR_WHITE,"Ai nevoie de minim level 2 pentru a cumpara masina!");
	return 1;
	}
	//return SendClientMessage(playerid, COLOR_WHITE, "disabled..");
	if(PlayerData[playerid][pPcarkey] != 999 && PlayerData[playerid][pPcarkey2] != 999 && PlayerData[playerid][pPcarkey3] != 999) return SendClientMessage(playerid, COLOR_GREY, "Nu mai poti cumpara alt vehicul.");
		if(IsPlayerInRangeOfPoint(playerid, 5.0, 1164.1460,-1766.5313,843.5234))
			{

ShowPlayerDialog(playerid, 140, DIALOG_STYLE_LIST, "Masini personale:", "Masini Normale\nMasini Sport\nScutere/Motociclete\nBarci/Elicoptere", "Alege", "Anulare");
	}else{

	SendClientMessage(playerid,COLOR_WHITE,"Nu esti la dealership!");
	}
	return 1;
	
}
Код:
			       switch(listitem)
            {
		  case 0:
                {
	ShowPlayerDialog(playerid, 141, DIALOG_STYLE_LIST, "Masini Normale:", "Phoenix-1.500.000\nPremier-1.200.000\nClub-1.300.000\nStallion-1.300.000\nFlash-2.850.000\nBlade-1.550.000\nSlamvan-1.400.000\nSabre-1.700.000\nAdmiral-1.250.000\nLandstalker-1.500.000", "Cumpara", "Anulare");
			  	}
					  case 1:
    			 {
	new text[500];
	format(text, sizeof(text),"Uranus-2.500.000\nEuros-1.400.000\nFeltzer-15.000.000\nWindsor-5.000.000\nHuntley-3.500.000\nSandking-3.500.000\nRancher-2.200.000\nBanshee-7.000.000\nBuffalo-6.500.000\nSultan-4.750.000\nElegy-4.200.000\nAlpha-3.400.000\nBullet-9.800.000\nInfernus-12.000.000\nTurismo-8.750.000\nCheetah-7.500.000\nZR 350-4.300.000\nSuper GT-4.450.000\nJester-5.300.000");
	ShowPlayerDialog(playerid,142,DIALOG_STYLE_LIST, "Masini Sport", text, "Cumpara","Anulare");
	 
	 }
	case 2:
                {
	ShowPlayerDialog(playerid, 143, DIALOG_STYLE_LIST, "Motoare/Scutere:", "FCR-900 -2.000.000\nFreeway-1.500.000\nNRG-500 -10.000.000\nFaggio-250.000\nPCJ-600-1.500.000", "Cumpara", "Anulare");
				}
		 case 3:
	            {
	ShowPlayerDialog(playerid, 144, DIALOG_STYLE_LIST, "Elicoptere/Barci:", "Maverick-20.000.000\nSparrow-15.000.000\nDodo-5.000.000\nSquallo-3.000.000\nSpeeder-5.000.000", "Cumpara", "Anulare");
				}
		
		}
	
		
		}
		
		if((dialogid == 141)||(dialogid == 142)||(dialogid == 143)||(dialogid == 144))
		{
					    if(!response)
            {
                SendClientMessage(playerid, 0xFF0000FF, "Ai anulat.");
                return 1; // We processed it
            }
		if(dialogid == 141)
		{
	if(PlayerData[playerid][pPcarkey] != 999)
	{
	  SendClientMessage(playerid, 0xFF0000FF, "Ai deja o masina personala.");
                return 1; // We processed it
	}
	
          switch(listitem)
            {

				case 0:
                {
				VehDSmod[playerid]=603;
				VehDSpret[playerid]=1500000;
                }

				case 1:
                {
				VehDSmod[playerid]=426;
				VehDSpret[playerid]=1200000;
                }

				case 2:
                {
				VehDSmod[playerid]=589;
				VehDSpret[playerid]=1300000;
                }
				case 3:
                {
				VehDSmod[playerid]=439;
				VehDSpret[playerid]=1300000;
                }

				case 4:
                {
				VehDSmod[playerid]=565;
				VehDSpret[playerid]=2850000;
                }

       		  	case 5:
                {
				VehDSmod[playerid]=536;
				VehDSpret[playerid]=1550000;
                }

				case 6:
                {
				VehDSmod[playerid]=535;
				VehDSpret[playerid]=1400000;
                }

				case 7:
                {
				VehDSmod[playerid]=475;
				VehDSpret[playerid]=1700000;
                }
				case 8:
                {
				VehDSmod[playerid]=445;
				VehDSpret[playerid]=1250000;
                }
				case 9:
                {
				VehDSmod[playerid]=400;
				VehDSpret[playerid]=1500000;
                }
				}
				}
				else if(dialogid == 142)
	{
					if(PlayerData[playerid][pPcarkey] != 999)
	{
	  SendClientMessage(playerid, 0xFF0000FF, "Ai deja o masina personala.");
                return 1; // We processed it
	}
		if(PlayerData[playerid][pPcarkey] != 999)
	{
	  SendClientMessage(playerid, 0xFF0000FF, "Ai deja o masina personala.");
                return 1; // We processed it
	}
				         switch(listitem)
				{
				case 0:
                {
				VehDSmod[playerid]=558;
				VehDSpret[playerid]=2500000;
                }


				case 1:
                {
				VehDSmod[playerid]=587;
				VehDSpret[playerid]=1400000;
                }
			    case 2:
                {
				VehDSmod[playerid]=533;
				VehDSpret[playerid]=15000000;
                }
				case 3:
                {
				VehDSmod[playerid]=555;
				VehDSpret[playerid]=5000000;
                }
				case 4:
                {
				VehDSmod[playerid]=579;
				VehDSpret[playerid]=3500000;
                }

				case 5:
                {
				VehDSmod[playerid]=495;
				VehDSpret[playerid]=3500000;
                }
				case 6:
                {
				VehDSmod[playerid]=489;
				VehDSpret[playerid]=2200000;
                }
				case 7:
                {
				VehDSmod[playerid]=429;
				VehDSpret[playerid]=7000000;
                }
				case 8:
                {
				VehDSmod[playerid]=402;
				VehDSpret[playerid]=6500000;
                }
				case 9:
                {
				VehDSmod[playerid]=560;
				VehDSpret[playerid]=4750000;
                }


				case 10:
                {
				VehDSmod[playerid]=562;
				VehDSpret[playerid]=4200000;
                }


				case 11:
                {
				VehDSmod[playerid]=602;
				VehDSpret[playerid]=3400000;
                }


				 case 12:
                {
				VehDSmod[playerid]=541;
				VehDSpret[playerid]=9800000;
                }


				 case 13:
                {
				VehDSmod[playerid]=411;
				VehDSpret[playerid]=12000000;
                }


				 case 14:
                {
				VehDSmod[playerid]=451;
				VehDSpret[playerid]=8750000;
                }


				 case 15:
                {
				VehDSmod[playerid]=415;
				VehDSpret[playerid]=7500000;
                }


				 case 16:
                {
				VehDSmod[playerid]=477;
				VehDSpret[playerid]=4300000;
                }


				 case 17:
                {
				VehDSmod[playerid]=506;
				VehDSpret[playerid]=4450000;
                }


				 case 18:
                {
				VehDSmod[playerid]=559;
				VehDSpret[playerid]=5300000;
                }
}
}
			else if(dialogid == 143)
		{
	if(PlayerData[playerid][pPcarkey2] != 999)
	{
	  SendClientMessage(playerid, 0xFF0000FF, "Ai deja o motoclicleta personala.");
                return 1; // We processed it
	}
						         switch(listitem)
            {				
				 case 0:
                {
				VehDSmod[playerid]=521;
				VehDSpret[playerid]=2000000;
                }
				case 1:
                {
				VehDSmod[playerid]=463;
				VehDSpret[playerid]=1500000;
                }
				case 2:
                {
				VehDSmod[playerid]=522;
				VehDSpret[playerid]=10000000;
				
                }
				case 3:
                {
					VehDSmod[playerid]=462;
				VehDSpret[playerid]=1500000;
                }
				case 4:
                {
					VehDSmod[playerid]=461;
				VehDSpret[playerid]=700000;
                }
		
				}
		
		
		}
	    else if(dialogid == 144)
		{
			if(PlayerData[playerid][pPcarkey3] != 999)
	{
	  SendClientMessage(playerid, 0xFF0000FF, "Ai deja un avion sau barca personala.");
                return 1; // We processed it
	}
						         switch(listitem)
            {
			 case 0:
                {
				VehDSmod[playerid]=487; //heli
				VehDSpret[playerid]=20000000;
                }
				 case 1:
                {
				VehDSmod[playerid]=469; //heli
				VehDSpret[playerid]= 20000000;
                }
			 	case 2:
                {
				VehDSmod[playerid]=593; //avion
				VehDSpret[playerid]= 5000000;
                }
				 case 3:
                {
				VehDSmod[playerid]=446;
				VehDSpret[playerid]= 3000000;
                }
				 case 4:
                {
				VehDSmod[playerid]=452;
				VehDSpret[playerid]= 5000000;
                }
				
				}
		
		
		}
				
			if(GetPlayerCash(playerid) > VehDSpret[playerid])
			{
	
		
	
	
			new string[512];

 				      
                        new idd;
						mysql_query("SELECT * FROM `cars`");
						mysql_store_result();
						idd = mysql_num_rows()+1;
						mysql_free_result();
	
      				  format(string, sizeof(string), "%s",ArIsim[VehDSmod[playerid]-400]);
						strmid(CarData[idd][cDescription], string, 0, strlen(string), 255);
			GetPlayerName(playerid, sendername, sizeof(sendername));
				strmid(CarData[idd][cOwner], sendername, 0, strlen(sendername), 999);
					  if(dialogid == 141)
		{
				         CarData[idd][cModel] = VehDSmod[playerid];
				        CarData[idd][cValue] = VehDSpret[playerid];
				        CarData[idd][cLocationx] = 1098.2990+random(5);
						CarData[idd][cLocationy] = -1755.0093+random(5);
						CarData[idd][cLocationz] = 13.1915+random(1);
				
						}
						  if(dialogid == 142)
		{
				         CarData[idd][cModel] = VehDSmod[playerid];
				        CarData[idd][cValue] = VehDSpret[playerid];
				        CarData[idd][cLocationx] = 1083.6465+random(5);
						CarData[idd][cLocationy] = -1757.9275+random(5);
						CarData[idd][cLocationz] = 12.9471+random(1);
						
						}
						  if(dialogid == 143)
		{
				         CarData[idd][cModel] = VehDSmod[playerid];
				        CarData[idd][cValue] = VehDSpret[playerid];
				        CarData[idd][cLocationx] = 1063.0447+random(2);
						CarData[idd][cLocationy] = -1740.2365+random(3);
						CarData[idd][cLocationz] = 13.0338+random(1);
					
						}
					 if(dialogid == 144)
		{
		 CarData[idd][cModel] = VehDSmod[playerid];
		   CarData[idd][cValue] = VehDSpret[playerid];
		if((CarData[idd][cModel]==460) || (CarData[idd][cModel]==452) || (CarData[idd][cModel]==453) || (CarData[idd][cModel]==473) || (CarData[idd][cModel]==446))
		{
				        
  						CarData[idd][cLocationx] = 540.1905+random(30);
						CarData[idd][cLocationy] = -1947.6304+random(30);
						CarData[idd][cLocationz] = 0.5787+random(5);
					
						}else{
						CarData[idd][cLocationx] = 1921.3323+random(50);
						CarData[idd][cLocationy] = -2427.3079+random(50);
						CarData[idd][cLocationz] = 13.7148+random(3);
					
						}
						}
						CarData[idd][cOwned] = 1;
						CarData[idd][cKM] = 0;
				        AddStaticVehicle(CarData[idd][cModel],CarData[idd][cLocationx],CarData[idd][cLocationy],CarData[idd][cLocationz],0,0,0);
						
						format(string, sizeof(string),"INSERT INTO cars (id, Model) VALUES (%d, %d)",  idd, CarData[idd][cModel]);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Locationx='%f' WHERE id=%d", CarData[idd][cLocationx], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Locationy='%f' WHERE id=%d", CarData[idd][cLocationy], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Locationz='%f' WHERE id=%d", CarData[idd][cLocationz], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Angle='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET SaLocationx='%f' WHERE id=%d", CarData[idd][cLocationx], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET SaLocationy='%f' WHERE id=%d", CarData[idd][cLocationy], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET SaLocationz='%f' WHERE id=%d", CarData[idd][cLocationz], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET SaAngle='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET ColorOne='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET ColorTwo='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Description='%s' WHERE id=%d", CarData[idd][cDescription], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Value='%d' WHERE id=%d", CarData[idd][cValue], idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET License='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Owned='1' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Owner='%s' WHERE id=%d", CarData[idd][cOwner], idd);
        				mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Lockk='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Exploded='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Num='SA-Zone' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component00='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component01='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component02='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component03='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component04='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component05='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component06='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component07='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component08='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component09='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component10='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component11='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component12='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET Component13='0' WHERE id=%d", idd);
						mysql_query(string);
						format(string, sizeof(string), "UPDATE cars SET KM='0' WHERE id=%d", idd);
						mysql_query(string);
			  if((dialogid == 141) || (dialogid == 142))
		{
		SwitchKey[playerid] = 1;
		PlayerData[playerid][pPcarkey] = idd;
			        format(string, sizeof(string), "UPDATE players SET Car='%d' WHERE id=%d", PlayerData[playerid][pPcarkey], PlayerData[playerid][pSQLID]);
				mysql_query(string);
				 GivePlayerCash(playerid, - VehDSpret[playerid]);
					SendClientMessage(playerid,COLOR_WHITE,"Ai cumparat o masina, scrie /pozitiemasina pentru a o gasi.");
						}
						    else if(dialogid == 143)
		{
		SwitchKey[playerid] = 2;
		PlayerData[playerid][pPcarkey2] = idd;
				        format(string, sizeof(string), "UPDATE players SET Car2='%d' WHERE id=%d", PlayerData[playerid][pPcarkey2], PlayerData[playerid][pSQLID]);
				mysql_query(string);
				 GivePlayerCash(playerid, - VehDSpret[playerid]);
						SendClientMessage(playerid,COLOR_WHITE,"Ai cumparat un motor/scuter, scrie /pozitiemoto pentru a-l gasi.");
		}
				    else
		{
		SwitchKey[playerid] = 3;
		PlayerData[playerid][pPcarkey3] = idd;
				        format(string, sizeof(string), "UPDATE players SET Car3='%d' WHERE id=%d", PlayerData[playerid][pPcarkey3], PlayerData[playerid][pSQLID]);
				mysql_query(string);
				 GivePlayerCash(playerid, - VehDSpret[playerid]);
						SendClientMessage(playerid,COLOR_WHITE,"Ai cumparat un vehicul, scrie /pozitiebe pentru a-l gasi.");
		}

		}else{
		 SendClientMessage(playerid,COLOR_WHITE,"Nu ai suficienti bani!");
		}
		}
Reply
#2

What script you using? Im guessing your asking to either limit the amount of vehicles a player can have or limit the amount of vehicles in stock of each model...

Join this XMP Dev chat room (no sign up required - Just enter a username) if you want to chat to other programmers/scripters for help - im in there right now
Reply
#3

limit the amount of vehicles in stock of each model...

I dont know what script is in GM.
Reply
#4

Can somebody help me?
Reply
#5

Why do not you define something like
#define MAX_VEHS_PER_DEALERSHIP 10
and use it then?
Also order scipt to get how many cars left and to say you if there are any (true) to give you one, or (false) to send some message to you like " There is no vehs of that model left ".
Reply
#6

Can you make me some steps, but exactly what to do
Reply
#7

NOBODY?
Reply
#8

define hcount of max veh models per dealership
order a script to -1 per that veh model buyout.
make a script to send client message to player when theres no veh models left in that dealership
Reply
#9

I asked you to explain me, I am a newbie.
Reply
#10

Quote:
Originally Posted by TheWay
Посмотреть сообщение
I asked you to explain me, I am a newbie.
I explaned as much as I can, nobody won't script for free.
One more time, but now use SAMP wiki to see about what I am talking and you will learn.
Define max number of one veh model
order script to count down when someone buy veh
when script reach 0 veh models, onplayercommandtext sendclientmessage that theres no more vehs of that model left
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)