Player owned vehicles duplicating..Mhm abit of help here .
#1

Hello , I'm suffering from a problem , Which is causing vehicles to duplicate .. I couldn't find out the bug ..

It's a vehicle storage system .

CMD:
Код:
CMD:vstorage(playerid, params[])
{
	new vstring[1024];
	for(new i, iModelID; i < MAX_PLAYERVEHICLES; i++) {
		if((iModelID = PlayerVehicleInfo[playerid][i][pvModelId] - 400) >= 0) {
			if(PlayerVehicleInfo[playerid][i][pvImpounded]) {
				format(vstring, sizeof(vstring), "%s\n%s (impounded)", vstring, VehicleName[iModelID]);
			}
			else if(PlayerVehicleInfo[playerid][i][pvDisabled]) {
				format(vstring, sizeof(vstring), "%s\n%s (disabled)", vstring, VehicleName[iModelID]);
			}
			else if(!PlayerVehicleInfo[playerid][i][pvSpawned]) {
				format(vstring, sizeof(vstring), "%s\n%s (stored)", vstring, VehicleName[iModelID]);
			}
			else format(vstring, sizeof(vstring), "%s\n%s (spawned)", vstring, VehicleName[iModelID]);
		}
		else strcat(vstring, "\nEmpty");
	}
	ShowPlayerDialog(playerid, VSTORAGE, DIALOG_STYLE_LIST, "Vehicle storage", vstring, "(De)spawn", "Cancel");
	return 1;
}
Dialog response
Код:
	if(dialogid == VSTORAGE && response) {
		if(PlayerVehicleInfo[playerid][listitem][pvSpawned])
		{
			new
				Float: vehiclehealth;

			GetVehicleHealth(PlayerVehicleInfo[playerid][listitem][pvId], vehiclehealth);

			if(vehiclehealth < 750)
			{
				SendClientMessage(playerid, COLOR_WHITE, "This vehicle is too damaged to be stored.");
			}
			else {
				--PlayerCars;
				VehicleSpawned[playerid]--;
				PlayerVehicleInfo[playerid][listitem][pvSpawned] = 0;
				DestroyVehicle(PlayerVehicleInfo[playerid][listitem][pvId]);
				//VehicleRadioStation[PlayerVehicleInfo[playerid][listitem][pvId]] = 0;
				PlayerVehicleInfo[playerid][listitem][pvId] = INVALID_PLAYER_VEHICLE_ID;

				new vstring[128];
				format(vstring, sizeof(vstring), "You have stored your %s. The vehicle has been despawned.", VehicleName[PlayerVehicleInfo[playerid][listitem][pvModelId] - 400]);
				SendClientMessage(playerid, COLOR_WHITE, vstring);
			}
		}
		else if(PlayerVehicleInfo[playerid][listitem][pvModelId] == 0) {
			SendClientMessage(playerid, COLOR_WHITE, "You can't spawn an non-existant vehicle.");
		}
		else if(PlayerVehicleInfo[playerid][listitem][pvImpounded]) {
			SendClientMessage(playerid, COLOR_WHITE, "You can't spawn an impounded vehicle. If you wish to reclaim it, do so at the DMV in Dillimore.");
		}
		else if(PlayerVehicleInfo[playerid][listitem][pvDisabled] == 1) {
			SendClientMessage(playerid, COLOR_WHITE, "You can't spawn a disabled vehicle. It is disabled due to your Donator level (vehicle restrictions).");
		}
		else if(PlayerVehicleInfo[playerid][listitem][pvSpawned] == 0) {
			if(PlayerInfo[playerid][pDonateRank] == 0 && VehicleSpawned[playerid] >= 3) {
				SendClientMessage(playerid, COLOR_GREY, "As non-VIP you can only have 3 vehicle spawned. You must store a vehicle in order to spawn another one.");
			}
			else if(PlayerInfo[playerid][pDonateRank] == 1 && VehicleSpawned[playerid] >= 4) {
				SendClientMessage(playerid, COLOR_GREY, "As Bronze VIP you can only have 4 vehicles spawned. You must store a vehicle in order to spawn another one.");
			}
			else if(PlayerInfo[playerid][pDonateRank] == 2 && VehicleSpawned[playerid] >= 5) {
				SendClientMessage(playerid, COLOR_GREY, "As Silver VIP you can only have 5 vehicles spawned. You must store a vehicle in order to spawn another one.");
			}
			else if(PlayerInfo[playerid][pDonateRank] == 3 && VehicleSpawned[playerid] >= 6) {
				SendClientMessage(playerid, COLOR_GREY, "As Gold VIP you can only have 6 vehicles spawned. You must store a vehicle in order to spawn another one.");
			}
			else if(PlayerInfo[playerid][pDonateRank] == 4 && VehicleSpawned[playerid] >= 10) {
				SendClientMessage(playerid, COLOR_GREY, "As Platinum VIP you can only have 10 vehicles spawned. You must store a vehicle in order to spawn another one.");
			}
			else if(PlayerInfo[playerid][pDonateRank] == 5 && VehicleSpawned[playerid] >= 10){
				SendClientMessage(playerid, COLOR_GREY, "As VIP Moderator you can only have 10 vehicles spawned. You must store a vehicle in order to spawn another one.");
			}
			else if(!(0 <= PlayerInfo[playerid][pDonateRank] <= 6)) {
				SendClientMessage(playerid, COLOR_GREY, "You have an invalid VIP level.");
			}
			else {
				++PlayerCars;
				VehicleSpawned[playerid]++;
				PlayerVehicleInfo[playerid][listitem][pvSpawned] = 1;
				PlayerVehicleInfo[playerid][listitem][pvId] = CreateVehicle(PlayerVehicleInfo[playerid][listitem][pvModelId], PlayerVehicleInfo[playerid][listitem][pvPosX], PlayerVehicleInfo[playerid][listitem][pvPosY], PlayerVehicleInfo[playerid][listitem][pvPosZ], PlayerVehicleInfo[playerid][listitem][pvPosAngle],PlayerVehicleInfo[playerid][listitem][pvColor1], PlayerVehicleInfo[playerid][listitem][pvColor2], -1);
				//VehicleFuel[PlayerVehicleInfo[playerid][listitem][pvId]] = PlayerVehicleInfo[playerid][listitem][pvFuel];
				if(PlayerVehicleInfo[playerid][listitem][pvLocked] == 1) LockPlayerVehicle(playerid, PlayerVehicleInfo[playerid][listitem][pvId], PlayerVehicleInfo[playerid][listitem][pvLock]);

				/*if(strlen(PlayerVehicleInfo[playerid][listitem][pvNumberPlate]) > 0)
				SetVehicleNumberPlate(PlayerVehicleInfo[playerid][listitem][pvId], PlayerVehicleInfo[playerid][listitem][pvNumberPlate]);*/

				LoadPlayerVehicleMods(playerid, listitem);

				new vstring[128];
				format(vstring, sizeof(vstring), "You have taken your %s out of storage. The vehicle has been spawned at the last parking location.", VehicleName[PlayerVehicleInfo[playerid][listitem][pvModelId] - 400]);
				SendClientMessage(playerid, COLOR_WHITE, vstring);
			}
		}
		else SendClientMessage(playerid, COLOR_WHITE, "You can't spawn a non-existent vehicle.");
	}
I'm wondering , why the vehicles aren't stop spawning , when a player logs in ..:/
All vehicles should be despawned ,when a player logs in ..

I'd be glad if you help me out .
Reply
#2

Alex's is right,you must remove vehicles after the owner dis*connects,atleast they shall for your server's health.
Reply
#3

Quote:
Originally Posted by Tamer T
Посмотреть сообщение
Alex's is right,you must remove vehicles after the owner dis*connects,atleast they shall for your server's health.
Quote:
Originally Posted by ******
Посмотреть сообщение
You've not shown any code relating to logging in or out - do you actually destroy the vehicles when a player leaves?
Player owned vehicles only spawn , when a player in logged in .It gets De spawned when a player logs out .

So i'm not getting the part .How can i stop the vehicles from Spawning when a player logs in .:/ I've tried looking at OnPlayerSpawn and OnPlayerConnect aswell.. I'm confused around here..
Reply
#4

Here is the part of public OnPlayerLogin
Код:
for(new v = 0; v < MAX_PLAYERVEHICLES; v++)
				{
					format(string, 128, "pv%dPosX",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvPosX] = floatstr( val ); }
					format(string, 128, "pv%dPosY",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvPosY] = floatstr( val ); }
					format(string, 128, "pv%dPosZ",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvPosZ] = floatstr( val ); }
					format(string, 128, "pv%dPosAngle",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvPosAngle] = floatstr( val ); }
					format(string, 128, "pv%dModelId",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvModelId] = strval( val ); }
					format(string, 128, "pv%dLock",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvLock] = strval( val ); }
					format(string, 128, "pv%dLocked",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvLocked] = strval( val ); }
					format(string, 128, "pv%dPaintJob",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvPaintJob] = strval( val ); }
					format(string, 128, "pv%dColor1",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvColor1] = strval( val ); }
					format(string, 128, "pv%dColor2",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvColor2] = strval( val ); }
					format(string, 128, "pv%dPrice",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvPrice] = strval( val ); }
					format(string, 128, "pv%dTicket",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvTicket] = strval( val ); }
					format(string, 128, "pv%dWeapon0",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvWeapons][0] = strval( val ); }
					format(string, 128, "pv%dWeapon1",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvWeapons][1] = strval( val ); }
					format(string, 128, "pv%dWeapon2",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvWeapons][2] = strval( val ); }
					format(string, 128, "pv%dWepUpgrade",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvWepUpgrade] = strval( val ); }
					format(string, 128, "pv%dFuel",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvFuel] = floatstr( val ); }
					format(string, 128, "pv%dImpound",v);
					if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvImpounded] = strval( val ); }
					format(string, 128, "pv%dNumPlate",v);
					//if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); strcpy(PlayerVehicleInfo[playerid][v][pvNumberPlate], Data, 32); } //PlayerVehicleInfo[playerid][v][pvNumberPlate] = floatstr( val ); }
					for(new m = 0; m < MAX_MODS; m++)
					{
						format(string, 128, "pv%dMod%d", v, m);
						if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); PlayerVehicleInfo[playerid][v][pvMods][m] = strval( val ); }
					}
					//format(string, 128, "pv%dAllowedPlayer",v);
					//if( strcmp( key , string , true ) == 0 ) { val = ini_GetValue( Data ); strmid(PlayerVehicleInfo[playerid][v][pvAllowPlayer], val, 0, strlen(val)-1, 255); }
				}
This the the code of Player owned vehicle , loading in guess.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)