SA-MP Forums Archive
Little car system 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Little car system problem... (/showthread.php?tid=242203)



Car spawning problem... - Type-R - 19.03.2011

Hey everybody, so i decided to create a little car system so, that everybody could spawn a car, and that when you spawn a second one the first one would dissapear. The bug is that the first car doesn't disappear and theres somekind of magic... When you are sitting in somekind of car and spawn a car, and then go outside and spawn a second car then the first one dissapears... Heres the code:

Код:
COMMAND:masina(playerid, params[])
{
  new masinosmodelis = GetVehicleModel(playerid);
  new masinosid	= GetPlayerVehicleID(playerid);
  new Float:x, Float:y, Float:z, Float:a;
  new zaidejofailas[100], vardas[MAX_PLAYER_NAME];
  GetPlayerName(playerid, vardas, sizeof(vardas));
  format(zaidejofailas, sizeof(zaidejofailas), "FR/Saskaitos/%s.ini",vardas); // opening the player file
  if(ALygis[playerid] >= 2)
  {
  	if(sscanf(params,"d",masinosmodelis)) // if player does not type in ID
  	{
    	SendClientMessage(playerid,orandzine,"{FBDF89}[FunZoneLT]>> /masina [masinosid]");
  	}
  	else if(masinosmodelis < 400 || masinosmodelis > 611) // if player typed in to low or to high id
  	{
    	SendClientMessage(playerid,raudona,"[FunZoneLT]>> Masinos ID negali buti mazesnis nei 400 ar didesnis nei 611.");
  	}
  	else if(IsPlayerInAnyVehicle(playerid) == 1)
  	{
  	    DestroyVehicle(dini_Int(zaidejofailas, "Smasina"));// destroying the last car the player created
            SetVehicleToRespawn(masinosid);
    	    GetPlayerFacingAngle(playerid, a);
    	    GetPlayerPos(playerid, x, y, z);
   	    GetXYInFrontOfPlayer(playerid, x, y, 8);
   	    new i = GetPlayerInterior(playerid);
	    new v = CreateVehicle(masinosmodelis, x, y, z, a+90, -1, -1, 0);
	    LinkVehicleToInterior(v, i);
	    PutPlayerInVehicle(playerid, v, 0);
	    dini_IntSet(zaidejofailas, "Smasina", masinosid);// sets the cars ID that the player just created, so it could be destroyed
    }
    else
	{
	       DestroyVehicle(dini_Int(zaidejofailas, "Smasina"));// destroying the last car the player created
 		GetPlayerFacingAngle(playerid, a);
    	        GetPlayerPos(playerid, x, y, z);
   		GetXYInFrontOfPlayer(playerid, x, y, 8);
   		new i = GetPlayerInterior(playerid);
		new v = CreateVehicle(masinosmodelis, x, y, z, a+90, -1, -1, 0);
		LinkVehicleToInterior(v, i);
		PutPlayerInVehicle(playerid, v, 0);
		dini_IntSet(zaidejofailas, "Smasina", masinosid);// sets the cars ID that the player just created, so it could be destroyed
    }
    new string[100];
    format(string, sizeof(string), "{FBDF89}[FunZoneLT]>> Masina ID: %d, buvo ismesta.", masinosmodelis);
    SendClientMessage(playerid, COLOR_LIMEGREEN, string);
  }
  else
  {
    SendClientMessage(playerid,raudona,"[FunZoneLT]>> Jus negalite naudoti sitos komandos.");
  }
  return 1;
}
Any suggestions?