Помогите "вылечить" плагин ..

M

MihailM

Здравствуйте , помогите исправить плагин .. а то что-то не нравиться ему :
Вот кусок кода/функции :
PHP:
public Action:Timer_Ammo(Handle:timer, any:client)
{
    if (g_bEnabled)
    {
        decl String:sClassName[64];
        new iWeaponIndex = 0;
        for (new i = 0, iWeapon, iAmount, iAmmo; i < 5; i++) {
            if ((iWeapon = GetPlayerWeaponSlot(client, i)) != -1) {  // 66 строчка 
                iAmount = GetEntData(iWeapon, g_iClipOffset);
                GetEntityNetClass(iWeapon,sClassName,sizeof(sClassName));
                ReplaceString(sClassName,sizeof(sClassName),"CWeapon","");
                iWeaponIndex = GetWeaponIndex(sClassName);
                if (iWeaponIndex > -1 && g_iAmount[iWeaponIndex] > -1) {
                    iAmount = g_iAmount[iWeaponIndex];
                    iAmmo = g_iAmmo[iWeaponIndex];
                    SetEntData(client, iAmmo, iAmount, _, true);
                }
            }
        }
    }
    return Plugin_Continue;
}
PHP:
L 09/16/2014 - 00:43:13: [SM] Native "GetPlayerWeaponSlot" reported: Client 13 is not in game
L 09/16/2014 - 00:43:13: [SM] Displaying call stack trace for plugin "dod_ammo.smx":
L 09/16/2014 - 00:43:13: [SM]   [0]  Line 66, /home/forums/content/files/4/1/6/8/1/56564.attach::Timer_Ammo()
L 09/16/2014 - 01:16:31: Error log file session closed.
Заранее благодарен !
 

AlmazON

Не путать с самим yand3xmail
Сообщения
5,099
Реакции
2,755
SteamM, так, например:
PHP:
public Action:Timer_Ammo(Handle:timer, any:client)
{
    if (g_bEnabled && client && IsClientInGame(client))
    {
        decl String:sClassName[64];
        new iWeaponIndex = 0;
        for (new i = 0, iWeapon, iAmount, iAmmo; i < 5; i++) {
            if ((iWeapon = GetPlayerWeaponSlot(client, i)) != -1) {  // 66 строчка 
                iAmount = GetEntData(iWeapon, g_iClipOffset);
                GetEntityNetClass(iWeapon,sClassName,sizeof(sClassName));
                ReplaceString(sClassName,sizeof(sClassName),"CWeapon","");
                iWeaponIndex = GetWeaponIndex(sClassName);
                if (iWeaponIndex > -1 && g_iAmount[iWeaponIndex] > -1) {
                    iAmount = g_iAmount[iWeaponIndex];
                    iAmmo = g_iAmmo[iWeaponIndex];
                    SetEntData(client, iAmmo, iAmount, _, true);
                }
            }
        }
    }
    return Plugin_Continue;
}
А вообще, лучше таймер просто переделать.
 
M

MihailM

А вообще, лучше таймер просто переделать.
Знать бы как , я просто нуб в программирование . А так Спасибо , сейчас опробуем !

Добавлено через 22 часа 40 минут
Вроде ошибки пропали , но вроде и плагин перестал работать . Хотя сейчас другие проблемы с сервером .
 
Последнее редактирование модератором:
Сверху Снизу