Object destroys when other player spawns the object
#1

Hi all,

I am using a spikestrip include and i modifed it.
But now when i place a spikestrip and someone else place one to mine spikestrip will be destroyed.
Include:
pawn Код:
#include <a_samp>

#define MAX_SPIKESTRIPS 200

enum sInfo
{
    sCreated,
    Float:sX,
    Float:sY,
    Float:sZ,
    sObject,
};
new SpikeInfo[MAX_SPIKESTRIPS][sInfo];

stock CreateStrip(Float:x,Float:y,Float:z,Float:Angle)
{
    for(new i = 0; i < sizeof(SpikeInfo); i++)
    {
        if(SpikeInfo[i][sCreated] == 0)
        {
            SpikeInfo[i][sCreated]=1;
            SpikeInfo[i][sX]=x;
            SpikeInfo[i][sY]=y;
            SpikeInfo[i][sZ]=z-0.7;
            SpikeInfo[i][sObject] = CreateObject(2899, x, y, z-0.9, 0, 0, Angle-90);
            return 1;
        }
    }
    return 0;
}

stock DeleteAllStrip()
{
    for(new i = 0; i < sizeof(SpikeInfo); i++)
    {
        if(SpikeInfo[i][sCreated] == 1)
        {
            SpikeInfo[i][sCreated]=0;
            SpikeInfo[i][sX]=0.0;
            SpikeInfo[i][sY]=0.0;
            SpikeInfo[i][sZ]=0.0;
            DestroyObject(SpikeInfo[i][sObject]);
        }
    }
    return 0;
}

stock DeleteStrip(playerid)
{
    for(new i = 0; i < sizeof(SpikeInfo); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 20000.0, SpikeInfo[i][sX], SpikeInfo[i][sY], SpikeInfo[i][sZ]))
        {
            if(SpikeInfo[i][sCreated] == 1)
            {
                SpikeInfo[i][sCreated]=0;
                SpikeInfo[i][sX]=0.0;
                SpikeInfo[i][sY]=0.0;
                SpikeInfo[i][sZ]=0.0;
                DestroyObject(SpikeInfo[i][sObject]);
                return 1;
            }
        }
    }
    return 0;
}
Command:
pawn Код:
dcmd_spikestrip(playerid,params[])
{
    #pragma unused params
    if(gTeam[playerid]!=TEAM_COP)
    {
        SendClientMessage(playerid,COLOR_RED,"Only Police Officers can place Spikestrips!");
        return 1;
    }
    else if(gTeam[playerid]==TEAM_COP)
    {
        if(HasPlacedSpikestripRecently[playerid]>=1)
        {
            SendClientMessage(playerid,COLOR_RED,"Please wait before placing a spikestrip again.");
            return 1;
        }
        DeleteStrip(playerid);
        new Float:plocx,Float:plocy,Float:plocz,Float:ploca;
        GetPlayerPos(playerid, plocx, plocy, plocz);
        GetPlayerFacingAngle(playerid,ploca);
        CreateStrip(plocx,plocy,plocz,ploca);
        HasPlacedSpikestripRecently[playerid]=60;
        return 1;
    }
    return 1;
}
How can i fix this?

Admigo
Reply
#2

Anyone?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)