SA-MP Forums Archive
help with a not working filterscript? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help with a not working filterscript? (/showthread.php?tid=279973)



help with a not working filterscript? - ahmed2793 - 29.08.2011

i found this filterscript and when i compile everything work but when i test the mines won't explode the object is created but when players steps on it nothnig happens!!
this is the pawn code can anybody plz tell me what's the problem and how to fix?
pawn Code:
#include <dcmd>
#include <a_samp>
#define MAX_PLAYER 20
#define COLOR_RED 0xAA3333AA
#define COLOR_YELLOW 0xFFFF00AA
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
new gTeam[MAX_PLAYERS];
forward ActivateMine(objectid);
forward MineCheck();
new LandMines[MAX_PLAYER], MineState[MAX_OBJECTS], IsMine[MAX_OBJECTS], MineOwner[MAX_OBJECTS], MineKilled[MAX_PLAYER], MineKiller[MAX_PLAYER];
public OnFilterScriptInit()
{
     SetTimer("MineCheck", 100, true);
     for(new i=0;i<MAX_OBJECTS;i++)
    {
        IsMine[i] = 0;
        MineState[i] = 0;
    }
     return 1;
}
public OnPlayerConnect(playerid)
{
    MineKilled[playerid] = 0;
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(getmine, 7, cmdtext);
    dcmd(plantmine, 9, cmdtext);
    return 0;
}
dcmd_getmine(playerid, params[])
{
    if(GetPlayerMoney(playerid) < 500) SendClientMessage(playerid, COLOR_RED, "Not enough money: One mine cost 500$");
    else
    {
        LandMines[playerid]++;
        GivePlayerMoney(playerid, -500);
        SendClientMessage(playerid, COLOR_YELLOW, "Successfuly bought a mine, plant it with /plantmine");
    }
    return 1;
    #pragma unused params
}

dcmd_plantmine(playerid, params[])
{
    if(LandMines[playerid] < 1) SendClientMessage(playerid, COLOR_RED, "You have no mines, get one with /getmine");
    else
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        new mine;
        mine = CreateObject(1211, x, y, z-1.5, 0, 0, 0);
        IsMine[mine] = 1;
        SendClientMessage(playerid, COLOR_YELLOW, "Planted a mine, the mine will be activated in 10 seconds!");
        SetTimerEx("ActivateMine", 10000, false, "i", mine);
        LandMines[playerid]--;
        MineOwner[mine] = playerid;
    }
    return 1;
    #pragma unused params
}
public OnPlayerDeath(playerid, killerid, reason)
{
    if(MineKilled[playerid] == 1)
    {
        SetPlayerScore(MineKiller[playerid], GetPlayerScore(MineKiller[playerid])+1);
        GivePlayerMoney(MineKiller[playerid], 1250);
        SendDeathMessage(MineKiller[playerid], playerid, reason);
        MineKilled[playerid] = 0;
    }
    else
    {
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
        SendDeathMessage(killerid, playerid, reason);
        GivePlayerMoney(killerid, 1250);
    }
    return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
    for(new i=0;i<MAX_OBJECTS;i++)
    {
        if(IsValidObject(i) && IsMine[i] == 1)
        {
            if(MineOwner[i] == playerid)
            {
                MineOwner[i] = 255;
            }
        }
    }

}
public ActivateMine(objectid)
{
    MineState[objectid] = 1;
    return 1;
}

public MineCheck()
{
    new Float:x, Float:y, Float:z;
    for(new i=0;i<MAX_PLAYER;i++)
    {
        if(IsPlayerConnected(i))
        {
            for(new o=0;o<MAX_OBJECTS;o++)
            {
                if(IsValidObject(o))
                {
                    GetPlayerPos(i, x, y, z);
                    if(GetObjectDistanceToPointEx(o, x, y, z) < 3)
                    {
                        if(IsMine[o] == 1 && MineState[o] == 1 && gTeam[MineOwner[o]] != gTeam[i])
                        {
                            DestroyObject(o);
                            CreateExplosion(x, y, z, 3, 200);
                            CreateExplosion(x+1, y, z, 3, 200);
                            CreateExplosion(x-1, y, z, 3, 200);
                            CreateExplosion(x, y+1, z, 3, 200);
                            CreateExplosion(x, y-1, z, 3, 200);
                            GameTextForPlayer(i, "~w~You have hit a ~r~landmine~w~!", 2000, 3);
                            IsMine[o] = 0;
                            MineState[o] = 0;
                            if(MineOwner[o] != 255)
                            {
                                MineKiller[i] = MineOwner[o];
                                MineKilled[i] = 1;
                            }
                        }
                    }
                }
            }
        }
    }
    return 1;
}
GetObjectDistanceToPointEx(objectid,Float:x,Float:y,Float:z)
{
     new Float:x1,Float:y1,Float:z1;
     new Float:tmpdis;
     GetObjectPos(objectid,x1,y1,z1);
     tmpdis = floatsqroot(floatpower(floatabs(floatsub(x,x1)),2)+floatpower(floatabs(floatsub(y,y1)),2)+floatpower(floatabs(floatsub(z,z1)),2));
     return floatround(tmpdis);
}



Re : help with a not working filterscript? - ahmed2793 - 29.08.2011

any ideas plz?


Re: Re : help with a not working filterscript? - =WoR=G4M3Ov3r - 29.08.2011

Quote:
Originally Posted by ahmed2793
View Post
any ideas plz?
Did you try passin it with a vehicle ?


Re : help with a not working filterscript? - ahmed2793 - 30.08.2011

i tried with a car and on foot but no explosion!!!!!!!