Проблема с KillTimer

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Пожалуйста, помогите исправить плагин. Все логи в ошибках ;)

Ошибка:
PHP:
[SM] Native "KillTimer" reported: Invalid timer handle e66b0795 (error 3)
[SM] Displaying call stack trace for plugin "RPG.smx":
[SM]   [0]  Line 355, rpg/helpers.inc::Timer_KillTimer()

Код:
PHP:
public Action:Timer_KillTimer(Handle:timer,Handle:hTimer)
{
    if(hTimer!=INVALID_HANDLE)
        KillTimer(hTimer, true);
        
    return Plugin_Stop;
}

--------- предложенный фикс с аллмодерса ---------
Мне тут предложили фикс на аллмодерсе, но один сказал что тоже не правильно.
Вот сама статья на аллмодерсе forums.alliedmods.net
Вот код фикса:
PHP:
public Action:Timer_KillTimer(Handle:timer,Handle:hTimer)
{
        if(hTimer != INVALID_HANDLE)
        {
                KillTimer(hTimer, true);
                hTimer = INVALID_HANDLE;
				
                return Plugin_Stop;
        }
        return Plugin_Continue;
}
 

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Попробуй так.
Вместо (poisonsmoke.inc)
PHP:
public Action:Timer_OnPoisonsmInterval(Handle:timer,Handle:datapack)
{
    ResetPack(datapack); // Set the reading position to the first cell
    new thrower=ReadPackCell(datapack);  // Get the client index of owner
    new Float:x=ReadPackFloat(datapack); // Get the x value of the smokegrenade
    new Float:y=ReadPackFloat(datapack); // Get the y value of the smokegrenade
    new Float:z=ReadPackFloat(datapack); // Get the z value of the smokegrenade
    
    new Float:victimloc[3];
    new amount;
    
    if(IsClientInGame(thrower))
    {
        new Float:smokeloc[3];
        smokeloc[0]=x;
        smokeloc[1]=y;
        smokeloc[2]=z;

        // Make green beam ring effect (Visible to teammates if freeforall is disabled)
        if(g_poisonsmUpgradeConfigCache[UpgradeConfig_Effects]&&g_CoreConfigCache[CoreConfig_freeforall]==0)
        {
            new color[4]={150,0,150,127};
            new team=GetClientTeam(thrower);
            if(team==2)
                BeamRingEffect("@t",smokeloc,0.0,225.0,g_poisonsmUpgradeConfigCache[UpgradeConfig_Interval],3.0,color,0.0,0);
            if(team==3)
                BeamRingEffect("@ct",smokeloc,0.0,225.0,g_poisonsmUpgradeConfigCache[UpgradeConfig_Interval],3.0,color,0.0,0);
        }
        for(new victim=1;victim<=MaxClients;victim++)
            if(IsClientInGame(victim))
                if(IsPlayerAlive(victim)&&thrower!=victim)
                {
                    GetClientAbsOrigin(victim,victimloc);
                    if(GetDistanceBetween(smokeloc,victimloc)<=225.0)
                    {
                        amount=GetClientHealth(victim)-RoundToNearest(g_poisonsmUpgradeConfigCache[UpgradeConfig_Amount]*GetPlayerUpgradeLevel(thrower,g_modulepoisonsm));
                        if(amount<1)
                        {
                            if(g_poisonsmUpgradeConfigCache[UpgradeConfig_Suicide]==0)
                                amount=1;
                            else
                                amount=0;
                        }
                        SetEntityHealth(victim,amount);
                    }
                }
        return Plugin_Continue;
    }

    CloseHandle(datapack);
    return Plugin_Stop;
}
Вставить
PHP:
public poisonsm_SmokegrenadeDetonated(thrower,Float:x,Float:y,Float:z)
{
    if(IsValidPlayer(thrower))
        if(GetClientTeam(thrower)!=g_poisonsmUpgradeConfigCache[UpgradeConfig_TeamLock])
            if(GetPlayerUpgradeLevel(thrower,g_modulepoisonsm))
            {
                new Handle:datapack=CreateDataPack();
                WritePackCell(datapack,thrower); // Write the client index of owner
                WritePackFloat(datapack,x); // Write the x value of the smokegrenade
                WritePackFloat(datapack,y); // Write the y value of the smokegrenade
                WritePackFloat(datapack,z); // Write the z value of the smokegrenade
                hTimer=CreateTimer(g_poisonsmUpgradeConfigCache[UpgradeConfig_Interval],Timer_OnPoisonsmInterval,datapack,TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
                CreateTimer(20.0,Timer_KillTimer,hTimer,TIMER_FLAG_NO_MAPCHANGE);
            }
}

public Action:Timer_OnPoisonsmInterval(Handle:timer,Handle:datapack)
{
    ResetPack(datapack); // Set the reading position to the first cell
    new thrower=ReadPackCell(datapack);  // Get the client index of owner
    new Float:x=ReadPackFloat(datapack); // Get the x value of the smokegrenade
    new Float:y=ReadPackFloat(datapack); // Get the y value of the smokegrenade
    new Float:z=ReadPackFloat(datapack); // Get the z value of the smokegrenade
    
    new Float:victimloc[3];
    new amount;
    
    if(IsClientInGame(thrower))
    {
        new Float:smokeloc[3];
        smokeloc[0]=x;
        smokeloc[1]=y;
        smokeloc[2]=z;

        // Make green beam ring effect (Visible to teammates if freeforall is disabled)
        if(g_poisonsmUpgradeConfigCache[UpgradeConfig_Effects]&&g_CoreConfigCache[CoreConfig_freeforall]==0)
        {
            new color[4]={150,0,150,127};
            new team=GetClientTeam(thrower);
            if(team==2)
                BeamRingEffect("@t",smokeloc,0.0,225.0,g_poisonsmUpgradeConfigCache[UpgradeConfig_Interval],3.0,color,0.0,0);
            if(team==3)
                BeamRingEffect("@ct",smokeloc,0.0,225.0,g_poisonsmUpgradeConfigCache[UpgradeConfig_Interval],3.0,color,0.0,0);
        }
        for(new victim=1;victim<=MaxClients;victim++)
            if(IsClientInGame(victim))
                if(IsPlayerAlive(victim)&&thrower!=victim)
                {
                    GetClientAbsOrigin(victim,victimloc);
                    if(GetDistanceBetween(smokeloc,victimloc)<=225.0)
                    {
                        amount=GetClientHealth(victim)-RoundToNearest(g_poisonsmUpgradeConfigCache[UpgradeConfig_Amount]*GetPlayerUpgradeLevel(thrower,g_modulepoisonsm));
                        if(amount<1)
                        {
                            if(g_poisonsmUpgradeConfigCache[UpgradeConfig_Suicide]==0)
                                amount=1;
                            else
                                amount=0;
                        }
                        SetEntityHealth(victim,amount);
                    }
                }
        return Plugin_Continue;
    }
	hTimer = INVALID_HANDLE;
    CloseHandle(datapack);
    return Plugin_Stop;	
}
В thc_rpg добавь вверху строку
PHP:
new Handle:hTimer = INVALID_HANDLE;

И вместо (helpers.inc)
PHP:
public Action:Timer_KillTimer(Handle:timer,Handle:hTimer)
{
    if(hTimer!=INVALID_HANDLE)
        KillTimer(hTimer, true);
        
    return Plugin_Stop;
}
Вставить
PHP:
public Action:Timer_KillTimer(Handle:timer,Handle:hTimer)
{
    if(hTimer!=INVALID_HANDLE)
	{
		hTimer = INVALID_HANDLE;
        KillTimer(hTimer, true);
	}
    return Plugin_Stop;
}

А откуда данный код?

Ошибка:
PHP:
//// RPG.sp
// thc_rpg/helpers.inc(352) : warning 219: local variable "hTimer" shadows a variable at a preceding level
// thc_rpg/upgrades/poisonsmoke.inc(162) : warning 219: local variable "hTimer" shadows a variable at a preceding level
// thc_rpg/upgrades/poisonsmoke.inc(168) : error 021: symbol already defined: "poisonsm_SmokegrenadeDetonated"
//
// 1 Error.

Добавлено через 45 минут
Кстати, а знаешь что нибудь об ошибки типа:
PHP:
[Core] [SavePlayerData] Player аааааааааааааааРnot saved to database, Reason: Incorrect string value: '\xD0' for column 'name' at row 7716
 
Последнее редактирование:
Сообщения
2,587
Реакции
1,344
Sergey Grinko, Попробовал, всего одно предупреждение, даже не ошибка:

C-подобный:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// thc_rpg.sp
// thc_rpg/helpers.inc(347) : warning 219: local variable "hTimer" shadows a variable at a preceding level
// Header size:          18240 bytes
// Code size:           229920 bytes
// Data size:            70228 bytes
// Stack/heap size:      16384 bytes; Total requirements:  334772 bytes
//
// 1 Warning.
//
// Compilation Time: 2,25 sec
// ----------------------------------------

Press enter to exit ...
 

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Sergey Grinko, Попробовал, всего одно предупреждение, даже не ошибка:

C-подобный:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// thc_rpg.sp
// thc_rpg/helpers.inc(347) : warning 219: local variable "hTimer" shadows a variable at a preceding level
// Header size:          18240 bytes
// Code size:           229920 bytes
// Data size:            70228 bytes
// Stack/heap size:      16384 bytes; Total requirements:  334772 bytes
//
// 1 Warning.
//
// Compilation Time: 2,25 sec
// ----------------------------------------

Press enter to exit ...

Это с этим что он скинул))
А так что с кодировкой?
 
Сообщения
2,587
Реакции
1,344
Кодировка стоит UTF-8 без BOM, у меня когда открываешь нотепадом - он сразу преобразовывает кодировку.
Брал из второго поста.
 

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Кодировка стоит UTF-8 без BOM, у меня когда открываешь нотепадом - он сразу преобразовывает кодировку.
Брал из второго поста.

У меня все файлы в ANSI, а когда меняешь на utf8. То одни ошибки...
А если поставить utf8 без bom, то когда заново открываешь файл, а там опять ANSI
 

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Опять

PHP:
L 02/18/2013 - 05:24:01: [SM] Native "KillTimer" reported: Invalid timer handle 216803ba (error 3)
L 02/18/2013 - 05:24:01: [SM] Displaying call stack trace for plugin "RPG.smx":
L 02/18/2013 - 05:24:01: [SM]   [0]  Line 356, thc_rpg/helpers.inc::Timer_KillTimer()
 

Impulse72

Участник
Сообщения
244
Реакции
163
Добавлено через 45 минут
PHP:
[Core] [SavePlayerData] Player аааааааааааааааРnot saved to database, Reason: Incorrect string value: '\xD0' for column 'name' at row 7716
Интересно, когда у пользователей будет привычка ПЕРЕВОДИТЬ на русский язык текст ошибки. \xD0 - неверное стринговое значение.
 

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Интересно, когда у пользователей будет привычка ПЕРЕВОДИТЬ на русский язык текст ошибки. \xD0 - неверное стринговое значение.

Я так понял что это из-за русских символов в нике, но тоже зависит от длины.
На форумах говорят что это из-за кодировки, но при смене кодировки на win1251 вылезает еще интересней ошибка...

А как объясните такую ошибку?
Я если честно вообще не понял в чем прикол
PHP:
[RPG.smx] [Core] [GetPlayerRank] Rank of player mentoll is not calculateable, Reason: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
 
Последнее редактирование:

Sergey Grinko

Участник
Сообщения
140
Реакции
10
Подчинил проблему с сохранением никами))
Поставил макс. длину 31 за место 32, и сразу ошибки исчезли.
 
Сверху Снизу