[Help]Timer
#1

I need help with this:
I made a timer so after 5 seconds bomb will explode,
I already made a command to plant a bomb I just need a help with this.

Here is a code:
pawn Код:
forward Bomb();
public Bomb()
{
    new Float:X, Float:Y, Float:Z;
    new playerid;
    Timer1 = SetTimerEx("Bomb",5000,false,"d",playerid);
    CreateExplosion(X, Y, Z, 2, 2);
    KillTimer(Timer1);
}
And here is a command to plant a bomb:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
            {
            case 1:
                {
                switch(listitem)
                {
                    case 0:
                    {
                    new Float:X, Float:Y, Float:Z;
                    GetPlayerPos(playerid, X, Y, Z);
                    CreateObject(1252, X, Y, Z, 0.0, 0.0, 96.0);
                }
    }       }
    }
}
Reply
#2

Cut out [pawn] Timer1 = SetTimerEx("Bomb",5000,false,"d",playerid);/pawn] and put it inside your command instead.

You also have to change
pawn Код:
forward Bomb();
public Bomb()
to
pawn Код:
forward Bomb(playerid);
public Bomb(playerid)
Reply
#3

You also have to change
pawn Код:
forward Bomb();
public Bomb()
to
pawn Код:
forward Bomb(playerid);
public Bomb(playerid)
[/QUOTE]

I got 2 errors

C:\Users\..\...\samp03bsvr_R2_win32\filterscripts\ BombMenu.pwn(110) : warning 219: local variable "playerid" shadows a variable at a preceding level
C:\Users\..\....\samp03bsvr_R2_win32\filterscripts \BombMenu.pwn(110) : warning 203: symbol is never used: "playerid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Reply
#4

nvm I fixed the problem.
Now I am going to test it,anyway thank you for the help !
Reply
#5

Remove "new playerid;"

This forum requires that you wait 120 seconds between posts. Please try again in 70 seconds. - go hang yourself

Ok, good job ^^
Reply
#6

It still doesnt work, bomb doesnt explode after 5 seconds !
Reply
#7

You have to GetPlayerPos(playerid,X,Y,Z); on the explosion otherwize it will create a explosion at the coordinates 0,0,0
Reply
#8

thanks it works but how can i create that it will explode at there where is the bomb planted ?
Reply
#9

sorry for double post .. I fixed the problem, thanks guys !
Reply
#10

Add this to the top of your script.
pawn Код:
new Float:bombx, Float:bomby, Float:bombz;
On your command, change this.
pawn Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
CreateObject(1252, X, Y, Z, 0.0, 0.0, 96.0);
To this.
pawn Код:
GetPlayerPos(playerid, bombx, bomby, bombz);
CreateObject(1252, bombx, bomby, bombz, 0.0, 0.0, 96.0);

Now on your public, change the CreateExplosion to this.
pawn Код:
CreateExplosion(bombx, bomby, bombz, 2, 2);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)