Aqui vai um anti car spam, criado por mim, com a ajuda do Koman, pela primeira idealizaзao do cуdigo:
pawn Код:
new CarSpam[MAX_PLAYERS];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
CarSpam[playerid]++;
SetTimerEx("CarSpam0",1000,0,"i",playerid);
DetectarCarro(GetPlayerVehicleID(playerid));
if(CarSpam[playerid] > 5)
{
Kick(playerid);
}
return 1;
}
forward CarSpam0(playerid);
public CarSpam0(playerid)
{
CarSpam[playerid] = 0;
return 1;
}
stock IsVehicleInRangeOfPoint(vehicleid, Float:range, Float:x, Float:y, Float:z)
{
new Float:px, Float:py, Float:pz; GetVehiclePos(vehicleid,px,py,pz); px -= x; py -= y; pz -= z;
return ((px * px) + (py * py) + (pz * pz)) < (range * range);
}
forward DetectarCarro(vehicleid);
public DetectarCarro(vehicleid)
{
new Float:PosVeh[3];
new VeiculosPerto = 0;
GetVehiclePos(vehicleid,PosVeh[0],PosVeh[1],PosVeh[2]);
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsVehicleInRangeOfPoint(i,10.0,PosVeh[0],PosVeh[1],PosVeh[2]))
{
VeiculosPerto++;
}
}
if(VeiculosPerto >= 30)
{
for(new f=0; f<MAX_PLAYERS; f++)
{
if(IsPlayerConnected(f))
{
if(IsPlayerInRangeOfPoint(f,20.0,PosVeh[0],PosVeh[1],PosVeh[2]))
{
new Float:Pos[3]; GetPlayerPos(f,Pos[0],Pos[1],Pos[2]);
for(new xy=0; xy<MAX_VEHICLES; xy++)
{
if(IsVehicleInRangeOfPoint(xy,20.0,Pos[0],Pos[1],Pos[2]))
{
SetVehicleToRespawn(xy);
}
}
}
}
}
}
return 1;
}
Tambйm tem o anti fake kill, feito pelo leonardo1434 e adaptado por mim:
pawn Код:
new FakeKill[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
FakeKill[playerid]++;
SetTimerEx("FakeKill0",1000,0,"i",playerid);
if(FakeKill[playerid] > 2)
{
Kick(playerid);
}
return 1;
}
forward FakeKill0(playerid);
public FakeKill0(playerid)
{
FakeKill[playerid] = 0;
return 1;
}