rendered paste body#include <a_samp>
forward perf(playerid,vehicleid);
#pragma tabsize 0
new nrg;
enum SavePlayerPosEnum {
Float:LastX,
Float:LastY,
Float:LastZ
}
forward UpdateSpeed();
#define SLOTS 50
new SavePlayerPos[SLOTS][SavePlayerPosEnum];
new SpeedMode = 0;
new UpdateSeconds = 1;
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" anti bike fall off + unlimit nrg health loaded");
print(" created by [PG]perf");
print("--------------------------------------\n");
SetTimer("UpdateSpeed", UpdateSeconds*1000, 1);
return 1;
}
public OnFilterScriptExit()
{
print("\n--------------------------------------");
print(" anti bike fall off + unlimit nrg health unloaded");
print(" created by [PG]perf");
print("--------------------------------------\n");
return 1;
}
public OnPlayerSpawn(playerid)
{
nrg = CreateVehicle(522,1928.5276,-2247.7937,13.1128,173.5390,39,106,-1);
PutPlayerInVehicle(playerid,nrg,0);
SetTimer("perf",10,1);
return 1;
}
public perf(playerid,vehicleid)
{
new i;
for (i=0;i<MAX_PLAYERS;i++){
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) {
new vid;
vid = GetPlayerVehicleID(i);
SetPlayerHealth(playerid,1000);
PutPlayerInVehicle(i,nrg,0);
SetVehicleHealth(vid,1000);}
}
return 1;
}
public UpdateSpeed(){ //not created by me
new Float:x,Float:y,Float:z;
new Float:distance,value,string[256];
for(new i=0; i<SLOTS; i++){
if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) {
GetPlayerPos(i, x, y, z);
distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2));
value = floatround(distance * 3600);
if(UpdateSeconds > 1){
value = floatround(value / UpdateSeconds);
}
if(SpeedMode){
format(string,sizeof(string)," ~w~%d ~g~MPH",floatround(value/1600));
GameTextForPlayer(i, string, 1100, 6);
}
else{
format(string,sizeof(string),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~w~%d ~g~KPH",floatround(value/1000));
GameTextForPlayer(i, string, 1100, 3);
}
SavePlayerPos[i][LastX] = x;
SavePlayerPos[i][LastY] = y;
SavePlayerPos[i][LastZ] = z;
}
}
}