Avoid blowing up myself with mine system
#1

Hi!


I created a simple mine system pretty long ago..
But I didn't found any solution to avoid blowing up myself when placing it..

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

new Float:X,Float:Y,Float:Z;
forward bombS(playerid); //Bomb safe so you not blowing up when you plant it.
new atb[MAX_PLAYERS]; //Anti blow up

#define Blue 0x631BE0FF
#define Green 0x29D419FF

public OnFilterScriptInit()
{


    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

#endif


public OnPlayerSpawn(playerid)
{
    return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mine", cmdtext, true, 4) == 0)
    {
        GetPlayerPos(playerid, X, Y, Z);
        if(IsPlayerInRangeOfPoint(playerid, 3.0,  X, Y, Z))
        CreateObject(1006, X, Y, Z,Float:X, Float:Y, Float:Z);
       
        if(atb[playerid] == 1)
        {
            SetTimerEx("bombS",9000,0,"i",playerid);
            atb[playerid]=0; //Anti blow up
            CreateExplosion(X, Y, Z, 10, 20.0);
        }

        return 1;
    }
    return 0;
}



public bombS(playerid)
{
    atb[playerid]=1;
    SendClientMessage(playerid, Green, "Your bomb is ready!");
}
I have tried with that "anti blow up thing"
As shown in the script. But it didn't helped.

I have thouht that I can use a timer too but then when someone steps on it, it will not blow up
directly(?).

Antother thing I have thinking about (It's a kinda TDM GM)
When somone steps on it, it will check the players color and then compare it to the player who steps on it.

If they're equal to each other, they're in same team and will not blow up.
If it's not equal to each other (emeny and and player) the player will blow up (who stepped on it)

Or compare it with some teams. But I'm not fully sure how to do this..
I just know abit of it.
Can someone show a small example?.

Thanks alot!
Reply
#2

EDIT: Can you give me an idea on how this thing is going to work? Will it be like, When you /mine it will plant a bomb and create explosion after few seconds?
Reply
#3

Quote:
Originally Posted by Sid_Alexander
Посмотреть сообщение
EDIT: Can you give me an idea on how this thing is going to work? Will it be like, When you /mine it will plant a bomb and create explosion after few seconds?
Yeah, I have created so when you type /plant it will be created a object in your position (GetPlayerPos) and when someone walks on it, it will explode (detected by isPlayerInRangeOfPoint)

But it's exploding when I'm planting it xD.
Reply
#4

Can't you just make a simple admin system for that, such as /asetlevel [User] [Level 1(User)-Level2(Admin)]
And if the user is a Admin, Then it excludes them from the detonation radius?
Reply
#5

I suppose you could add a bool to control this. When the bomb is placed down, Set the bool to false. Add a timer, and when it ends the bool is set to true. After a player over it, Make sure that the bool is set to true and they are near the bomb.
Reply
#6

Quote:
Originally Posted by davve95
Посмотреть сообщение
Yeah, I have created so when you type /plant it will be created a object in your position (GetPlayerPos) and when someone walks on it, it will explode (detected by isPlayerInRangeOfPoint)

But it's exploding when I'm planting it xD.
You're gunna need to assign the position through variables, Because you can't use GetObjectPos, So if you're creating a mine, Make a variable, And add positions of a player to it, And then on player update, See if a player is in range of that variables point, Then Explode the mine.
Reply
#7

The command to create a mine will have to set a connected property (as a variable) to false so that it won't blow up. You can then have it set to true after 2 seconds (using SetTimerEx), giving the player 2 seconds to move away.

Alternatively, store the name of the player who created the mine and store the time it was created using time(). When it detonated, compare for the player using strcmp and see how long it has been since creation using time() - MineInfo[mineid][timeCreated] (if it is 2000 or greater, then detonate)
Reply
#8

Just say that this mine is this player's mine. If the player stepping on the mine is the owner of this mine, don't explode this mine. If you don't know how to interpret this then ask someone to explain what I'm saying, I'm going to bed... :P
Reply
#9

He's saying, If you own the mine it shouldn't blow up, Otherwise yes.
Reply
#10

Quote:
Originally Posted by Lawbringer
Посмотреть сообщение
The command to create a mine will have to set a connected property (as a variable) to false so that it won't blow up. You can then have it set to true after 2 seconds (using SetTimerEx), giving the player 2 seconds to move away.

Alternatively, store the name of the player who created the mine and store the time it was created using time(). When it detonated, compare for the player using strcmp and see how long it has been since creation using time() - MineInfo[mineid][timeCreated] (if it is 2000 or greater, then detonate)
The other suggestions seems abit complicated.. So I guess I will got with this.
I don't understand to fully, so could you show a small example?

Or the bool thing would be eaiser I think. Can somone show a example on some of them?..
Thanks and sorry for bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)