A Bomber Script Without Map Andreas
#1

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 :
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;
}
Reply
#2

AnyOne ??
Reply
#3

I can't see the problem you have here.

But if you are not using mapandreas just because it uses much RAM there is a stable version of it which does not use additional RAM. It works flawlessly.

https://sampforum.blast.hk/showthread.php?tid=275492
Reply
#4

well thanx for help but i don't use mapandreas coz i have many objects put in my server and map andreas won't detect them
Reply
#5

I want to point that you're checking if "i != playerid" twice
pawn Код:
for(new i = 0 ; i <= MAX_PLAYERS && i != playerid ; i++)
{
    if(i != playerid)
Also I have a suggestion for it, You could get the "z" of the nearest player (If found) And create explosion there.
Reply
#6

so where does it explode?
Reply
#7

when there is a player near it or when Z reaches -20
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)