29.11.2013, 07:31
I Started And Finished A Script That Works Without Map Andreas But The Problem Is That Every Time I Drop A Bomb It Doesn't Explode Near Players As It Should Do .
The Code :
The Code :
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
#include < sscanf2 >
#include <fixes2>
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define MAX_BOMBS 10000
#define MAX_VEHICLE_BOMBS 20
new vmb[MAX_VEHICLES];
new bomb[MAX_VEHICLES][MAX_VEHICLE_BOMBS];
new planehasbombs[MAX_VEHICLES] = 0;
new timer[MAX_BOMBS];
stock Float:Dist(Float:x1,Float:x2,Float:y1,Float:y2)
{
new Float:val = floatsqroot(((x2-x1)*(x2-x1)) + ((y2-y1)*(y2-y1)));
return val;
}
forward BomberCheck(vehicleid,playerid,obj);
public BomberCheck(vehicleid,playerid,obj)
{
new Float:x,Float:y,Float:z;
GetObjectPos(obj,x,y,z);
if(z == -20)
{
DestroyObject(obj);
KillTimer(timer[obj]);
}else{
for(new i = 0 ; i <= MAX_PLAYERS && i != playerid ; i++)
{
if(i != playerid)
{
if(IsPlayerInRangeOfPoint(i,10.0,x,y,z))
{
CreateExplosion(x,y,z,0,10);
DestroyObject(obj);
SetPVarInt(i,"special",1);
CallRemoteFunction("OnPlayerDeath","iii",i,playerid,51);
SetPlayerHealth(i,0);
print("Gotcha");
KillTimer(timer[obj]);
}
}
}
}
return 1;
}
public OnVehicleSpawn(vehicleid)
{
new model = GetVehicleModel(vehicleid);
switch(model)
{
case 476:
{
planehasbombs[vehicleid] = 4;
}
case 553:
{
planehasbombs[vehicleid] = 10;
}
case 577:
{
planehasbombs[vehicleid] = 20;
}
case 592:
{
planehasbombs[vehicleid] = 15;
}
}
return 1;
}
public OnFilterScriptInit()
{
vmb[476] = 4;
vmb[553] = 10;
vmb[577] = 20;
vmb[592] = 15;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
if(model == 476||553||577||592)
{
if(planehasbombs[vehicleid] > 0)
{
if(PRESSED(KEY_HANDBRAKE))
{
planehasbombs[vehicleid] = planehasbombs[vehicleid] - 1;
new Float:x,Float:y,Float:z;
GetVehiclePos(vehicleid,x,y,z);
bomb[vehicleid][planehasbombs[vehicleid]] = CreateObject(3786,x,y,z-5,0,0,0,300);
MoveObject(bomb[vehicleid][planehasbombs[vehicleid]],x,y,-20,10);
new string[124];
format(string,124,"%i Down . %i Left",vmb[model]-planehasbombs[vehicleid],planehasbombs[vehicleid]);
SendClientMessage(playerid,0xFF0000FF,string);
timer[bomb[vehicleid][planehasbombs[vehicleid]]] = SetTimerEx("BomberCheck",50,1,"iii",vehicleid,playerid,bomb[vehicleid][planehasbombs[vehicleid]]);
}
}
}
return 1;
}