[Inc] New SA-MP callbacks

Инклуды

Модератор: SJplayer

Аватара
Автор темы
Y_Less
Ефрейтор
Ефрейтор
Сообщения: 28
Зарегистрирован: 16 февраля 2014
Репутация: 2
С нами: 3 года 10 месяцев

[Inc] New SA-MP callbacks

Сообщение #1 Y_Less » 16 мая 2014, 14:44

Введение


Здесь собраны полезные callbacks для SA-MP, которые работает с любой версией SA-MP.

Код: Выделить всё

// Вызывается, когда игрок делает паузу своей игры.
forward OnPlayerPause(playerid);

// Вызывается, когда игрок возвращается в игру.
forward OnPlayerResume(playeridtime);

// Вызывается, когда игрок нажимает на клавишу.
forward OnPlayerHoldingKey(playeridkeys);

// Вызывается когда игрок отпускает клавишу.
forward OnPlayerReleaseKey(playeridkeystime);

// Вызывается, когда игрок падает с высокого места.
forward OnPlayerFall(playeridFloat:heightFloat:damage);

// Вызывается, когда игрок теряет пакеты.
forward OnPlayerPacketLoss(playeridFloat:oldlossFloat:newloss);

// Вызывается, когда игрок выводит из строя свой автомобиль.
forward OnPlayerCrashVehicle(playeridvehicleidFloat:damage);

// Вызывается, когда игрок использует торговый автомат.
forward OnPlayerUseVending(playerid);

// Вызывается при изменения FPS у игрока.
forward OnPlayerFPSChange(playeridoldfpsnewfps);

// Вызывается когда игрок  автомобиль другого игрока.
forward OnPlayerCarJack(playeridtargetidvehicleid);

// Вызывается, когда игрок полностью занимает все боеприпасы в своих оружиях.
forward OnPlayerWeaponEmpty(playeridweaponid);

// Вызывается, когда игрок стреляет другого игрока в своей команде.
forward OnPlayerFriendlyFire(playeridtargetidweaponid);

// Вызывается, когда игрок целиится в другого игрока.
forward OnPlayerTargetPlayer(playeridtargetidweaponid);

// Вызывается, когда игрок полностью отключает TextDraw режим выбора.
forward OnPlayerDisableCursor(playerid);

// Звонки, когда игрок стреляет больше боеприпасов, чем их оружие может вместить.
forward OnPlayerAntiReload(playeridweaponid); 


Функции


Код: Выделить всё

// Возвращает 1, если игрок находится в режиме паузы.
stock IsPlayerPaused(playerid);

// Возвращает 1, если игрок держит клавишу.
stock IsPlayerHoldingKey(playeridkeys);

// Возвращает потери пакетов игрока.
stock Float:GetPlayerPacketLoss(playerid);

// Возвращает время, что игрок был AFK.
stock GetPlayerPausedTime(playerid);

// Возвращает 1, если рядом с игроком находится любой торговый автомат.
stock IsPlayerNearVending(playerid);

// Возвращает количество FPS игрока.
stock GetPlayerFPS(playerid); 


Вот несколько примеров использования:

Код: Выделить всё

public OnPlayerResume(playeridtime)
{
    new
        
str[48];

    
format(strsizeof(str), "Ты остановился на %d миллисекунд."time);
    return 
SendClientMessage(playerid, -1str);
}

public 
OnPlayerCrashVehicle(playeridvehicleidFloat:damage)
{
    
SendClientMessage(playerid0xFF0000FF"Вы разбился ваш автомобиль!");
    
SendClientMessage(playerid0xFF0000FF"Пожалуйста узнайте, как водить машину!");
    return 
1;


Код

Код: Выделить всё

    

    
/*
            New SA-MP callbacks by Emmet
            Created on Sunday, January 26, 2014 at 11:58 AM.
    */
     
    #if !defined POTENTIAL_CRASH_DAMAGE
            #define POTENTIAL_CRASH_DAMAGE (55.0)
    #endif
     
    #if !defined POTENTIAL_SPEED_DROP
            #define POTENTIAL_SPEED_DROP (5.0)
    #endif
     
    #define IsCallbackUsed(%0) \
            
(g_CallbackInfo & %0)
     
    
#define CB_GetPlayerFlag(%0,%1) \
            
(g_aCallbackFlags[(%0)] & %1)
     
    
// Player variables
    
enum e_cbPlayerData {
            
e_cbTime,
            
e_cbTimer,
            
e_cbPresses,
            
e_cbLast,
            
e_cbVending,
            
e_cbFrames,
            
e_cbDrunk,
            
e_cbTarget,
            
Float:e_cbHealth,
            
Float:e_cbPacket,
            
Float:e_cbPosition[3]
    };
     
    
// Player flags
    
enum e_cbPlayerFlags (<<= 1) {
            
e_cbInitialized 1,
            
e_cbUpdate,
            
e_cbPaused,
            
e_cbHolding,
            
e_cbSelection
    
};
     
    
// Callback flags
    
enum e_cbCallbackFlags (<<= 1) {
            
CB_OnPlayerPause 1,
            
CB_OnPlayerResume,
            
CB_OnPlayerHoldingKey,
            
CB_OnPlayerReleaseKey,
            
CB_OnPlayerFall,
            
CB_OnPlayerPacketLoss,
            
CB_OnPlayerUseVending,
            
CB_OnPlayerCrashVehicle,
            
CB_OnPlayerFPSChange,
            
CB_OnPlayerCarJack,
            
CB_OnPlayerWeaponEmpty,
            
CB_OnPlayerFriendlyFire,
            
CB_OnPlayerTargetPlayer,
            
CB_OnPlayerDisableCursor,
            
CB_OnPlayerAntiReload
    
};
     
    static
        
e_cbCallbackFlagsg_CallbackInfo,
        
e_cbPlayerFlagsg_aCallbackFlags[MAX_PLAYERS],
            
g_cbCallbackData[MAX_PLAYERS][e_cbPlayerData];
     
    static
            
g_aLastVehicle[MAX_PLAYERS] = {INVALID_PLAYER_ID, ...},
            
g_aVehicleDamage[MAX_VEHICLES][3 char],
            
Float:g_aVehicleHealth[MAX_VEHICLES],
            
Float:g_aVehicleSpeed[MAX_VEHICLES],
            
g_aFiredShots[MAX_PLAYERS][5],
            
g_aLastWeapon[MAX_PLAYERS];
     
    static const
            
g_aClipData[] = {3417714710030305010011},
            
g_aClipSlots[] = {2223334455466};
     
    static const 
Float:g_aVendingMachines[][] = {
        {
2480.9548, -1958.521713.5830}, {2325.9185, -1645.955314.8270},
            {
2352.9932, -1357.159724.3984}, {2153.8535, -1015.723062.8835},
        {
2140.2710, -1161.499823.9922}, {2224.4141, -1153.44411025.7969},
            {
2060.1152, -1898.455413.5538}, {1634.0741, -2238.281513.5078},
        {
1729.7947, -1943.862813.5687}, {-16.1516, -90.85121003.5469},
            {-
17.5205, -90.96631003.5469},  {1929.5516, -1772.480313.5469},
        {
496.0115, -23.53061000.6797},  {500.6090, -2.10741000.6797},
            {
501.7604, -2.21851000.6797},   {-19.1310, -57.04531003.5469},
        {-
36.1302, -57.13511003.5469},  {1153.9125, -1460.972915.7969},
            {
1788.3973, -1369.247215.7578}, {2575.7300, -1284.61081060.9844},
        {
662.4797, -551.414116.3359},   {200.2021, -107.58681.5513},
            {
1278.5977372.221119.5547},   {2271.7053, -77.228326.5810},
        {-
2119.4229, -422.274735.5313}, {-2119.7649, -423.477035.5313},
            {-
2068.6082, -397.522535.5313}, {-2039.8768, -397.521835.5313},
        {-
2011.1292, -397.522235.5313}, {-2005.6145, -490.868635.5313},
            {-
2034.4011, -490.875435.5313}, {-2063.2300, -490.870535.5313},
        {-
2092.0771, -490.869735.5313}, {-2229.1521287.164535.3203},
            {-
1981.6025142.699127.6875},  {-1349.2971492.282011.1953},
        {-
1349.3674493.929511.1953},  {-2419.5833984.571245.2969},
            {-
2419.5457986.002045.2969},  {-1455.01732592.417555.8359},
        {-
252.99132599.688562.8582},  {-252.92742597.892162.8582},
            {-
862.75811537.423022.5870},  {-75.28121227.926919.7359},
        {-
14.72541176.175019.5634},   {1398.81982223.360111.0234},
            {
1659.43181722.097410.8281},  {1519.33501055.288610.8203},
        {
2503.13181244.509410.8203},  {2647.74241128.913811.1797},
            {
2845.74291294.297511.3906},  {2320.06182532.036410.8203},
        {
2086.58942071.411111.0579},  {-32.5264, -185.90411003.5469},
            {-
33.8699, -186.02131003.5469}, {361.6433159.35751008.3828},
        {
374.7823188.23601008.3893},  {351.6473206.11471008.3828},
            {
371.6005177.71061019.9844},  {373.8686, -178.93081000.6328},
        {
378.2982, -178.92201000.6328}, {315.9102, -140.5504999.6016}
    };
     
    
// Called when a player pauses their game.
    
forward OnPlayerPause(playerid);
     
    
// Called when a player returns to the game.
    
forward OnPlayerResume(playeridtime);
     
    
// Called when a player starts holding a key.
    
forward OnPlayerHoldingKey(playeridkeys);
     
    
// Called when a player releases a key.
    
forward OnPlayerReleaseKey(playeridkeystime);
     
    
// Called when a player falls from a tall height.
    
forward OnPlayerFall(playeridFloat:heightFloat:damage);
     
    
// Called when a player loses packets.
    
forward OnPlayerPacketLoss(playeridFloat:oldlossFloat:newloss);
     
    
// Called when a player crashes their vehicle.
    
forward OnPlayerCrashVehicle(playeridvehicleidFloat:damage);
     
    
// Called when a player uses a vending machine.
    
forward OnPlayerUseVending(playerid);
     
    
// Called when a player's FPS change.
    
forward OnPlayerFPSChange(playeridoldfpsnewfps);
     
    
// Called when a player jacks another player's vehicle.
    
forward OnPlayerCarJack(playeridtargetidvehicleid);
     
    
// Called when a player completely uses up all ammo in their weapon.
    
forward OnPlayerWeaponEmpty(playeridweaponid);
     
    
// Called when a player shoots another player in their team.
    
forward OnPlayerFriendlyFire(playeridtargetidweaponid);
     
    
// Called when a player aims at another player.
    
forward OnPlayerTargetPlayer(playeridtargetidweaponid);
     
    
// Called when a player explicitly disables textdraw selection mode.
    
forward OnPlayerDisableCursor(playerid);
     
    
// Calls when a player shoots more ammo than their weapon's clip can hold.
    
forward OnPlayerAntiReload(playeridweaponid);
     
    
stock IsPlayerNearVending(playerid)
    {
        for (new 
0sizeof(g_aVendingMachines); ++)
            {
            if (
GetPlayerDistanceFromPoint(playeridg_aVendingMachines[i][0], g_aVendingMachines[i][1], g_aVendingMachines[i][2]) > 3.0)
                continue;
     
                    else
                        return 
i;
        }
            return 
0;
    }
     
    
stock IsPlayerPaused(playerid)
            return 
GetCallbackFlag(playeridCB_PAUSED);
     
    
stock GetPlayerFPS(playerid)
            return (
g_cbCallbackData[playerid][e_cbFrames]);
     
    
stock GetPlayerPausedTime(playerid)
            return (
g_cbCallbackData[playerid][e_cbTime]);
     
    
stock CB_SelectTextDraw(playeridhovercolor)
    {
            
CB_SetPlayerFlag(playeride_cbSelectiontrue);
            return 
SelectTextDraw(playeridhovercolor);
    }
     
    
stock CB_CancelSelectTextDraw(playerid)
    {
            
CB_SetPlayerFlag(playeride_cbSelectionfalse);
            return 
CancelSelectTextDraw(playerid);
    }
     
    
stock static CB_SetPlayerFlag(playeride_cbPlayerFlags:flagbool:status)
    {
            if (
status)
                
g_aCallbackFlags[playerid] |= flag;
     
            else
                
g_aCallbackFlags[playerid] &= ~flag;
     
            return 
0;
    }
     
    
stock static CB_GetVehicleDriver(vehicleid)
    {
            for (new 
0GetMaxPlayers(); != l++)
            {
                    if (
GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPlayerVehicleID(i) == vehicleid)
                        return 
i;
            }
            return 
INVALID_PLAYER_ID;
    }
     
    
stock static Float:CB_GetVehicleSpeed(vehicleid)
    {
            static
                
Float:x,
                
Float:y,
                
Float:z,
                    
Float:speed;
     
            
GetVehicleVelocity(vehicleidxyz);
            
speed floatsqroot((x) + (y) + (z)) * 100;
     
            return 
speed;
    }
     
    
stock static CB_SearchCallbacks()
    {
            
enum e_CustomCallbacks {
                
e_CallbackName[32 char],
                
e_cbCallbackFlagse_CallbackFlag
            
};
            static const 
g_aCustomCallbacks[][e_CustomCallbacks] = {
                {!
"OnPlayerPause"CB_OnPlayerPause},
                    {!
"OnPlayerResume"CB_OnPlayerResume},
                    {!
"OnPlayerHoldingKey"CB_OnPlayerHoldingKey},
                    {!
"OnPlayerReleaseKey"CB_OnPlayerReleaseKey},
                {!
"OnPlayerFall"CB_OnPlayerFall},
                    {!
"OnPlayerPacketLoss"CB_OnPlayerPacketLoss},
                    {!
"OnPlayerUseVending"CB_OnPlayerUseVending},
                    {!
"OnPlayerCrashVehicle"CB_OnPlayerCrashVehicle},
                {!
"OnPlayerFPSChange"CB_OnPlayerFPSChange},
                    {!
"OnPlayerCarJack"CB_OnPlayerCarJack},
                    {!
"OnPlayerWeaponEmpty"CB_OnPlayerWeaponEmpty},
                    {!
"OnPlayerFriendlyFire"CB_OnPlayerFriendlyFire},
                {!
"OnPlayerTargetPlayer"CB_OnPlayerTargetPlayer},
                    {!
"OnPlayerDisableCursor"CB_OnPlayerDisableCursor},
                    {!
"OnPlayerAntiReload"CB_OnPlayerAntiReload}
            };
            for (new 
0!= sizeof(g_aCustomCallbacks); ++)
            {
                    if (
funcidx(g_aCustomCallbacks[i][e_CallbackName]) == -1)
                        continue;
     
                    
g_CallbackInfo |= g_aCustomCallbacks[i][e_CallbackFlag];
            }
    }
     
    public 
OnFilterScriptInit()
    {
        
CB_SearchCallbacks();
     
            if (
IsCallbackUsed(CB_OnPlayerPause) || IsCallbackUsed(CB_OnPlayerResume))
                    
SetTimer("CB_TabTimer"600true);
     
            
#if defined CB_OnFilterScriptInit
                
return CB_OnFilterScriptInit();
            
#else
                    
return 1;
            
#endif
    
}
     
    public 
OnGameModeInit()
    {
            
CB_SearchCallbacks();
     
            if (
IsCallbackUsed(CB_OnPlayerPause) || IsCallbackUsed(CB_OnPlayerResume))
                    
SetTimer("CB_TabTimer"600true);
     
            
#if defined CB_OnGameModeInit
                
return CB_OnGameModeInit();
            
#else
                    
return 1;
            
#endif
    
}
     
    public 
OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
    {
            if ((
IsCallbackUsed(CB_OnPlayerFriendlyFire)) && (hittype == BULLET_HIT_TYPE_PLAYER && GetPlayerTeam(playerid) == GetPlayerTeam(hitid) && GetPlayerTeam(playerid) != && GetPlayerTeam(playerid) != NO_TEAM))
                    
CallLocalFunction("OnPlayerFriendlyFire""ddd"playeridhitidweaponid);
     
            if ((
IsCallbackUsed(CB_OnPlayerWeaponEmpty)) && (22 <= weaponid <= 38 && GetPlayerWeaponState(playerid) == WEAPONSTATE_LAST_BULLET && GetPlayerAmmo(playerid) == 1))
                    
CallLocalFunction("OnPlayerWeaponEmpty""dd"playeridweaponid);
     
            if ((
IsCallbackUsed(CB_OnPlayerAntiReload)) && (22 <= weaponid <= 34) && (weaponid != 25 && weaponid != 33 && weaponid != 34))
            {
                    new
                            
index = (weaponid 22);
     
                    if (++ 
g_aFiredShots[playerid][g_aClipSlots[index]] > g_aClipData[index] && (g_aFiredShots[playerid][g_aClipSlots[index]] - g_aClipData[index]) > 2)
                    {
                        
g_aFiredShots[playerid][g_aClipSlots[index]] = 0;
                            
CallLocalFunction("OnPlayerAntiReload""dd"playeridweaponid);
                    }
            }
            
#if defined CB_OnPlayerWeaponShot
                
return CB_OnPlayerWeaponShot(playeridweaponidhittypehitidfXfYfZ);
            
#else
                    
return 1;
            
#endif
    
}
     
    public 
OnPlayerUpdate(playerid)
    {
            static
                
weaponid,
                
amount,
                
level,
                
Float:packet;
     
        if (!
CB_GetPlayerFlag(playeride_cbInitialized))
            {
                    
g_aCallbackFlags[playerid] |= e_cbInitialized;
     
                    
GetPlayerHealth(playeridg_cbCallbackData[playerid][e_cbHealth]);
                    
GetPlayerPos(playeridg_cbCallbackData[playerid][e_cbPosition][0], g_cbCallbackData[playerid][e_cbPosition][1], g_cbCallbackData[playerid][e_cbPosition][2]);
            }
            switch (
GetPlayerState(playerid))
            {
                case 
PLAYER_STATE_ONFOOT:
                {
                            if (
IsCallbackUsed(CB_OnPlayerAntiReload))
                            {
                                    if ((
weaponid GetPlayerWeapon(playerid)) != g_aLastWeapon[playerid])
                                    {
                                    if ((
22 <= g_aLastWeapon[playerid] <= 34) && (g_aLastWeapon[playerid] != 25 && g_aLastWeapon[playerid] != 33 && g_aLastWeapon[playerid] != 34))
                                                    
g_aFiredShots[playerid][g_aClipSlots[g_aLastWeapon[playerid] - 22]] = 0;
     
                                            
g_aLastWeapon[playerid] = weaponid;
                                    }
                                    else if ((
22 <= weaponid <= 34) && (weaponid != 25 && weaponid != 33 && weaponid != 34) && GetPlayerWeaponState(playerid) == WEAPONSTATE_RELOADING) {
                                            
g_aFiredShots[playerid][g_aClipSlots[weaponid 22]] = 0;
                                    }
                            }
                            if (
IsCallbackUsed(CB_OnPlayerTargetPlayer))
                            {
                            if (
g_cbCallbackData[playerid][e_cbTarget] == && GetPlayerTargetPlayer(playerid) == INVALID_PLAYER_ID)
                                    
g_cbCallbackData[playerid][e_cbTarget] = INVALID_PLAYER_ID;
     
                                    else if (
GetPlayerTargetPlayer(playerid) != g_cbCallbackData[playerid][e_cbTarget])
                                    {
                                    
g_cbCallbackData[playerid][e_cbTarget] = GetPlayerTargetPlayer(playerid);
                                    
CallLocalFunction("OnPlayerTargetPlayer""ddd"playeridg_cbCallbackData[playerid][e_cbTarget], GetPlayerWeapon(playerid));
                                    }
                            }
                            if (
IsCallbackUsed(CB_OnPlayerUseVending))
                            {
                                    if (
IsPlayerNearVending(playerid) && GetPlayerAnimationIndex(playerid) == 1660 && (GetTickCount() - g_cbCallbackData[playerid][e_cbVending]) > 3500)
                                    {
                                            
CallLocalFunction("OnPlayerUseVending""d"playerid);
                                            
g_cbCallbackData[playerid][e_cbVending] = GetTickCount();
                                    }
                            }
                            if (
IsCallbackUsed(CB_OnPlayerFall))
                            {
                            if (
GetPlayerAnimationIndex(playerid) < 1130 || GetPlayerAnimationIndex(playerid) > 1132)
                                    {
                                            static
                                                
Float:health,
                                                    
Float:x,
                                                    
Float:y,
                                                    
Float:z;
     
                                            
GetPlayerPos(playeridxyz);
                                            
GetPlayerHealth(playeridhealth);
     
                                            if (
g_cbCallbackData[playerid][e_cbHealth] > health && g_cbCallbackData[playerid][e_cbPosition][2] > z)
                                                    
CallLocalFunction("OnPlayerFall""dff"playeridfloatsub(g_cbCallbackData[playerid][e_cbPosition][2], z), floatsub(g_cbCallbackData[playerid][e_cbHealth], health));
     
                                            
GetPlayerHealth(playeridg_cbCallbackData[playerid][e_cbHealth]);
                                            
GetPlayerPos(playeridg_cbCallbackData[playerid][e_cbPosition][0], g_cbCallbackData[playerid][e_cbPosition][1], g_cbCallbackData[playerid][e_cbPosition][2]);
                                    }
                            }
                    }
                    case 
PLAYER_STATE_DRIVER:
                    {
                        new
                            
vehicleid GetPlayerVehicleID(playerid),
                            
Float:health;
     
                            
GetVehicleHealth(vehicleidhealth);
     
                            if ((
floatcmp(g_aVehicleHealth[vehicleid], health) > && floatabs(g_aVehicleHealth[vehicleid] - health) >= POTENTIAL_CRASH_DAMAGE) && floatabs(g_aVehicleSpeed[vehicleid] - CB_GetVehicleSpeed(vehicleid)) >= POTENTIAL_SPEED_DROP)
                            {
                                new
                                            
damage[4];
     
                                    
GetVehicleDamageStatus(vehicleiddamage[0], damage[1], damage[2], damage[3]);
     
                                for (new 
03++) if (g_aVehicleDamage[vehicleid]{i} != damage[i]) {
                                            
CallLocalFunction("OnPlayerCrashVehicle""ddf"playeridvehicleidfloatsub(g_aVehicleHealth[vehicleid], health));
     
                                            break;
                                    }
                                    for (new 
03++) if (g_aVehicleDamage[vehicleid]{i} != damage[i]) {
                                            
g_aVehicleDamage[vehicleid]{i} = damage[i];
                                    }
                            }
                            
g_aVehicleHealth[vehicleid] = health;
                            
g_aVehicleSpeed[vehicleid] = CB_GetVehicleSpeed(vehicleid);
                    }
            }
            if (
IsCallbackUsed(CB_OnPlayerFPSChange))
            {
                    if ((
level GetPlayerDrunkLevel(playerid)) < 100)
                    
SetPlayerDrunkLevel(playerid2000);
     
                    else if (
g_cbCallbackData[playerid][e_cbDrunk] != level)
                {
                        if ((
amount g_cbCallbackData[playerid][e_cbDrunk] - level) && g_cbCallbackData[playerid][e_cbFrames] != amount && <= amount <= 200)
                                    
CallLocalFunction("OnPlayerFPSChange""ddd"playeridg_cbCallbackData[playerid][e_cbFrames], amount);
     
                            
g_cbCallbackData[playerid][e_cbFrames] = amount;
                            
g_cbCallbackData[playerid][e_cbDrunk] = level;
                    }
            }
            if (
IsCallbackUsed(CB_OnPlayerPacketLoss))
            {
                    
packet NetStats_PacketLossPercent(playerid);
     
                    if (
floatcmp(packet0.0) != && floatcmp(packetg_cbCallbackData[playerid][e_cbPacket]) != 0) {
                        
CallLocalFunction("OnPlayerPacketLoss""dff"playeridg_cbCallbackData[playerid][e_cbPacket], packet);
     
                            
g_cbCallbackData[playerid][e_cbPacket] = packet;
                    }
            }
            
CB_SetPlayerFlag(playeride_cbUpdatetrue);
            
g_cbCallbackData[playerid][e_cbLast] = GetTickCount();
     
            
#if defined CB_OnPlayerUpdate
                    
return CB_OnPlayerUpdate(playerid);
            
#else
                    
return 1;
            
#endif
    
}
     
    public 
OnPlayerStateChange(playeridnewstateoldstate)
    {
            if (
IsCallbackUsed(CB_OnPlayerCarJack))
            {
                    if (
newstate == PLAYER_STATE_DRIVER)
                            
g_aLastVehicle[playerid] = GetPlayerVehicleID(playerid);
     
                    else if (
newstate == PLAYER_STATE_ONFOOT && oldstate == PLAYER_STATE_DRIVER)
                    {
                            static
                                    
driverid INVALID_PLAYER_ID;
     
                            if ((
driverid CB_GetVehicleDriver(g_aLastVehicle[playerid])) != INVALID_PLAYER_ID)
                                
CallLocalFunction("OnPlayerCarJack""ddd"driveridplayeridg_aLastVehicle[playerid]);
     
                            
g_aLastVehicle[playerid] = INVALID_VEHICLE_ID;
                    }
            }
            
#if defined CB_OnPlayerStateChange
                
return CB_OnPlayerStateChange(playeridnewstateoldstate);
            
#else
                    
return 1;
            
#endif
    
}
     
    public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
    {
        if (
IsCallbackUsed(CB_OnPlayerHoldingKey))
            {
                    if (!
CB_GetPlayerFlag(playeride_cbHolding))
                    {
                    
CB_SetPlayerFlag(playeride_cbHoldingtrue);
     
                    
g_cbCallbackData[playerid][e_cbTime] = GetTickCount();
                            
g_cbCallbackData[playerid][e_cbTimer] = SetTimerEx("CB_HoldingTimer"200true"dd"playeridnewkeys);
                    }
            }
            
#if defined CB_OnPlayerKeyStateChange
                
return CB_OnPlayerKeyStateChange(playeridnewkeysoldkeys);
            
#else
                    
return 1;
            
#endif
    
}
     
    public 
OnPlayerClickTextDraw(playeridText:clickedid)
    {
            if ((
IsCallbackUsed(CB_OnPlayerDisableCursor)) && (clickedid == Text:INVALID_TEXT_DRAW && g_aCallbackFlags[playerid] & e_cbSelection))
                
CallLocalFunction("OnPlayerDisableCursor""d"playerid);
     
            
#if defined CB_OnPlayerClickTextDraw
                    
return CB_OnPlayerClickTextDraw(playeridclickedid);
            
#else
                    
return 0;
            
#endif
    
}
     
    
forward CB_HoldingTimer(playeridkey);
    public 
CB_HoldingTimer(playeridkey)
    {
            static
                
keys[3];
     
            
GetPlayerKeys(playeridkeys[0], keys[1], keys[2]);
     
            if (
keys[0] & key)
            {
                
g_cbCallbackData[playerid][e_cbPresses]++;
                
CallLocalFunction("OnPlayerHoldingKey""dd"playeridkey);
            }
            else
            {
                if (
IsCallbackUsed(CB_OnPlayerReleaseKey) && g_cbCallbackData[playerid][e_cbPresses] > 0)
                    
CallLocalFunction("OnPlayerReleaseKey""ddd"playeridkeysGetTickCount() - g_cbCallbackData[playerid][e_cbTime]);
     
            
g_cbCallbackData[playerid][e_cbPresses] = 0;
     
            
KillTimer(g_cbCallbackData[playerid][e_cbTimer]);
                
CB_SetPlayerFlag(playeride_cbHoldingfalse);
            }
    }
     
    
forward CB_TabTimer();
    public 
CB_TabTimer()
    {
            for (new 
0GetMaxPlayers(); != l++)
            {
                if (
GetPlayerState(i) != PLAYER_STATE_ONFOOT && GetPlayerState(i) != PLAYER_STATE_DRIVER && GetPlayerState(i) != PLAYER_STATE_PASSENGER)
                    continue;
     
                    if (
CB_GetPlayerFlag(ie_cbUpdate))
                    {
                        if (
IsCallbackUsed(CB_OnPlayerResume) && CB_GetPlayerFlag(ie_cbPaused))
                            
CallLocalFunction("OnPlayerResume""dd"iGetTickCount() - g_cbCallbackData[i][e_cbTime]);
     
                        
CB_SetPlayerFlag(ie_cbUpdatefalse);
                        
CB_SetPlayerFlag(ie_cbPausedfalse);
                    }
                    else if (
IsCallbackUsed(CB_OnPlayerPause))
                    {
                            if (!
CB_GetPlayerFlag(ie_cbPaused) && (GetTickCount() - g_cbCallbackData[i][e_cbLast]) >= 2000)
                            {
                            
g_cbCallbackData[i][e_cbTime] = GetTickCount();
     
                                    
CallLocalFunction("OnPlayerPause""d"i);
                                    
CB_SetPlayerFlag(ie_cbPausedtrue);
                            }
                    }
            }
    }
     
    
#if defined _ALS_SelectTextDraw
            #undef SelectTextDraw
    #else
            #define _ALS_SelectTextDraw
    #endif
     
    #if defined _ALS_CancelSelectTextDraw
            #undef CancelSelectTextDraw
    #else
            #define _ALS_CancelSelectTextDraw
    #endif
     
    #if defined _ALS_OnFilterScriptInit
            #undef OnFilterScriptInit
    #else
            #define _ALS_OnFilterScriptInit
    #endif
     
    #if defined _ALS_OnGameModeInit
            #undef OnGameModeInit
    #else
            #define _ALS_OnGameModeInit
    #endif
     
    #if defined _ALS_OnPlayerStateChange
            #undef OnPlayerStateChange
    #else
            #define _ALS_OnPlayerStateChange
    #endif
     
    #if defined _ALS_OnPlayerKeyStateChange
            #undef OnPlayerKeyStateChange
    #else
            #define _ALS_OnPlayerKeyStateChange
    #endif
     
    #if defined _ALS_OnPlayerUpdate
            #undef OnPlayerUpdate
    #else
            #define _ALS_OnPlayerUpdate
    #endif
     
    #if defined _ALS_OnPlayerWeaponShot
            #undef OnPlayerWeaponShot
    #else
            #define _ALS_OnPlayerWeaponShot
    #endif
     
    #if defined _ALS_OnPlayerClickTextDraw
            #undef OnPlayerClickTextDraw
    #else
            #define _ALS_OnPlayerClickTextDraw
    #endif
     
    #define SelectTextDraw          CB_SelectTextDraw
    #define CancelSelectTextDraw    CB_CancelSelectTextDraw
     
    #define OnFilterScriptInit      CB_OnFilterScriptInit
    #define OnGameModeInit                  CB_OnGameModeInit
    #define OnPlayerUpdate                  CB_OnPlayerUpdate
    #define OnPlayerStateChange     CB_OnPlayerStateChange
    #define OnPlayerKeyStateChange  CB_OnPlayerKeyStateChange
    #define OnPlayerWeaponShot      CB_OnPlayerWeaponShot
    #define OnPlayerClickTextDraw   CB_OnPlayerClickTextDraw
     
    #if defined CB_OnPlayerUpdate
            
forward CB_OnPlayerUpdate(playerid);
    
#endif
     
    #if defined CB_OnFilterScriptInit
            
forward CB_OnFilterScriptInit();
    
#endif
     
    #if defined CB_OnGameModeInit
            
forward CB_OnGameModeInit();
    
#endif
     
    #if defined CB_OnPlayerStateChange
            
forward CB_OnPlayerStateChange(playeridnewstateoldstate);
    
#endif
     
    #if defined CB_OnPlayerKeyStateChange
            
forward CB_OnPlayerKeyStateChange(playeridnewkeysoldkeys);
    
#endif
     
    #if defined CB_OnPlayerWeaponShot
            
forward CB_OnPlayerWeaponShot(playeridweaponidhittypehitidfXfYfZ);
    
#endif
     
    #if defined CB_OnPlayerClickTextDraw
            
forward CB_OnPlayerClickTextDraw(playeridText:clickedid);
    
#endif

 
Spam Machine

! ! !


Вернуться в «Include»

Кто сейчас на форуме

Сейчас этот раздел просматривают: 2 гостя

Яндекс.Метрика
:: Часовой пояс: UTC+03:00