Jump to content

[ TUT ]Anti Air Break


Pulo15

Recommended Posts

Kód je úplně stejný, jako jsi napsal, jestli ho chceš vidět..

 

(Je to samostatný FS, nic jiného u něj není)

 

#include 


#define UPDATE_COUNT 5
#define POSSIBLE_AIRBREAK_COUNT_CAR 10
#define POSSIBLE_AIRBREAK_COUNT_ONFOOT 7

new pupdates[MAX_PLAYERS];
new airbreakcount[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
pupdates[playerid]++;
  if(pupdates[playerid] > UPDATE_COUNT)
  {
      pupdates[playerid]=0;
      new check;
     if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsVehicleValid(GetPlayerVehicleID(playerid)))
     {
        new Float:vx,Float:vy,Float:vz;
        GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
        if(vx==0.0 && vy==0.0 && vz < -0.0032 && vz > -0.022)
        {
           check=1;
        }
     }
     else
     {
         if(GetPlayerState(playerid)==PLAYER_STATE_ONFOOT)
         {
              new Float:vx,Float:vy,Float:vz,Float:px,Float:py,Float:pz;
              GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
              GetPlayerVelocity(playerid,vx,vy,vz);
              GetPlayerPos(playerid,px,py,pz);
               pupdates[playerid]=0;
               if(-0.022 < vz < -0.0040 && -0.121 < vx < 0.121 && -0.121 < vy < 0.121 && GetPlayerSurfingVehicleID(playerid)==INVALID_VEHICLE_ID && pz > 2.0)
               {
                   if(!IsPlayerInRangeOfPoint(playerid,2.0,GetPVarFloat(playerid,"oposx"),
GetPVarFloat(playerid,"oposy"),GetPVarFloat(playerid,"oposz")) || -0.5>(GetPVarFloat(playerid,"oposz")-pz)>-0.1 || 0.075>(GetPVarFloat(playerid,"oposz")-pz)>-0.075)
                    {
                      check=2;
                   }
                   SetPVarFloat(playerid,"oposx",px);
                   SetPVarFloat(playerid,"oposy",py);
                   SetPVarFloat(playerid,"oposz",pz);
               }
         }
     }
     if(check > 0)
     {
         new POSSIBLE_AIRBREAK_COUNT;
        switch(check)
        {
            case 1: POSSIBLE_AIRBREAK_COUNT=POSSIBLE_AIRBREAK_COUNT_CAR;
            case 2: POSSIBLE_AIRBREAK_COUNT=POSSIBLE_AIRBREAK_COUNT_ONFOOT;
         }
        airbreakcount[playerid]++;
        if(airbreakcount[playerid] > POSSIBLE_AIRBREAK_COUNT && IsPlayerInWater(playerid)==0)
        {
              airbreakcount[playerid]=0;
                    //sem si dajte co sa stane, ak hracovi zisti AirBreak
              Kick(playerid); //tu je trebars Kick
        }
     }
     else
     {
         airbreakcount[playerid]=0;
     }
  }
  return 1;
}



stock IsVehicleValid(id)
{
  new type=GetVehicleModel(id);
  new blocked[]={ 548, 425, 417, 487, 488, 497, 563, 447, 469, 520 };
  for(new i;i   {
     if(type == blocked[i])
     {
        return 0;
     }
  }
  return 1;
}

stock IsPlayerInArea(playerid, Float:max_x, Float:min_x, Float:max_y, Float:min_y)
{
  new Float:X, Float:Y, Float:Z;
  GetPlayerPos(playerid, X, Y, Z);
  if(X <= max_x && X >= min_x && Y <= max_y && Y >= min_y) return 1;
  return 0;
}

stock IsPlayerInWater(playerid)
{
  new Float:x,Float:y,Float:pz;
  GetPlayerPos(playerid,x,y,pz);
  if (
  (IsPlayerInArea(playerid, 2032.1371, 1841.2656, 1703.1653, 1467.1099) && pz <= 9.0484) //lv piratenschiff
    || (IsPlayerInArea(playerid, 2109.0725, 2065.8232, 1962.5355, 10.8547) && pz <= 10.0792) //lv visage
    || (IsPlayerInArea(playerid, -492.5810, -1424.7122, 2836.8284, 2001.8235) && pz <= 41.06) //lv staucamm
    || (IsPlayerInArea(playerid, -2675.1492, -2762.1792, -413.3973, -514.3894) && pz <= 4.24) //sf südwesten kleiner teich
    || (IsPlayerInArea(playerid, -453.9256, -825.7167, -1869.9600, -2072.8215) && pz <= 5.72) //sf gammel teich
    || (IsPlayerInArea(playerid, 1281.0251, 1202.2368, -2346.7451, -2414.4492) && pz <= 9.3145) //ls neben dem airport
    || (IsPlayerInArea(playerid, 2012.6154, 1928.9028, -1178.6207, -1221.4043) && pz <= 18.45) //ls mitte teich
    || (IsPlayerInArea(playerid, 2326.4858, 2295.7471, -1400.2797, -1431.1266) && pz <= 22.615) //ls weiter südöstlich
    || (IsPlayerInArea(playerid, 2550.0454, 2513.7588, 1583.3751, 1553.0753) && pz <= 9.4171) //lv pool östlich
    || (IsPlayerInArea(playerid, 1102.3634, 1087.3705, -663.1653, -682.5446) && pz <= 112.45) //ls pool nordwestlich
    || (IsPlayerInArea(playerid, 1287.7906, 1270.4369, -801.3882, -810.0527) && pz <= 87.123) //pool bei maddog's haus oben
    || (pz < 1.5)
  )
  {
      return 1;
  }
  return 0;
}

 

Link to comment
Share on other sites

  • Replies 71
  • Created
  • Last Reply

Top Posters In This Topic

Takže, po tvé otázce, jakou mám verzi SAMP serveru jsem si stáhl nejnovější SAMP server, vyzkoušel jsem znova ten FS a jaké překvapení? FS jede.. Moje chyba, asi jsem stáhl SAMP server, kde byl napsaný R8, přitom to byl R3 nebo jaký..

Link to comment
Share on other sites

Guest Mare[C]ek
A ku všetkému si l*ma čo nevie dať hore

new pupdate[MAX_PLAYERS];

po česky

A kevšemu si l*ma čo nevie dať hore

new pupdate[MAX_PLAYERS];

 

ma tam

pupdate  s

to tam chybalo..staci dat hore ku

new pupdates blablabla...

Link to comment
Share on other sites

ho zkousel sem tuto verzi a air brk to odhali malo kdy

trochu sem to poupravil a udelal sem scrypt kery odhali airbrk co nejdrive

 

#include 

forward OnPlayerUpdated();

new blocked[] = {548,425,417,487,488,497,563,447,469,520};

public OnFilterScriptInit()
{
SetTimer("OnPlayerUpdated",580,1);
}

stock IsVehicleValid(id)
{
new type = GetVehicleModel(id);
for(new i;i	{
	if(type == blocked[i]) return 0;
}
return 1;
}

public OnPlayerUpdated()
{
for(new playerid;playerid	{
	if(IsPlayerConnected(playerid))
	{
		if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		{
		    new vehicleid = GetPlayerVehicleID(playerid);
		    if(IsVehicleValid(vehicleid))
		    {
			    new Float:vx,Float:vy,Float:vz;
			    GetPlayerPos(playerid,vy,vy,vz);
				if(vz > 1 || vz < -7)
				{
					GetVehicleVelocity(vehicleid,vx,vy,vz);
					if(vx==0.0 && vy==0.0 && vz < -0.0032 && vz > -0.022)
					{
					    SendClientMessage(playerid,0xFFFFFFAA,"Air brk v aute");
					}
				}
			}
		}
		else if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
		{
			new Float:vx,Float:vy,Float:vz;
			GetPlayerPos(playerid,vy,vy,vz);
			if(vz > 1 || vz < -7)//takto pozname ze neni ve vode (v te urovni ke to pocita jako airbrk)
			{
				GetPlayerVelocity(playerid,vx,vy,vz);
				if(-0.022 < vz < -0.0040 && -0.121 < vx < 0.121 && -0.121 < vy < 0.121 && GetPlayerSurfingVehicleID(playerid)==INVALID_VEHICLE_ID)
				{
				    SendClientMessage(playerid,0xFFFFFFAA,"Air brk pesky");
				}
			}
		}
	}
}
return 1;
}

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...