Jump to content
FREAKHOSTING





[Tutorial] Modificarea vitezei vehicul


Impulsive.
 Share

Recommended Posts

Incepem prin a defini variabilile de care ne vom folosi:

Adaugati tot de mai jos undeva la inceputul gamemode-ului.

#define SPEED_MULTIPLIER 1.025
#define SPEED_THRESHOLD  0.4
#define  SpeedUPCheck(%0,%1,%2,%3,%4)  floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.7)
new g_SpeedUpTimer = -1, Float:g_SpeedThreshold, maxSpeed[MAX_VEHICLES];

Adaugati tot de mai jos in OnGameModeInit().

g_SpeedThreshold = SPEED_THRESHOLD * SPEED_THRESHOLD;
g_SpeedUpTimer = SetTimer("SpeedUP", 250, true);

Adaugati tot de mai jos undeva prin gamemode.

forward SpeedUP();
public SpeedUP[250]() {
	foreach(new playerid : Player) {
        new vehicleid = GetPlayerVehicleID(playerid), Float:vx, Float:vy, Float:vz, viteza = GetPlayerSpeedUP(playerid, 0);
		if(IsPlayerInAnyVehicle(playerid)) {
     		GetVehicleVelocity(vehicleid, vx, vy, vz);
            if(vx * vx + vy * vy < g_SpeedThreshold)
                continue;

            vx *= SPEED_MULTIPLIER;
            vy *= SPEED_MULTIPLIER;

            if (vz > 0.04 || vz < -0.04)
            vz -= 0.020;
			if(viteza < maxSpeed[vehicleid])
				SetVehicleVelocity(vehicleid, vx, vy, vz);
		}
    }
}

Adaugati tot de mai jos undeva prin gamemode.

stock GetPlayerSpeedUP(playerid, get3d) {
	new veh = GetPlayerVehicleID(playerid), Float:FlSP[3];
	GetVehicleVelocity(veh, FlSP[0], FlSP[1], FlSP[2]), SpeedUPCheck(FlSP[0], FlSP[1], FlSP[2], 100.0, get3d);
	return 1;
}

Adaugati comanda undeva prin gamemode.

CMD:maxspeedup(playerid, params[]) {
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "** Nu te afli intr-un vehicul.");
	new speed, veh = GetPlayerVehicleID(playerid), string[51];
    if(sscanf(params, "i", speed)) return SendClientMessage(playerid, -1, "/maxspeedup [speed]");
    switch(speed) {
        case 0: return SendClientMessage(playerid, -1, "** Max speed-ul a fost eliminat!"), maxSpeed[veh] = 0, 0;
    }
    maxSpeed[veh] = speed;
    format(string, sizeof string, "** Vehiculul #%d detine acum maxSpeed-ul #%d.", veh, maxSpeed[veh]);
	SendClientMessage(playerid, -1, string);
	return 1;
}

Pentru a elimina max speed-ul de pe un vehicul tastati comanda:

[/maxspeedup 0]

 

Link to comment
Share on other sites

  • 0
  • 25
FREAKHOSTING





  • NeeD locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...