Timer Problem
#1

i have made this command and when i run this it makes explosion with the timer of 6 seconds but it explodes area where the player is after 6 seconds i don't know where is error !

Код:
 if ( !strcmp( "/cannonfire", cmdtext, true, 10 ) )
 {
   if(  GetPlayerMoney(playerid) < 10000 ) return SendClientMessage( playerid, 0xFF0000FF, "You dont have Enough Money For a Cannon Strike" );
    else
   {
         SendClientMessage( playerid, 0x00FF00FF, "Cannon fire on your position in 6 Seconds and counting!" );
         GivePlayerMoney( playerid, -10000 );
         SetTimerEx( "CannonExplosion", 6000, false, "i", playerid );
    }
    return true;
 }
and this

Код:
forward CannonExplosion(playerid);
public CannonExplosion(playerid)
{
    new
        Float: P[ 3 ];
    GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );
    CreateExplosion( P[ 0 ] + random( 5 ), P[ 1 ] + random( 5 ), P[ 2 ] + random( 5 ), 6, 100.0 );
}
Reply
#2

just get the player pos in the command and store it in the timerex .. and make some like

CannonExplosion(playerid,X,y,Z);


Reply
#3

try

pawn Код:
if ( !strcmp( "/cannonfire", cmdtext, true, 10 ) )
 {
   if(  GetPlayerMoney(playerid) < 10000 ) return SendClientMessage( playerid, 0xFF0000FF, "You dont have Enough Money For a Cannon Strike" );
    else
   {
        new Float:P[3];
        GetPlayerPos( playerid, P[ 0 ], P[ 1 ], P[ 2 ] );

         SendClientMessage( playerid, 0x00FF00FF, "Cannon fire on your position in 6 Seconds and counting!" );
         GivePlayerMoney( playerid, -10000 );
         SetTimerEx( "CannonExplosion", 6000, false, "ifff", playerid, P[0], P[1], P[2] );
    }
    return true;
 }

forward CannonExplosion(playerid, x, y, z);
public CannonExplosion(playerid, x, y, z)
{
    CreateExplosion( x + random( 5 ), y + random( 5 ), z + random( 5 ), 6, 100.0 );
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)