SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/11/2019, 06:26 AM   #1
AndrewRussett
Big Clucker
 
AndrewRussett's Avatar
 
Join Date: Feb 2017
Location: Los Santos
Posts: 79
Reputation: 0
Default Would you help me with this? +REP.

Good, basically the code makes every few minutes the vehicles that are within the radius of a parking lot be taken to the same. It fails in several ways, sometimes gives you another virtualworld, sometimes they fall from the mappeo (and that's the same LVPD only as in another virtual one, to avoid this same), what can it be?

Code:
	// > Parking.
	foreach(new Jugadores_: Player)
	{
		DeletePVar(Jugadores_, "AvisoEst_");
	}
	foreach(new BucleVehicles_ : TotalVehicles_)
	{
	    new Float:Range_ = 0;
	    if(IsValidVehicle(Vehicles[ BucleVehicles_ ][aID_SAMP]))
	    {
			if(EnArea_Veh(Vehicles[ BucleVehicles_ ][aID_SAMP], -24.4454, -313.1188, 4.9387, 150.0))
			{
			    Range_ = 150.0;
			}
			if(EnArea_Veh(Vehicles[ BucleVehicles_ ][aID_SAMP], -1699.3402, -17.7018, 3.2818, 230.0))
			{
			    Range_ = 230.0;
			}
			if(EnArea_Veh(Vehicles[ BucleVehicles_ ][aID_SAMP], 1416.9493, -1164.7372, 23.2872, 80.0))
			{
			    Range_ = 80.0;
			}
			if(Range_ != 0)
			{
			    if(Vehicles[ BucleVehicles_ ][aPropSQLID] != 0 && !Vehicles[ BucleVehicles_ ][aParking])
			    {
					if(!CocheOcupado_(Vehicles[ BucleVehicles_ ][aID_SAMP]))
		            {
						foreach(new BucleEst_ : TotalEst_)
						{
							if(EnArea_Veh(Vehicles[ BucleVehicles_ ][aID_SAMP], Parking[ BucleEst_ ][estPosicion][0], Parking[ BucleEst_ ][estPosicion][1], Parking[ BucleEst_ ][estPosicion][2], Range_))
							{
								foreach(new Jugadores_: Player)
								{
									if(EsPropAuto(Jugadores_, Vehicles[ BucleVehicles_ ][aID_SAMP]))
									{
										if(!GetPVarInt(Jugadores_, "AvisoEst_"))
										{
											SetPVarInt(Jugadores_, "AvisoEst_", 1);
											SendClientMessage(Jugadores_, -1, "Info: Your vehicle has been towed to the nearest parking lot.");
										}
									}
								}
							    SetVehicleVirtual(Vehicles[ BucleVehicles_ ][aID_SAMP], Parking[ BucleEst_ ][estVirtualWorld]);
				            	Vehicles[ BucleVehicles_ ][aParking] = Parking[ BucleEst_ ][estVirtualWorld];
								//
							    new HandleVeh_ = SQL::Open(SQL::UPDATE, SQL_TABLA_VEHICLES, "id_vehicle", Vehicles[ BucleVehicles_ ][aSQLID]);
						        SQL::WriteInt(HandleVeh_, "in_parking", Vehicles[ BucleVehicles_ ][aParking]);
						        SQL::Close(HandleVeh_);
								switch(random(72))
								{
									case 0:
									{
										SetVehiclePos(Vehicles[ BucleVehicles_ ][aID_SAMP], 2316.8738,2430.7534,2.9453);
										SetVehicleZAngle(Vehicles[ BucleVehicles_ ][aID_SAMP], 59.5572);
									}
									etc...
								}	
							}	
						}				
				    }
			    }
			}
		}
	}
	return 1;
}	

EnArea_Veh(VehID, Float:PosVeh_X, Float:PosVeh_Y, Float:PosVeh_Z, Float:Radio_)
{
	new Float:X, Float:Y, Float:Z;
	GetVehiclePos(VehID, X, Y, Z);

    new Float:Distancia_ = (X-PosVeh_X)*(X-PosVeh_X)+(Y-PosVeh_Y)*(Y-PosVeh_Y)+(Z-PosVeh_Z)*(Z-PosVeh_Z);
    if(Distancia_ <= Radio_ * Radio_)
    {
        return 1;
    }
	return 0;
}
AndrewRussett is offline   Reply With Quote
Old 13/11/2019, 05:53 AM   #2
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,162
Reputation: 73
Default Re: Would you help me with this? +REP.

fall from the map is caused by syncing, vehicles are loaded before map loads, to avoid that issue, make "ground object" to be loaded from far distance.

Quote:
Originally Posted by AndrewRussett View Post
sometimes gives you another virtualworld
you're not even using SetPlayerVirtualWorld, or you didn't provide that part of a code.
__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 04:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.