CreateExplosion-timer help
#1

Hi all,

I'm wondering why this isn't working. I want the people to have 10 seconds to run when they used /bomb. The timer isn't working and there's no explosion coming at all .

Код:
// ----------------------------------------------------------------------------------------------------------------------//

		new playercash;
		playercash = GetPlayerMoney(playerid);
		if(strcmp(cmd, "/bomb", true) == 0) {
		if (playercash < 50000) {
				SendClientMessage(playerid, COLOR_RED, "You need at least 50.000$ to buy a bomb!");
 				}
        else
        {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(giveplayerid, X, Y, Z);
        GivePlayerMoney(playerid, playercash-50000);
        SendClientMessage(playerid, COLOR_RED, "Bomb planted! 10 seconds till detonation!");
        SetTimerEx("CreateExplosion", 10000, false, "fffif", X, Y, Z, 10, 30.0);
        //CreateExplosion(X, Y, Z, 10, 30.0);
        SendClientMessage(playerid,COLOR_GREEN, "You have planted a bomb!");

        }
    return 1;
    }

// ----------------------------------------------------------------------------------------------------------------------//
Thanks!
Reply
#2

First of all: GivePlayerMoney(playerid, -50000);

It's not SET player money, but GIVE player money

Create a public function, which uses CreateExplosion

for example:

Код:
forward BlastBomb(Float:X, Float:Y, Float:Z, type, Float:radius);

[...]

public BlastBomb(Float:X, Float:Y, Float:Z, type, Float:radius)
{
   CreateExplosion(X, Y, Z, type, radius);
   return 1;
}
And call this function with the timer
Reply
#3

Thanks! I'll test it tomorrow, I'm typing this from my PSP.
Reply
#4

Sorry for the double post, but it didn't work. It's probably me doing something wrong, but what .

Код:
// On top 

forward BlastBomb(Float:X, Float:Y, Float:Z, type, Float:radius);

// In OnPlayerCommandText

		new playercash;
		playercash = GetPlayerMoney(playerid);
		if(strcmp(cmd, "/bomb", true) == 0) {
		if (playercash < 50000) {
				SendClientMessage(playerid, COLOR_RED, "You need at least 50.000$ to buy a bomb!");
 				}
        else
        {
        new Float:X, Float:Y, Float:Z;
        GetPlayerPos(playerid, X, Y, Z);
        GivePlayerMoney(playerid, playercash-50000);
        SendClientMessage(playerid, COLOR_RED, "Bomb planted! 10 seconds till detonation!");
        SetTimer("BlastBomb", 10000, 0);
        SendClientMessage(playerid,COLOR_GREEN, "You have planted a bomb!");

        }
    return 1;
    }

// Somewhere else (outside other functions)

public BlastBomb(Float:X, Float:Y, Float:Z, type, Float:radius)
{
   CreateExplosion(X, Y, Z, type, radius);
   return 1;
}
Could somebody help me with this please? Would be greatly appreciated.
Reply
#5

Could you like to say us the erros ?

put this under the public

new Float;
new Float:y;
new Float:z;
Reply
#6

This would be nice! if it would WORK
Reply
#7

Well the only error is the explosion, it's just not coming.
Reply
#8

Код:
// On top 

forward BlastBomb();
new Float:X, Float:Y, Float:Z;

// In OnPlayerCommandText

		new playercash;
		playercash = GetPlayerMoney(playerid);
		if(strcmp(cmd, "/bomb", true) == 0) {
		if (playercash < 50000) {
				SendClientMessage(playerid, COLOR_RED, "You need at least 50.000$ to buy a bomb!");
 				}
        else
        {
        GetPlayerPos(playerid, X, Y, Z);
        GivePlayerMoney(playerid, playercash-50000);
        SendClientMessage(playerid, COLOR_RED, "Bomb planted! 10 seconds till detonation!");
        SetTimer("BlastBomb", 10000, 0);
        SendClientMessage(playerid,COLOR_GREEN, "You have planted a bomb!");

        }
    return 1;
    }

// Somewhere else (outside other functions)

public BlastBomb()
{
   CreateExplosion(X, Y, Z, 10, 30.0);
   return 1;
}
Reply
#9

that works, awesome thank you so much!

Just one last question, how come I still keep my 50.000$?
Reply
#10

Quote:
Originally Posted by GTA_Rules
that works, awesome thank you so much!

Just one last question, how come I still keep my 50.000$?
EDIT:

use this

Код:
// On top 

forward BlastBomb();
new Float:X, Float:Y, Float:Z;

// In OnPlayerCommandText

		new playercash = GetPlayerMoney(playerid);
		if(strcmp(cmd, "/bomb", true) == 0) {
		if (playercash < 50000) {
				SendClientMessage(playerid, COLOR_RED, "You need at least 50.000$ to buy a bomb!");
 				}
        else
        {
        GetPlayerPos(playerid, X, Y, Z);
        GivePlayerMoney(playerid, -50000);
        SendClientMessage(playerid, COLOR_RED, "Bomb planted! 10 seconds till detonation!");
        SetTimer("BlastBomb", 10000, 0);
        SendClientMessage(playerid,COLOR_GREEN, "You have planted a bomb!");

        }
    return 1;
    }

// Somewhere else (outside other functions)

public BlastBomb()
{
   CreateExplosion(X, Y, Z, 10, 30.0);
   return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)