Is this stock..
#1

Wrongly coded? cuz, it doesn't work, i want to know if this is the stock's mistake or my mistake so answer fast please.


pawn Код:
stock IsVehicleInRangeOfPoint(vehicleid, Float:radi, Float:x, Float:y, Float:z)
{
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetVehiclePos(vehicleid, oldposx, oldposy, oldposz);
    tempposx = (oldposx -x);
    tempposy = (oldposy -y);
    tempposz = (oldposz -z);
    if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
    {
        return 1;
    }
    return 0;
}
Reply
#2

Код:
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);
}
Source: https://sampforum.blast.hk/showthread.php?tid=142234
Reply
#3

Thank you very much.
Reply
#4

Ok, it is not the stock..

can anyone tell me why this ain't working then?

The code:

pawn Код:
forward BombEx(playerid);
public BombEx(playerid)
{
    new Float:Pos[3], Obj, rand = random(50000), pKilledN[ MAX_PLAYER_NAME ];
    SendClientMessage(playerid, -1, "Bomb planted, now wait for a tank to come here!");
    GetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
    Obj = CreateObject(ObjID, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ]-1, 0.0, 0.0, 0.0, 0.0);
    if(IsVehicleInRangeOfPoint( 432, 5.0, Pos[ 0 ], Pos [ 1 ], Pos[ 2 ] ))
    {
        for( new i = 0; i < MAX_PLAYERS; i++)
        {
            pMineV[ i ][ oMine ] = true;
            DestroyObject(Obj);
            GetPlayerName(i, pKilledN, MAX_PLAYER_NAME);
            SendDeathMessage(playerid, i, 53);
            CreateExplosion(Pos[ 0 ], Pos[ 1 ], Pos[ 2 ], 3, 3.0);
            SetPlayerHealth(i, 0);
            GameTextForPlayer(i, "Exploded by a mine!", 5000, 4);
            format(str, SOFS, "You've killed %s ! and got $%d", pKilledN, rand);
            SendClientMessage(playerid, -1, str);
        }
    }
    return 1;
}
Reply
#5

Quote:

if(IsVehicleInRangeOfPoint( 432, 5.0, Pos[ 0 ], Pos [ 1 ], Pos[ 2 ] ))

Is the first parameter the vehicle model? If so, there's a difference between the Vehicle MODEL and the vehicle ID.
Reply
#6

I think someone has explained me about that before (Pottus) but honestly i forgot, can you explain me? please
Reply
#7

pawn Код:
if(IsVehicleInRangeOfPoint( 432, 5.0, Pos[ 0 ], Pos [ 1 ], Pos[ 2 ] ))
    {
        if(GetVehicleModel(vehicleid) ==432)
        {
            for( new i = 0; i < MAX_PLAYERS; i++)
            {
                pMineV[ i ][ oMine ] = true;
                DestroyObject(Obj);
                GetPlayerName(i, pKilledN, MAX_PLAYER_NAME);
                SendDeathMessage(playerid, i, 53);
                CreateExplosion(Pos[ 0 ], Pos[ 1 ], Pos[ 2 ], 3, 3.0);
                SetPlayerHealth(i, 0);
                GameTextForPlayer(i, "Exploded by a mine!", 5000, 4);
                format(str, SOFS, "You've killed %s ! and got $%d", pKilledN, rand);
                SendClientMessage(playerid, -1, str);
            }
        }
    }
    return 1;
}
Is this how it does work?
Reply
#8

Quote:
Originally Posted by Strier
Посмотреть сообщение
pawn Код:
if(IsVehicleInRangeOfPoint( 432, 5.0, Pos[ 0 ], Pos [ 1 ], Pos[ 2 ] ))
    {
        if(GetVehicleModel(vehicleid) ==432)
        {
            for( new i = 0; i < MAX_PLAYERS; i++)
            {
                pMineV[ i ][ oMine ] = true;
                DestroyObject(Obj);
                GetPlayerName(i, pKilledN, MAX_PLAYER_NAME);
                SendDeathMessage(playerid, i, 53);
                CreateExplosion(Pos[ 0 ], Pos[ 1 ], Pos[ 2 ], 3, 3.0);
                SetPlayerHealth(i, 0);
                GameTextForPlayer(i, "Exploded by a mine!", 5000, 4);
                format(str, SOFS, "You've killed %s ! and got $%d", pKilledN, rand);
                SendClientMessage(playerid, -1, str);
            }
        }
    }
    return 1;
}
Is this how it does work?
No, the first parameter of IsVehicleInRangeOfPoint requires a vehicle ID. I honestly don't know what the vehicle ID is.
Reply
#9

vehicleid = GetPlayerVehicleID(playerid);

Yea, i moved the GetVehicleModel above IsVehicleInRangeOfPoint, still the bomb doesn't explode.. :/
Reply
#10

Quote:
Originally Posted by Strier
Посмотреть сообщение
vehicleid = GetPlayerVehicleID(playerid);

Yea, i moved the GetVehicleModel above IsVehicleInRangeOfPoint, still the bomb doesn't explode.. :/
replace

Код:
if(IsVehicleInRangeOfPoint( 432, 5.0, Pos[ 0 ], Pos [ 1 ], Pos[ 2 ] ))
with
Код:
if(IsVehicleInRangeOfPoint( GetPlayerVehicleID(playerid), 5.0, Pos[ 0 ], Pos [ 1 ], Pos[ 2 ] ))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)