Y_TIMERS
#1

problem with Robstore timer no work S:, and the same process as the progress bar which if it works properly. Help pls . The load bar Apparently all perfectly but not execute the timer rob

pawn Код:
#include <YSI\y_timers>

#define MAX_ROB_STORE   2
#define TIENDA_1    0
#define TIENDA_2    1
new
        RobCP[MAX_ROB_STORE],
        PlayerBar:RobBar[MAX_PLAYERS],
        gBarValue[MAX_PLAYERS],
        gInc[MAX_PLAYERS] = 1,
        Timer:BarTime[MAX_PLAYERS],
        Timer:RobTime[MAX_PLAYERS],
        bool: pRobbing[MAX_PLAYERS][MAX_ROB_STORE],
        bool: Robbed[MAX_ROB_STORE]
;

public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    for (new i; i < MAX_ROB_STORE; ++i)
    {
        if(checkpointid == RobCP[i])
        {
            new message[256+1];
            format(message, 256,"[INFO]"COL_WHITE" Press "COL_ORANGE"~k~~SNEAK_ABOUT~"COL_WHITE" to rob, and "COL_ORANGE"~k~~PED_DUCK~"COL_WHITE" to stop rob");
            SendClientMessage(playerid, COLOR_SEXYGREEN, message);
        }
    }
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_WALK)
    {
        for (new i; i < MAX_ROB_STORE; ++i)
        {
            if(IsPlayerInDynamicCP(playerid, RobCP[i]))
            {
                if(GetPlayerTeam(playerid) != TEAM_CIVILIAN) return SendClientMessage( playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" You not are civilian, can't rob");
                if(pRobbing[playerid][i]) return SendClientMessage( playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" You are already robbing store");
                if(Robbed[i]) return SendClientMessage( playerid, COLOR_ERROR, "[ERROR]"COL_WHITE" Store has been robbed recently, please wait patiently!" );

                pRobbing[playerid][i] = true;
                Robbed[i] = true;

                RobBar[playerid] = CreatePlayerProgressBar(playerid, 547.000000, 446.000000, 10.000000, 50.000000, -11927297, 15.000000, BAR_DIRECTION_UP);
                SetPlayerProgressBarValue(playerid, RobBar[playerid], 0);
                gBarValue[playerid] = 0;
                ShowPlayerProgressBar(playerid, RobBar[playerid]);
                BarTime[playerid] = repeat ProgressBarTime(playerid);
                RobTime[playerid] = defer RobStore(playerid, i);
               
                AnimPlayer(playerid, "ROB_BANK", "CAT_SAFE_ROB", 2.5, 1, 0, 0, 0, 0);
                SetPlayerAttachedObject(playerid, 1, 1829,10,-0.3,0.5,-0.6,0,270,0);
                SetPlayerAttachedObject(playerid, 0, 1550, 1, 0.024558, -0.279748, -0.060589, 6.105677, 137.291320, 147.132202, 1.019888, 1.000000, 1.000000 );

                return 1;
            }
        }
    }
    if(newkeys & KEY_CROUCH && GetPlayerTeam(playerid) == TEAM_CIVILIAN) //quede aqui
    {
        for (new i; i < MAX_ROB_STORE; ++i)
        {
            if(IsPlayerInDynamicCP(playerid, RobCP[i]))
            {
                pRobbing[playerid][i] = false;
                Robbed[i] = false;
                SetPlayerProgressBarValue(playerid, RobBar[playerid], 0);
                DestroyPlayerProgressBar(playerid, RobBar[playerid]);
                stop BarTime[playerid];
                stop RobTime[playerid];
                RemovePlayerAttachedObject(playerid, 0);
                RemovePlayerAttachedObject(playerid, 1);
                ClearAnimations(playerid);
            }
        }
    }
    return 1;
}

timer RobStore[15000](playerid, storeid)
{
    new
        randMoney,
        probtorob,
        string[128]
    ;

    probtorob = Math.RandomEx(1, 5);
   
    pRobbing[playerid][storeid] = false;
    SetPlayerProgressBarValue(playerid, RobBar[playerid], 0);
    DestroyPlayerProgressBar(playerid, RobBar[playerid]);
    stop BarTime[playerid];
    stop RobStore(playerid, storeid);
    RemovePlayerAttachedObject(playerid, 0);
    RemovePlayerAttachedObject(playerid, 1);
    ClearAnimations(playerid);

    if(probtorob == 2)
    {
        format(string, sizeof(string), "[ROBBERY]"COL_WHITE" You have failed the robbery, your wanted increase %d!", WantedxRob);
        return SendClientMessage(playerid, COLOR_MONEY, string);
    }

    if(storeid == TIENDA_1)
    {
        randMoney = Math.RandomEx(MinRob, MaxRob);
        format(string, sizeof(string), "[ROBBERY]"COL_WHITE" %s has robbed "COL_MONEY"$%s"COL_WHITE" from TIENDA 1!", GetPlayerName(playerid), Comma(randMoney));
        SendClientMessageToAll(COLOR_MONEY, string);

    }
    else if(storeid == TIENDA_2)
    {
        randMoney = Math.RandomEx(MinRob, MaxRob);
        format(string, sizeof(string), "[ROBBERY]"COL_WHITE" %s has robbed "COL_MONEY"$%s"COL_WHITE" from TIENDA 2!", GetPlayerName(playerid), Comma(randMoney));
        SendClientMessageToAll(COLOR_MONEY, string);
    }

    if(GetPVarInt(playerid, "MoneyCase") == 1) GivePlayerMonez(playerid, randMoney*2);
    else GivePlayerMonez(playerid, randMoney);
    GivePlayerEXP(playerid, ServerEXP);
    GivePlayerWanted(playerid, 6);
    return 1;
}
//------------------[PROGRESS BAR]----------------------
timer ProgressBarTime[1000](playerid)
{
    if(gBarValue[playerid] <= 0) gInc[playerid] = 1;

    SetPlayerProgressBarValue(playerid, RobBar[playerid], gBarValue[playerid]);
    gBarValue[playerid] += gInc[playerid];
}
Reply
#2

BUMP!
Reply
#3

use foreach.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)