Вычесть доллары по запросу

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской
Здравствуйте, товарищи. Подскажите, что я не так прописал... Суть паблика: событие бонусного монстра с воровством золота. Мне же нужно было переделать его под доллары. Выдать награду за убийство бонусного монстра получилось (работает), а вот событие воровства не удалось изменить. Почему то, монстр перестал тырить голду.

Вот оригинальный, рабочий паблик, сделанный под воровство золота:

PHP:
public MakeBonusFx(iEnt)
{
    iEnt -= TASK_BONUS_FX;

    if(!is_valid_ent(iEnt) || g_IsGameEnded)
        return;

    if(entity_get_float(iEnt, EV_FL_health) <= 0.0)
        return;

    new entlist[33];
    new num
    static iChance;
    if(!iChance) iChance = g_ConfigValues[CFG_BONUS_STAEL_CHANCE];


    if( (num =  find_sphere_class(iEnt, "player", g_BonusThiefRange, entlist, 32) ) )
    {
        new Float:fOrigin[3], Origin[3];

        new iPlayer, iRandom;

        for(new i ; i < num ; i++)
        {
            iPlayer = entlist[i];
            if(!is_user_alive(iPlayer))
                continue;

            if(random(iChance - 1) == 0)
            {
                if(!fm_is_ent_visible(iPlayer, iEnt))
                    continue;

                if(!g_PlayerInfo[iPlayer][PLAYER_GOLD])
                    continue;

                static iMin, iMax;
                if(!iMin) iMin = g_ConfigValues[CFG_BONUS_MIN_GOLD]
                if(!iMax) iMax = g_ConfigValues[CFG_BONUS_MAX_GOLD]
                iRandom = random_num(iMin, iMax)

                if(iRandom == 0)
                    continue;

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
                write_byte(TE_BEAMENTPOINT)
                write_short(iEnt | 0x1000)
                write_coord_f(fOrigin[0])
                write_coord_f(fOrigin[1])
                write_coord_f(fOrigin[2])
                write_short(g_SpriteLighting)
                write_byte(0) // framerate
                write_byte(4) // framerate
                write_byte(4) // life
                write_byte(40)  // width
                write_byte(0)   // noise
                write_byte(255)   // r, g, b
                write_byte(255)   // r, g, b
                write_byte(0)   // r, g, b
                write_byte(255)    // brightness
                write_byte(10)        // speed
                message_end()

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                FVecIVec(fOrigin, Origin);

                message_begin(MSG_BROADCAST ,SVC_TEMPENTITY, Origin,iPlayer) //message begin
                write_byte(TE_SPRITETRAIL)
                write_coord(Origin[0]) // start position
                write_coord(Origin[1])
                write_coord(Origin[2])
                write_coord(Origin[0] + random_num(-3,3)) // end position
                write_coord(Origin[1]+ random_num(-3,3))
                write_coord(Origin[2]+ random_num(-3, 3))
                write_short(g_SpriteBloodDrop) // sprite index
                write_byte(random_num(30, 60)) // count
                write_byte(random_num(5, 15)) // life in 0.1's
                write_byte(5) // scale in 0.1's
                write_byte(random_num(10, 30)) // velocity along vector in 10's
                write_byte(random_num(3, 5)) // randomness of velocity in 10's
                message_end()

                client_cmd(iPlayer, "spk sound/%s", g_SoundFile[SND_COIN]);

                static szName[33];
                get_user_name(iPlayer, szName, 32);

                g_BonusRobbedGold += iRandom;

                if(g_PlayerInfo[iPlayer][PLAYER_GOLD] -  iRandom <= 0)
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр убит и ограблен ^x03%s^x01", CHAT_PREFIX, szName);
                    g_PlayerInfo[iPlayer][PLAYER_GOLD] = 0
                }
                else
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр украл ^x04%d золота^x01 у ^x03%s^x01", CHAT_PREFIX,iRandom,  szName);
                    g_PlayerInfo[iPlayer][PLAYER_GOLD] -= iRandom;
                }

            }
        }
    }

    set_task(0.5, "MakeBonusFx", iEnt + TASK_BONUS_FX);
}
А вот мой вариант, переделанный под доллары:

PHP:
public MakeBonusFx(iEnt, id)
{
    new plMoney[32];
    plMoney[id] = cs_get_user_money(id)

    iEnt -= TASK_BONUS_FX;

    if(!is_valid_ent(iEnt) || g_IsGameEnded)
        return;

    if(entity_get_float(iEnt, EV_FL_health) <= 0.0)
        return;

    new entlist[33];
    new num
    static iChance;
    if(!iChance) iChance = g_ConfigValues[CFG_BONUS_STAEL_CHANCE];


    if( (num =  find_sphere_class(iEnt, "player", g_BonusThiefRange, entlist, 32) ) )
    {
        new Float:fOrigin[3], Origin[3];

        new iPlayer, iRandom;

        for(new i ; i < num ; i++)
        {
            iPlayer = entlist[i];
            if(!is_user_alive(iPlayer))
                continue;

            if(random(iChance - 1) == 0)
            {
                if(!fm_is_ent_visible(iPlayer, iEnt))
                    continue;

                if(!plMoney[iPlayer])
                    continue;

                static iMin, iMax;
                if(!iMin) iMin = g_ConfigValues[CFG_BONUS_MIN_GOLD]
                if(!iMax) iMax = g_ConfigValues[CFG_BONUS_MAX_GOLD]
                iRandom = random_num(iMin, iMax)

                if(iRandom == 0)
                    continue;

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
                write_byte(TE_BEAMENTPOINT)
                write_short(iEnt | 0x1000)
                write_coord_f(fOrigin[0])
                write_coord_f(fOrigin[1])
                write_coord_f(fOrigin[2])
                write_short(g_SpriteLighting)
                write_byte(0) // framerate
                write_byte(4) // framerate
                write_byte(4) // life
                write_byte(40)  // width
                write_byte(0)   // noise
                write_byte(255)   // r, g, b
                write_byte(255)   // r, g, b
                write_byte(0)   // r, g, b
                write_byte(255)    // brightness
                write_byte(10)        // speed
                message_end()

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                FVecIVec(fOrigin, Origin);

                message_begin(MSG_BROADCAST ,SVC_TEMPENTITY, Origin,iPlayer) //message begin
                write_byte(TE_SPRITETRAIL)
                write_coord(Origin[0]) // start position
                write_coord(Origin[1])
                write_coord(Origin[2])
                write_coord(Origin[0] + random_num(-3,3)) // end position
                write_coord(Origin[1]+ random_num(-3,3))
                write_coord(Origin[2]+ random_num(-3, 3))
                write_short(g_SpriteBloodDrop) // sprite index
                write_byte(random_num(30, 60)) // count
                write_byte(random_num(5, 15)) // life in 0.1's
                write_byte(5) // scale in 0.1's
                write_byte(random_num(10, 30)) // velocity along vector in 10's
                write_byte(random_num(3, 5)) // randomness of velocity in 10's
                message_end()

                client_cmd(iPlayer, "spk sound/%s", g_SoundFile[SND_COIN]);

                static szName[33];
                get_user_name(iPlayer, szName, 32);

                g_BonusRobbedGold += iRandom;

                if(cs_set_user_money(id, plMoney[iPlayer] -  iRandom <= 0))
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр убит и ограблен ^x03%s^x01", CHAT_PREFIX, szName);
                    cs_set_user_money(id, plMoney[iPlayer] = 0)
                }
                else
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр украл ^x04%d золота^x01 у ^x03%s^x01", CHAT_PREFIX,iRandom,  szName);
                    cs_set_user_money(id, plMoney[iPlayer] -= iRandom);
                }

            }
        }
    }

    set_task(0.5, "MakeBonusFx", iEnt + TASK_BONUS_FX);
}
вроде, сделал по аналогии, все скомпилилось хорошо, а результата нет. Не ворует, жулик:( Подскажите, где я провтыкал, пожалуйста)
На всякий, прикрепил полный оригинальный исходник плагина.
 

Вложения

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
rxki, а если так ?
Код:
public MakeBonusFx(iEnt)
{
    new iPlayer, plMoney[32];
    plMoney[iPlayer] = cs_get_user_money(iPlayer)

    iEnt -= TASK_BONUS_FX;

    if(!is_valid_ent(iEnt) || g_IsGameEnded)
        return;

    if(entity_get_float(iEnt, EV_FL_health) <= 0.0)
        return;

    new entlist[33];
    new num
    static iChance;
    if(!iChance) iChance = g_ConfigValues[CFG_BONUS_STAEL_CHANCE];


    if( (num =  find_sphere_class(iEnt, "player", g_BonusThiefRange, entlist, 32) ) )
    {
        new Float:fOrigin[3], Origin[3];

        new iRandom;

        for(new i ; i < num ; i++)
        {
            iPlayer = entlist[i];
            if(!is_user_alive(iPlayer))
                continue;

            if(random(iChance - 1) == 0)
            {
                if(!fm_is_ent_visible(iPlayer, iEnt))
                    continue;

                if(!plMoney[iPlayer])
                    continue;

                static iMin, iMax;
                if(!iMin) iMin = g_ConfigValues[CFG_BONUS_MIN_GOLD]
                if(!iMax) iMax = g_ConfigValues[CFG_BONUS_MAX_GOLD]
                iRandom = random_num(iMin, iMax)

                if(iRandom == 0)
                    continue;

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
                write_byte(TE_BEAMENTPOINT)
                write_short(iEnt | 0x1000)
                write_coord_f(fOrigin[0])
                write_coord_f(fOrigin[1])
                write_coord_f(fOrigin[2])
                write_short(g_SpriteLighting)
                write_byte(0) // framerate
                write_byte(4) // framerate
                write_byte(4) // life
                write_byte(40)  // width
                write_byte(0)   // noise
                write_byte(255)   // r, g, b
                write_byte(255)   // r, g, b
                write_byte(0)   // r, g, b
                write_byte(255)    // brightness
                write_byte(10)        // speed
                message_end()

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                FVecIVec(fOrigin, Origin);

                message_begin(MSG_BROADCAST ,SVC_TEMPENTITY, Origin,iPlayer) //message begin
                write_byte(TE_SPRITETRAIL)
                write_coord(Origin[0]) // start position
                write_coord(Origin[1])
                write_coord(Origin[2])
                write_coord(Origin[0] + random_num(-3,3)) // end position
                write_coord(Origin[1]+ random_num(-3,3))
                write_coord(Origin[2]+ random_num(-3, 3))
                write_short(g_SpriteBloodDrop) // sprite index
                write_byte(random_num(30, 60)) // count
                write_byte(random_num(5, 15)) // life in 0.1's
                write_byte(5) // scale in 0.1's
                write_byte(random_num(10, 30)) // velocity along vector in 10's
                write_byte(random_num(3, 5)) // randomness of velocity in 10's
                message_end()

                client_cmd(iPlayer, "spk sound/%s", g_SoundFile[SND_COIN]);

                static szName[33];
                get_user_name(iPlayer, szName, 32);

                g_BonusRobbedGold += iRandom;

                if(cs_set_user_money(iPlayer, plMoney[iPlayer] -  iRandom <= 0))
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр убит и ограблен ^x03%s^x01", CHAT_PREFIX, szName);
                    cs_set_user_money(iPlayer, plMoney[iPlayer] = 0)
                }
                else
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр украл ^x04%d золота^x01 у ^x03%s^x01", CHAT_PREFIX,iRandom,  szName);
                    cs_set_user_money(iPlayer, plMoney[iPlayer] -= iRandom);
                }

            }
        }
    }

    set_task(0.5, "MakeBonusFx", iEnt + TASK_BONUS_FX);
}
 

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
rxki, ошибок в консоли никаких нет ?
 

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
rxki,
Код:
public MakeBonusFx(iEnt)
{
    new iPlayer, plMoney;

    iEnt -= TASK_BONUS_FX;

    if(!is_valid_ent(iEnt) || g_IsGameEnded)
        return;

    if(entity_get_float(iEnt, EV_FL_health) <= 0.0)
        return;

    new entlist[33];
    new num
    static iChance;
    if(!iChance) iChance = g_ConfigValues[CFG_BONUS_STAEL_CHANCE];

    if( (num =  find_sphere_class(iEnt, "player", g_BonusThiefRange, entlist, 32) ) )
    {
        new Float:fOrigin[3], Origin[3];

        new iRandom;

        for(new i ; i < num ; i++)
        {
            iPlayer = entlist[i]; plMoney = cs_get_user_money(iPlayer);
            
            if(!is_user_alive(iPlayer))
                continue;

            if(random(iChance - 1) == 0)
            {
                if(!fm_is_ent_visible(iPlayer, iEnt))
                    continue;

                if(!plMoney[iPlayer])
                    continue;

                static iMin, iMax;
                if(!iMin) iMin = g_ConfigValues[CFG_BONUS_MIN_GOLD]
                if(!iMax) iMax = g_ConfigValues[CFG_BONUS_MAX_GOLD]
                iRandom = random_num(iMin, iMax)

                if(iRandom == 0)
                    continue;

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
                write_byte(TE_BEAMENTPOINT)
                write_short(iEnt | 0x1000)
                write_coord_f(fOrigin[0])
                write_coord_f(fOrigin[1])
                write_coord_f(fOrigin[2])
                write_short(g_SpriteLighting)
                write_byte(0) // framerate
                write_byte(4) // framerate
                write_byte(4) // life
                write_byte(40)  // width
                write_byte(0)   // noise
                write_byte(255)   // r, g, b
                write_byte(255)   // r, g, b
                write_byte(0)   // r, g, b
                write_byte(255)    // brightness
                write_byte(10)        // speed
                message_end()

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                FVecIVec(fOrigin, Origin);

                message_begin(MSG_BROADCAST ,SVC_TEMPENTITY, Origin,iPlayer) //message begin
                write_byte(TE_SPRITETRAIL)
                write_coord(Origin[0]) // start position
                write_coord(Origin[1])
                write_coord(Origin[2])
                write_coord(Origin[0] + random_num(-3,3)) // end position
                write_coord(Origin[1]+ random_num(-3,3))
                write_coord(Origin[2]+ random_num(-3, 3))
                write_short(g_SpriteBloodDrop) // sprite index
                write_byte(random_num(30, 60)) // count
                write_byte(random_num(5, 15)) // life in 0.1's
                write_byte(5) // scale in 0.1's
                write_byte(random_num(10, 30)) // velocity along vector in 10's
                write_byte(random_num(3, 5)) // randomness of velocity in 10's
                message_end()

                client_cmd(iPlayer, "spk sound/%s", g_SoundFile[SND_COIN]);

                static szName[33];
                get_user_name(iPlayer, szName, 32);

                g_BonusRobbedGold += iRandom;

                if(cs_set_user_money(iPlayer, plMoney[iPlayer] -  iRandom <= 0))
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр убит и ограблен ^x03%s^x01", CHAT_PREFIX, szName);
                    cs_set_user_money(iPlayer, plMoney[iPlayer] = 0)
                }
                else
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр украл ^x04%d золота^x01 у ^x03%s^x01", CHAT_PREFIX,iRandom,  szName);
                    cs_set_user_money(iPlayer, plMoney[iPlayer] -= iRandom);
                }

            }
        }
    }

    set_task(0.5, "MakeBonusFx", iEnt + TASK_BONUS_FX);
}
 

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской

Вложения

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
rxki, a, tochno.

:Wacko2:
Код:
public MakeBonusFx(iEnt)
{
    iEnt -= TASK_BONUS_FX;

    if(!is_valid_ent(iEnt) || g_IsGameEnded)
        return;

    if(entity_get_float(iEnt, EV_FL_health) <= 0.0)
        return;

    new entlist[33];
    new num
    static iChance;
    if(!iChance) iChance = g_ConfigValues[CFG_BONUS_STAEL_CHANCE];

    if( (num =  find_sphere_class(iEnt, "player", g_BonusThiefRange, entlist, 32) ) )
    {
        new Float:fOrigin[3], Origin[3];

        new iPlayer, iRandom;

        for(new i ; i < num ; i++)
        {
            iPlayer = entlist[i];
            
            if(!is_user_alive(iPlayer))
                continue;

            if(random(iChance - 1) == 0)
            {
                if(!fm_is_ent_visible(iPlayer, iEnt))
                    continue;

                if(!cs_get_user_money(iPlayer))
                    continue;

                static iMin, iMax;
                if(!iMin) iMin = g_ConfigValues[CFG_BONUS_MIN_GOLD]
                if(!iMax) iMax = g_ConfigValues[CFG_BONUS_MAX_GOLD]
                iRandom = random_num(iMin, iMax)

                if(iRandom == 0)
                    continue;

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                message_begin(MSG_BROADCAST, SVC_TEMPENTITY )
                write_byte(TE_BEAMENTPOINT)
                write_short(iEnt | 0x1000)
                write_coord_f(fOrigin[0])
                write_coord_f(fOrigin[1])
                write_coord_f(fOrigin[2])
                write_short(g_SpriteLighting)
                write_byte(0) // framerate
                write_byte(4) // framerate
                write_byte(4) // life
                write_byte(40)  // width
                write_byte(0)   // noise
                write_byte(255)   // r, g, b
                write_byte(255)   // r, g, b
                write_byte(0)   // r, g, b
                write_byte(255)    // brightness
                write_byte(10)        // speed
                message_end()

                entity_get_vector(iPlayer, EV_VEC_origin, fOrigin);

                FVecIVec(fOrigin, Origin);

                message_begin(MSG_BROADCAST ,SVC_TEMPENTITY, Origin,iPlayer) //message begin
                write_byte(TE_SPRITETRAIL)
                write_coord(Origin[0]) // start position
                write_coord(Origin[1])
                write_coord(Origin[2])
                write_coord(Origin[0] + random_num(-3,3)) // end position
                write_coord(Origin[1]+ random_num(-3,3))
                write_coord(Origin[2]+ random_num(-3, 3))
                write_short(g_SpriteBloodDrop) // sprite index
                write_byte(random_num(30, 60)) // count
                write_byte(random_num(5, 15)) // life in 0.1's
                write_byte(5) // scale in 0.1's
                write_byte(random_num(10, 30)) // velocity along vector in 10's
                write_byte(random_num(3, 5)) // randomness of velocity in 10's
                message_end()

                client_cmd(iPlayer, "spk sound/%s", g_SoundFile[SND_COIN]);

                static szName[33];
                get_user_name(iPlayer, szName, 32);

                g_BonusRobbedGold += iRandom;

                if(cs_set_user_money(iPlayer, cs_get_user_money(iPlayer) - iRandom <= 0))
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр убит и ограблен ^x03%s^x01", CHAT_PREFIX, szName);
                    cs_set_user_money(iPlayer, cs_get_user_money(iPlayer) = 0)
                }
                else
                {
                    client_print_color(0, print_team_default, "%s^x01 Бонусный монстр украл ^x04%d золота^x01 у ^x03%s^x01", CHAT_PREFIX,iRandom,  szName);
                    cs_set_user_money(iPlayer, cs_get_user_money(iPlayer) - iRandom);
                }

            }
        }
    }

    set_task(0.5, "MakeBonusFx", iEnt + TASK_BONUS_FX);
}
 

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской
g52, в моем примере ошибок при компиле не было, он просто не делал то, что нужно
 

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
rxki, исходник полный можешь приложить ?
 

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской

To be or not to be

Пользователь
Регистрация
9 Июн 2017
Сообщения
1.215
Симпатии
304
rxki, td_const.inc нужен
 
K

kapangaIII

if(cs_set_user_money(id, plMoney[iPlayer] - iRandom <= 0))
Ничего странного?
 

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской
, в оригинале это звучит так
if(g_PlayerInfo[iPlayer][PLAYER_GOLD] - iRandom <= 0)
т.е., как я понял, это условие, когда кол.голды игрока отнимается рандомное кол.голды и оно <= нулю.
Пока писал это, подумал, что там нужно не cs_set_user_money, а cs_get_user_money , да?)[DOUBLEPOST=1548330355][/DOUBLEPOST]rxki, хотя, нет. бред написал на счет get)[DOUBLEPOST=1548330706][/DOUBLEPOST]if(cs_get_user_money(iPlayer) - iRandom <= 0) - так тоже не помогло
 
K

kapangaIII

if(cs_get_user_money(iPlayer)-iRandom < 1){
plMoney[iPlayer] = 0;
cs_set_user_money(id, plMoney[iPlayer]);
}
else{
plMoney[iPlayer] -= iRandom;
cs_set_user_money(id, cs_get_user_money(iPlayer)-iRandom);
}
 

rxki

Пользователь
Регистрация
5 Янв 2019
Сообщения
208
Симпатии
5
Пол
Мужской
,

, попробовал, все равно не ворует
 
K

kapangaIII

Значит код изначально не работает или перехватываются msgmoney.
EventMoney[DOUBLEPOST=1548339208][/DOUBLEPOST]
if(cs_get_user_money(iPlayer)-iRandom < 1){
plMoney[iPlayer] = 0;
cs_set_user_money(iPlayer, plMoney[iPlayer]);
}
else{
plMoney[iPlayer] -= iRandom;
cs_set_user_money(iPlayer, cs_get_user_money(iPlayer)-iRandom);
}

Попробуй так. Просто скопируй и вставь.
 
Последнее редактирование модератором:
Сверху Снизу