Jump to content

Am o problema!!


Ionut1

Recommended Posts

Salut, am o problema la tickrate, cand dau 'F' gen sa intru intr-un vehicul imi scad tick-uri si am postat astea aici, nu stiu de la ce este cine ma poate ajuta va rog frumos. 

		   new car = GetClosestVehicle(playerid);
		   if(car != INVALID_VEHICLE_ID && IsPlayerNearVehicle(playerid,car,5)) 
		   {
			   for(new i = 0; i < 10; i++) 
			   {
					if(PlayerInfo[playerid][pCarKey][i] != 0) 
					{
						if(CarInfo[PlayerInfo[playerid][pCarKey][i]][Spawned] == car) SetVehicleParamsForPlayer(car, playerid, 0, 0);
					}
					if(car == RentVehicle[playerid]) SetVehicleParamsForPlayer(car, playerid, 0, 0);	
			   }
		   } 
function LockCarFunction(playerid) {
	new 
		string[64],
		engine,lights,alarm,doors,bonnet,boot,objective,
		idd, car;
		
	if(IsPlayerInAnyVehicle(playerid)) car = GetPlayerVehicleID(playerid);
	else car = GetClosestVehicle(playerid);
	if(car == INVALID_VEHICLE_ID) return true;
	else if(!IsPlayerNearVehicle(playerid, car, 5) && !IsABoat(car)) return true;
	else if(!IsPlayerNearVehicle(playerid, car, 10) && IsABoat(car)) return true;
	GetVehicleParamsEx(car,engine,lights,alarm,doors,bonnet,boot,objective);
	
	if(JobWorking[playerid] == 1 && JobVehicle[playerid] == car) {
		if(doors == 1) {
			format(string, sizeof(string), "~w~%s~n~~g~Deschis",aVehicleNames[GetVehicleModel(car)-400]);
			GameTextForPlayer(playerid, string, 3000, 4);
			SetVehicleParamsEx(car,engine,lights,alarm,0,bonnet,boot,objective);
		}
		else {
			format(string, sizeof(string), "~w~%s~n~~r~Inchis",aVehicleNames[GetVehicleModel(car)-400]);
			GameTextForPlayer(playerid, string, 3000, 4);				
			SetVehicleParamsEx(car,engine,lights,alarm,1,bonnet,boot,objective);
		}		
		return true;
	}
	
	if(VehicleSQL[car] != 0) {
		idd = VehicleSQL[car];
		if(VehicleKey[playerid] != 0 && VehicleKey[playerid] == car) {
			if(CarInfo[idd][cLock] == 0) {
				CarInfo[idd][cLock] = 1;
				SetVehicleParamsEx(car,engine,lights,alarm,1,bonnet,boot,objective);
				format(string, sizeof(string), "~w~%s~n~~r~Inchis",aVehicleNames[CarInfo[idd][cModel]-400]);
				GameTextForPlayer(playerid, string, 5000, 4);
			}
			else {
				CarInfo[idd][cLock] = 0;
				SetVehicleParamsEx(car,engine,lights,alarm,0,bonnet,boot,objective);
				format(string, sizeof(string), "~w~%s~n~~g~Deschis",aVehicleNames[CarInfo[idd][cModel]-400]);
				GameTextForPlayer(playerid, string, 5000, 4);
			}
			mysql_format(SQL, string, sizeof(string), "UPDATE cars SET Lockk='%d' WHERE ID=%d", CarInfo[idd][cLock], idd);
			mysql_tquery(SQL, string, "", "");	
			return true;
		}
	}
	
	if(GetVehicles(playerid) == 0) return true;
	idd = FindSpawnID(car);
	if(idd == 0) return true;
	new succes;
	for(new i = 0; i < 10; i++) {
		if(PlayerInfo[playerid][pCarKey][i] == idd && idd != 0) succes = 1;
	}
	if(succes == 0) return true;

	if(CarInfo[idd][cLock] == 0) {
		CarInfo[idd][cLock] = 1;	
		SetVehicleParamsEx(car,engine,lights,alarm,1,bonnet,boot,objective);
		format(string, sizeof(string), "~w~%s~n~~r~Inchis",aVehicleNames[GetVehicleModel(car)-400]);
		GameTextForPlayer(playerid, string, 5000, 4);
	}
	else {
		CarInfo[idd][cLock] = 0;
		SetVehicleParamsEx(car,engine,lights,alarm,0,bonnet,boot,objective);
		format(string, sizeof(string), "~w~%s~n~~g~Deschis",aVehicleNames[GetVehicleModel(car)-400]);
		GameTextForPlayer(playerid, string, 5000, 4);
	}
	mysql_format(SQL, string, sizeof(string), "UPDATE cars SET Lockk='%d' WHERE ID=%d", CarInfo[idd][cLock], idd);
	mysql_tquery(SQL, string, "", "");	
	return true;
}
stock GetDistance2( Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2 ) return floatround( floatsqroot( ( ( x1 - x2 ) * ( x1 - x2 ) ) + ( ( y1 - y2 ) * ( y1 - y2 ) ) + ( ( z1 - z2 ) * ( z1 - z2 ) ) ) );
forward Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2);
public Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));

stock GetClosestVehicle(playerid) {
    new closestdist = 999999999, closestvehicle = -1;
    new Float:x[2],Float:y[2],Float:z[2],distance;
    for(new i; i < MAX_VEHICLES; i++) {
        GetVehiclePos(i,x[0],y[0],z[0]);
        GetPlayerPos(playerid,x[1],y[1],z[1]);
        distance = floatround(GetDistanceBetweenPoints(x[0],y[0],z[0],x[1],y[1],z[1]));
        if(distance < closestdist) {
            closestdist = distance;
            closestvehicle = i;
        }
    }
    return closestvehicle;
}
stock GetClosestVehicle2(playerid) {
	new Float: Distance;
	if(!Distance) Distance = 200.0;
	new Float:X[2], Float:Y[2], Float:Z[2], Float:NearestPos = floatabs(Distance), NearestVehicle = INVALID_VEHICLE_ID;
	GetPlayerPos(playerid, X[0], Y[0], Z[0]);
	for(new i; i < MAX_VEHICLES; i++) {
		if(!IsVehicleStreamedIn(i, playerid) || IsPlayerInVehicle(playerid, i)) continue;
		GetVehiclePos(i, X[1], Y[1], Z[1]);
		if(NearestPos > GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1])) NearestPos = GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]), NearestVehicle = i;
	}
	return NearestVehicle;
}

 

Edited by Ionut1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.