Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Players Library Include (playerslib.inc)
- * Very useful and awesome player stuff:
- - Funtions
- - Callbacks
- - Macros !:D!
- Author: (creator)
- * Gammix
- (c) Copyright 2015
- * This file is provided as is (no warranties).
- */
- /*
- FUNCTIONS:
- //playerfuncs.inc
- native GivePlayerScore(playerid, score);
- native SetPlayerMoney(playerid, money);
- native RemovePlayerWeapoon(playerid, weaponid);
- native SetPlayerFacingPoint(playerid, Float:x, Float:y);
- native IsPlayerFacingPoint(playerid, Float:x, Float:y, Float:range = 10.0);
- native SetPlayerFacingPlayer(playerid, targetid);
- native IsPlayerFacingPlayer(playerid, targetid, Float:range = 10.0);
- native IsPlayerBehindPlayer(playerid, targetid, Float:range = 10.0);
- native GetPlayerWeaponAmmo(playerid, weaponid);
- native SetPlayerWeaponAmmo(playerid, weaponid, ammo);
- native SetPlayerWalkingStyle(playerid, style);
- native GetPlayerWalkingStyle(playerid);
- native _
- //playercalls.inc
- native IsPlayerPaused(playerid);
- native IsPlayerInClassSelection(playerid);
- native GetPlayerPausedTime(playerid);
- native _
- //playerstates.inc
- native IsPlayerSpawned(playerid);
- native IsPlayerSpectating(playerid);
- native IsPlayerDriver(playerid);
- native IsPlayerInClassSelection(playerid);
- native IsPlayerDead(playerid);
- native _
- //playerstats.inc
- native GetPlayerKills(playerid);
- native GetPlayerDeaths(playerid);
- native GetPlayerSpree(playerid);
- native GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds);
- native GetPlayerHeadshots(playerid);
- native GetPlayerWeaponShots(playerid);
- native GetPlayerWeaponHits(playerid);
- CALLBACKS:
- /playerfuncs.inc
- public public OnPlayerWalk(playerid, style)
- //playercalls.inc
- public OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz);
- public OnPlayerFacingAngleChange(playerid, Float:newangle, Float:oldangle);
- public OnPlayerWeaponChange(playerid, newweapon, oldweapon);
- public OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth);
- public OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour);
- public OnPlayerVirtualWorldChange(playerid, newworld, oldworld);
- public OnPlayerSkinChange(playerid, newskin, oldskin);
- public OnPlayerPingChange(playerid, newping, oldping);
- public OnPlayerAmmoChange(playerid, weaponid, newammo, oldammo);
- public OnPlayerKillPlayer(playerid, killerid, weaponid);
- public OnPlayerPause(playerid);
- public OnPlayerUnpause(playerid, time);
- public OnPlayerFakeKill(playerid, count);
- //playerstates.inc
- //no callbacks
- //playerstats.inc
- public OnPlayerHeadshot(playerid, issuerid, weaponid)
- */
- //-----
- //playercalls.inc
- //-----
- //playercalls.inc
- #define PAUSE_CHECK_TIME 5 // This is the time after which the player will be considered as PAUSED.
- #define ANTI_FAKE_KILL //comment this if you don't want anti fake kill system
- enum PlayerCallEnum
- {
- Float:P_HEALTH,
- Float:P_ARMOUR,
- Float:P_X,
- Float:P_Y,
- Float:P_Z,
- Float:P_ANGLE,
- P_WORLDID,
- P_SKIN,
- P_WEAPON,
- P_AMMO,
- P_PING,
- P_LAST_UPDATE,
- bool:P_PAUSED,
- P_PAUSE_CHECK_TIMER,
- P_PAUSED_TIME,
- P_DEATHS,
- P_DEATH_TICK
- }
- static gPlayerCall[MAX_PLAYERS][PlayerCallEnum];
- //playerfuncs.inc
- static gWalkingStyle[MAX_PLAYERS];
- //playerstats.inc
- enum PlayerEnum
- {
- P_KILLS,
- P_DEATHS,
- P_SPREE,
- P_TIME[3],
- P_TIMER,
- P_HEADSHOTS,
- P_SHOTS,
- P_HITS
- }
- static gPlayer[MAX_PLAYERS][PlayerEnum];
- //-----------------------
- #if ! defined IsValidWeapon
- #define IsValidWeapon(%0) \
- (%0 < 47)
- #endif
- #if ! defined IsPlayerInClassSelection
- static IsPlayerInClassSelection(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new Float: health = 0.0;
- GetPlayerHealth(playerid, health);
- if(GetPlayerState(playerid) == PLAYER_STATE_WASTED && health > 0.0) return true;
- return false;
- }
- #endif
- stock GetPlayerPausedTime(playerid)
- {
- return gPlayerCall[playerid][P_PAUSED_TIME];
- }
- stock IsPlayerPaused(playerid)
- {
- return gPlayerCall[playerid][P_PAUSED];
- }
- public OnPlayerConnect(playerid)
- {
- gPlayerCall[playerid][P_PAUSED] = false;
- gPlayerCall[playerid][P_PAUSED_TIME] = 0;
- gPlayerCall[playerid][P_PAUSE_CHECK_TIMER] = SetTimerEx("CheckPlayerPause", 500, true, "i", playerid);
- //playerstats.inc
- gPlayer[playerid][P_KILLS] = 0;
- gPlayer[playerid][P_DEATHS] = 0;
- gPlayer[playerid][P_SPREE] = 0;
- for(new i; i < 3; i++) gPlayer[playerid][P_TIME][i] = 0;
- gPlayer[playerid][P_TIMER] = SetTimerEx("OnPlayerUpdateSecond", 1000, true, "i", playerid);
- gPlayer[playerid][P_HEADSHOTS] = 0;
- gPlayer[playerid][P_SHOTS] = 0;
- gPlayer[playerid][P_HITS] = 0;
- //
- gPlayerCall[playerid][P_DEATHS] = 0;
- gPlayerCall[playerid][P_DEATH_TICK] = 0;
- return CallLocalFunction("HOoK_OnPlayerConnect", "i", playerid);
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect HOok_OnPlayerConnect
- forward HOok_OnPlayerConnect(playerid);
- public OnPlayerDisconnect(playerid, reason)
- {
- gPlayerCall[playerid][P_PAUSED] = false;
- gPlayerCall[playerid][P_PAUSED_TIME] = 0;
- KillTimer(gPlayerCall[playerid][P_PAUSE_CHECK_TIMER]);
- //playerstats.inc
- KillTimer(gPlayer[playerid][P_TIMER]);
- //
- return CallLocalFunction("HOok_OnPlayerDisconnect", "ii", playerid, reason);
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect HOok_OnPlayerDisconnect
- forward HOok_OnPlayerDisconnect(playerid, reason);
- public OnPlayerSpawn(playerid)
- {
- GetPlayerPos(playerid, gPlayerCall[playerid][P_X], gPlayerCall[playerid][P_Y], gPlayerCall[playerid][P_Z]);
- GetPlayerFacingAngle(playerid, gPlayerCall[playerid][P_ANGLE]);
- gPlayerCall[playerid][P_WORLDID] = GetPlayerVirtualWorld(playerid);
- GetPlayerHealth(playerid, gPlayerCall[playerid][P_HEALTH]);
- GetPlayerArmour(playerid, gPlayerCall[playerid][P_ARMOUR]);
- gPlayerCall[playerid][P_SKIN] = GetPlayerSkin(playerid);
- gPlayerCall[playerid][P_WEAPON] = GetPlayerWeapon(playerid);
- gPlayerCall[playerid][P_AMMO] = GetPlayerAmmo(playerid);
- gPlayerCall[playerid][P_PING] = GetPlayerPing(playerid);
- //playerstats.inc
- gPlayer[playerid][P_SPREE] = 0;
- //
- return CallLocalFunction("HOok_OnPlayerSpawn", "i", playerid);
- }
- #if defined _ALS_OnPlayerSpawn
- #undef OnPlayerSpawn
- #else
- #define _ALS_OnPlayerSpawn
- #endif
- #define OnPlayerSpawn HOok_OnPlayerSpawn
- forward HOok_OnPlayerSpawn(playerid);
- public OnPlayerUpdate(playerid)
- {
- //OnPlayerUnpause
- gPlayerCall[playerid][P_LAST_UPDATE] = GetTickCount();
- if(gPlayerCall[playerid][P_PAUSED])
- {
- if(CallLocalFunction("OnPlayerUnpause", "ii", playerid, gPlayerCall[playerid][P_PAUSED_TIME]))
- {
- gPlayerCall[playerid][P_PAUSED] = false;
- gPlayerCall[playerid][P_PAUSED_TIME] = 0;
- KillTimer(gPlayerCall[playerid][P_PAUSE_CHECK_TIMER]);
- gPlayerCall[playerid][P_PAUSE_CHECK_TIMER] = SetTimerEx("CheckPlayerPause", 500, true, "i", playerid);
- }
- }
- //OnPlayerPosChange
- static Float:player_pos[3];
- GetPlayerPos(playerid, player_pos[0], player_pos[1], player_pos[2]);
- if( player_pos[0] != gPlayerCall[playerid][P_X] ||
- player_pos[1] != gPlayerCall[playerid][P_Y] ||
- player_pos[2] != gPlayerCall[playerid][P_Z])
- {
- if(CallLocalFunction("OnPlayerPosChange", "iffffff", playerid, player_pos[0], player_pos[1], player_pos[2], gPlayerCall[playerid][P_X], gPlayerCall[playerid][P_Y], gPlayerCall[playerid][P_Z]))
- {
- GetPlayerPos(playerid, gPlayerCall[playerid][P_X], gPlayerCall[playerid][P_Y], gPlayerCall[playerid][P_Z]);
- }
- else
- {
- SetPlayerPos(playerid, gPlayerCall[playerid][P_X], gPlayerCall[playerid][P_Y], gPlayerCall[playerid][P_Z]);
- }
- }
- //OnPlayerFacingAngleChange
- static Float:player_angle;
- GetPlayerFacingAngle(playerid, player_angle);
- if(player_angle != gPlayerCall[playerid][P_ANGLE])
- {
- if(CallLocalFunction("OnPlayerFacingAngleChange", "iff", playerid, player_angle, gPlayerCall[playerid][P_ANGLE]))
- {
- GetPlayerFacingAngle(playerid, gPlayerCall[playerid][P_ANGLE]);
- }
- else
- {
- SetPlayerFacingAngle(playerid, gPlayerCall[playerid][P_ANGLE]);
- }
- }
- //OnPlayerWeaponChange
- static player_weapon;
- player_weapon = GetPlayerWeapon(playerid);
- if(player_weapon != gPlayerCall[playerid][P_WEAPON])
- {
- if(CallLocalFunction("OnPlayerWeaponChange", "iii", playerid, player_weapon, gPlayerCall[playerid][P_WEAPON]))
- {
- gPlayerCall[playerid][P_WEAPON] = player_weapon;
- }
- else
- {
- SetPlayerArmedWeapon(playerid, gPlayerCall[playerid][P_WEAPON]);
- }
- }
- //OnPlayerHealthChange
- static Float:player_health;
- GetPlayerHealth(playerid, player_health);
- if(player_health != gPlayerCall[playerid][P_HEALTH])
- {
- if(CallLocalFunction("OnPlayerHealthChange", "iff", playerid, player_health, gPlayerCall[playerid][P_HEALTH]))
- {
- GetPlayerHealth(playerid, gPlayerCall[playerid][P_HEALTH]);
- }
- else
- {
- SetPlayerHealth(playerid, gPlayerCall[playerid][P_HEALTH]);
- }
- }
- //OnPlayerArmourChange
- static Float:player_armour;
- GetPlayerArmour(playerid, player_armour);
- if(player_armour != gPlayerCall[playerid][P_ARMOUR])
- {
- if(CallLocalFunction("OnPlayerArmourChange", "iff", playerid, player_armour, gPlayerCall[playerid][P_ARMOUR]))
- {
- GetPlayerArmour(playerid, gPlayerCall[playerid][P_ARMOUR]);
- }
- else
- {
- SetPlayerArmour(playerid, gPlayerCall[playerid][P_ARMOUR]);
- }
- }
- //OnPlayerVirtualWorldChange
- static player_world;
- player_world = GetPlayerVirtualWorld(playerid);
- if(player_world != gPlayerCall[playerid][P_WORLDID])
- {
- if(CallLocalFunction("OnPlayerVirtualWorldChange", "iii", playerid, player_world, gPlayerCall[playerid][P_WORLDID]))
- {
- gPlayerCall[playerid][P_WORLDID] = player_world;
- }
- else
- {
- SetPlayerVirtualWorld(playerid, gPlayerCall[playerid][P_WORLDID]);
- }
- }
- //OnPlayerSkinChange
- static player_skin;
- player_skin = GetPlayerSkin(playerid);
- if(player_skin != gPlayerCall[playerid][P_SKIN])
- {
- if(CallLocalFunction("OnPlayerSkinChange", "iii", playerid, player_skin, gPlayerCall[playerid][P_SKIN]))
- {
- gPlayerCall[playerid][P_SKIN] = player_skin;
- }
- else
- {
- SetPlayerSkin(playerid, gPlayerCall[playerid][P_SKIN]);
- }
- }
- //OnPlayerPingChange
- static player_ping;
- player_ping = GetPlayerPing(playerid);
- if(player_ping != gPlayerCall[playerid][P_PING])
- {
- CallLocalFunction("OnPlayerPingChange", "iii", playerid, player_ping, gPlayerCall[playerid][P_PING]);
- gPlayerCall[playerid][P_PING] = player_ping;
- }
- return CallLocalFunction("HOok_OnPlayerUpdate", "i", playerid);
- }
- #if defined _ALS_OnPlayerUpdate
- #undef OnPlayerUpdate
- #else
- #define _ALS_OnPlayerUpdate
- #endif
- #define OnPlayerUpdate HOok_OnPlayerUpdate
- forward HOok_OnPlayerUpdate(playerid);
- public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- //OnPlayerAmmoChange
- static player_ammo;
- player_ammo = GetPlayerAmmo(playerid);
- if(player_ammo != gPlayerCall[playerid][P_AMMO])
- {
- if(CallLocalFunction("OnPlayerAmmoChange", "iiii", playerid, weaponid, player_ammo, gPlayerCall[playerid][P_AMMO]))
- {
- gPlayerCall[playerid][P_AMMO] = player_ammo;
- }
- else
- {
- SetPlayerAmmo(playerid, weaponid, gPlayerCall[playerid][P_AMMO]);
- }
- }
- //playerstats.inc
- if(weaponid != 0)
- {
- gPlayer[playerid][P_SHOTS] += 1;
- }
- //
- return CallLocalFunction("HOok_OnPlayerWeaponShot", "iiiifff", playerid, weaponid, hittype, hitid, fX, fY, fZ);
- }
- #if defined _ALS_OnPlayerWeaponShot
- #undef OnPlayerWeaponShot
- #else
- #define _ALS_OnPlayerWeaponShot
- #endif
- #define OnPlayerWeaponShot HOok_OnPlayerWeaponShot
- forward HOok_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);
- public OnPlayerDeath(playerid, killerid, reason)
- {
- //anti fake kill and OnPlayerKillPlayer callback
- if( killerid != INVALID_PLAYER_ID &&
- playerid != INVALID_PLAYER_ID &&
- ! IsPlayerNPC(killerid) &&
- ! IsPlayerNPC(playerid))
- {
- #if defined ANTI_FAKE_KILL
- if(gettime() - gPlayerCall[playerid][P_DEATH_TICK] < 5 * 100)
- {
- gPlayerCall[playerid][P_DEATHS] ++;
- if(gPlayerCall[playerid][P_DEATHS] > 1)
- {
- CallLocalFunction("OnPlayerFakeKill", "ii", playerid, gPlayerCall[playerid][P_DEATHS]);
- return gPlayerCall[playerid][P_DEATHS] = 0;
- }
- }
- else
- {
- gPlayerCall[playerid][P_DEATHS] = 1;
- gPlayerCall[playerid][P_DEATH_TICK] = gettime();
- }
- #endif
- reason = GetPlayerWeapon(killerid);
- if(! IsValidWeapon(reason)) reason = 0;
- CallLocalFunction("OnPlayerKillPlayer", "iii", playerid, killerid, reason);
- }
- //playerstats.inc
- gPlayer[playerid][P_DEATHS] += 1;
- gPlayer[playerid][P_SPREE] = 0;
- if(killerid != INVALID_PLAYER_ID)
- {
- gPlayer[killerid][P_KILLS] += 1;
- gPlayer[killerid][P_SPREE] += 1;
- }
- //
- return CallLocalFunction("HOok_OnPlayerDeath", "iii", playerid, killerid, reason);
- }
- #if defined _ALS_OnPlayerDeath
- #undef OnPlayerDeath
- #else
- #define _ALS_OnPlayerDeath
- #endif
- #define OnPlayerDeath HOok_OnPlayerDeath
- forward HOok_OnPlayerDeath(playerid, killerid, reason);
- //internal callbacks
- forward CheckPlayerPause(playerid);
- public CheckPlayerPause(playerid)
- {
- new CurrentTime = GetTickCount();
- new PlayerState = GetPlayerState(playerid);
- if(! gPlayerCall[playerid][P_PAUSED])
- {
- if(! IsPlayerInClassSelection(playerid))
- {
- if((CurrentTime - gPlayerCall[playerid][P_LAST_UPDATE]) >= (PAUSE_CHECK_TIME * 1000))
- {
- if( (PlayerState == PLAYER_STATE_ONFOOT) ||
- (PlayerState == PLAYER_STATE_DRIVER) ||
- (PlayerState == PLAYER_STATE_PASSENGER))
- {
- if(CallLocalFunction("OnPlayerPause", "i", playerid))
- {
- gPlayerCall[playerid][P_PAUSED] = true;
- gPlayerCall[playerid][P_PAUSED_TIME] = 0;
- KillTimer(gPlayerCall[playerid][P_PAUSE_CHECK_TIMER]);
- gPlayerCall[playerid][P_PAUSE_CHECK_TIMER] = SetTimerEx("CountPlayerPausedTime", 1000, true, "i", playerid);
- }
- }
- }
- }
- }
- return 1;
- }
- forward CountPlayerPausedTime(playerid);
- public CountPlayerPausedTime(playerid)
- {
- gPlayerCall[playerid][P_PAUSED_TIME] += 1;
- return 1;
- }
- //
- forward OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz);
- forward OnPlayerFacingAngleChange(playerid, Float:newangle, Float:oldangle);
- forward OnPlayerWeaponChange(playerid, newweapon, oldweapon);
- forward OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth);
- forward OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour);
- forward OnPlayerVirtualWorldChange(playerid, newworld, oldworld);
- forward OnPlayerSkinChange(playerid, newskin, oldskin);
- forward OnPlayerPingChange(playerid, newping, oldping);
- forward OnPlayerAmmoChange(playerid, weaponid, newammo, oldammo);
- forward OnPlayerKillPlayer(playerid, killerid, weaponid);
- forward OnPlayerPause(playerid);
- forward OnPlayerUnpause(playerid, time);
- forward OnPlayerFakeKill(playerid, count);
- //-----
- //playerfuncs.inc
- //-----
- //walking styles
- #define WALKING_STYLE_DEFAULT 0
- #define WALKING_STYLE_CIVILIAN 1
- #define WALKING_STYLE_GANGSTA 2
- #define WALKING_STYLE_GANGSTA_2 3
- #define WALKING_STYLE_OLD 4
- #define WALKING_STYLE_FAT_OLD 5
- #define WALKING_STYLE_FAT 6
- #define WALKING_STYLE_LADY 7
- #define WALKING_STYLE_LADY_2 8
- #define WALKING_STYLE_WHORE 9
- #define WALKING_STYLE_WHORE_2 10
- #define WALKING_STYLE_DRUNK 11
- #define WALKING_STYLE_BLIND 12
- #define WALKING_STYLE_ARMED 13
- #if ! defined HOLDING
- #define HOLDING(%0) \
- ((newkeys & (%0)) == (%0))
- #endif
- #if ! defined RELEASED
- #define RELEASED(%0) \
- (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
- #endif
- stock GivePlayerScore(playerid, score)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return SetPlayerScore(playerid, GetPlayerScore(playerid) + score);
- }
- stock SetPlayerMoney(playerid, money)
- {
- if(! IsPlayerConnected(playerid)) return false;
- ResetPlayerMoney(playerid);
- return GivePlayerMoney(playerid, money);
- }
- stock RemovePlayerWeapoon(playerid, weaponid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new weapon, ammo;
- for(new i; i != 13; i++)
- {
- GetPlayerWeaponData(playerid, i, weapon, ammo);
- if(weapon == weaponid)
- {
- return GivePlayerWeapon(playerid, weaponid, -ammo);
- }
- }
- return false
- }
- stock SetPlayerFacingPoint(playerid, Float:x, Float:y)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new Float:pos[3];
- GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
- new Float:angle;
- if( y > pos[1] ) angle = (-acos((x - pos[0]) / floatsqroot((x - pos[0])*(x - pos[0]) + (y - pos[1])*(y - pos[1]))) - 90.0);
- else if( y < pos[1] && x < pos[0] ) angle = (acos((x - pos[0]) / floatsqroot((x - pos[0])*(x - pos[0]) + (y - pos[1])*(y - pos[1]))) - 450.0);
- else if( y < pos[1] ) angle = (acos((x - pos[0]) / floatsqroot((x - pos[0])*(x - pos[0]) + (y - pos[1])*(y - pos[1]))) - 90.0);
- if(x > pos[0]) angle = (floatabs(floatabs(angle) + 180.0));
- else angle = (floatabs(angle) - 180.0);
- return SetPlayerFacingAngle(playerid, angle);
- }
- stock static IsAngleInRangeOfAngle(Float:a1, Float:a2, Float:range = 10.0)
- {
- a1 -= a2;
- if((a1 < range) && (a1 > -range)) return true;
- return false;
- }
- stock IsPlayerFacingPoint(playerid, Float:x, Float:y, Float:range = 10.0)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new Float:pos[3];
- GetPlayerPos(pedid, pos[0], pos[1], pos[2]);
- new Float:facing;
- GetPlayerFacingAngle(playerid, facing);
- new Float:angle;
- if( pos[1] > y ) angle = (-acos((pos[0] - x) / floatsqroot((pos[0] - x)*(pos[0] - x) + (pos[1] - y)*(pos[1] - y))) - 90.0);
- else if( pos[1] < y && pos[0] < x ) angle = (acos((pos[0] - x) / floatsqroot((pos[0] - x)*(pos[0] - x) + (pos[1] - y)*(pos[1] - y))) - 450.0);
- else if( pos[1] < y ) angle = (acos((pos[0] - x) / floatsqroot((pos[0] - x)*(pos[0] - x) + (pos[1] - y)*(pos[1] - y))) - 90.0);
- return (IsAngleInRangeOfAngle(-angle, facing, range));
- }
- stock SetPlayerFacingPlayer(playerid, targetid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- if(! IsPlayerConnected(targetid)) return false;
- new Float:pos[3];
- GetPlayerPos(targetid, pos[0], pos[1], pos[2]);
- return SetPlayerFacingAngle(playerid, pos[0], pos[1]);
- }
- stock IsPlayerFacingPlayer(playerid, targetid, Float:range = 10.0)
- {
- if(! IsPlayerConnected(playerid)) return false;
- if(! IsPlayerConnected(targetid)) return false;
- new Float:pos[3];
- GetPlayerPos(targetid, pos[0], pos[1], pos[2]);
- return IsPlayerFacingPoint(playerid, pos[0], pos[1], range);
- }
- stock IsPlayerBehindPlayer(playerid, targetid, Float:range = 10.0)
- {
- if(! IsPlayerConnected(playerid)) return false;
- if(! IsPlayerConnected(targetid)) return false;
- new Float:angle[2];
- GetPlayerFacingAngle(playerid, angle[0]);
- GetPlayerFacingAngle(targetid, angle[1]);
- return (IsAngleInRangeOfAngle(angle[0], angle[1], range) && IsPlayerFacingPlayer(playerid, targetid, range));
- }
- stock GetPlayerWeaponAmmo(playerid, weaponid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new current_weapon = GetPlayerWeapon(playerid);
- SetPlayerArmedWeapon(playerid, weaponid);
- new ammo = GetPlayerAmmo(playerid);
- SetPlayerArmedWeapon(playerid, current_weapon);
- return ammo;
- }
- stock SetPlayerWeaponAmmo(playerid, weaponid, ammo)
- {
- if(! IsPlayerConnected(playerid)) return false;
- RemovePlayerWeapon(playeird, weaponid);
- return GivePlayerWeapon(playerid, weaponid, ammo);
- }
- stock SetPlayerWalkingStyle(playerid, style)
- {
- if(! IsPlayerConnected(playerid)) return false;
- gWalkingStyle[playerid] = style;
- return true;
- }
- stock GetPlayerWalkingStyle(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gWalkingStyle[playerid];
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new keys, updown, leftright;
- GetPlayerKeys(playerid, keys, updown, leftright);
- if( HOLDING(KEY_WALK) &&
- ( (updown & KEY_UP ||
- updown & KEY_DOWN)
- ||
- (leftright & KEY_LEFT ||
- leftright & KEY_RIGHT))
- )
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
- {
- if(gWalkingStyle[playerid] != WALKING_STYLE_DEFAULT)
- {
- new stylestr[28];
- switch(gWalkingStyle[playerid])
- {
- case WALKING_STYLE_CIVILIAN: stylestr = "WALK_civi";
- case WALKING_STYLE_GANGSTA: stylestr = "WALK_gang1";
- case WALKING_STYLE_GANGSTA_2: stylestr = "WALK_gang2";
- case WALKING_STYLE_OLD: stylestr = "WALK_old";
- case WALKING_STYLE_FAT_OLD: stylestr = "WALK_fatold";
- case WALKING_STYLE_FAT: stylestr = "WALK_fat";
- case WALKING_STYLE_LADY: stylestr = "WOMAN_walknorm";
- case WALKING_STYLE_LADY_2: stylestr = "WOMAN_walkbusy";
- case WALKING_STYLE_WHORE: stylestr = "WOMAN_walkpro";
- case WALKING_STYLE_WHORE_2: stylestr = "WOMAN_walksexy";
- case WALKING_STYLE_DRUNK: stylestr = "WALK_drunk";
- case WALKING_STYLE_BLIND: stylestr = "Walk_Wuzi";
- case WALKING_STYLE_ARMED: stylestr = "WALK_armed";
- }
- if(CallLocalFunction("OnPlayerWalk", "ii", playerid, gWalkingStyle[playerid]))
- {
- return ApplyAnimation(playerid, "PED", stylestr, 4.1, 1, 1, 1, 1, 1);
- }
- }
- }
- }
- }
- if(RELEASED(KEY_WALK))
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
- {
- if(gWalkingStyle[playerid] != WALKING_STYLE_DEFAULT)
- {
- new stylestr[28];
- switch(gWalkingStyle[playerid])
- {
- case WALKING_STYLE_CIVILIAN: stylestr = "WALK_civi";
- case WALKING_STYLE_GANGSTA: stylestr = "WALK_gang1";
- case WALKING_STYLE_GANGSTA_2: stylestr = "WALK_gang2";
- case WALKING_STYLE_OLD: stylestr = "WALK_old";
- case WALKING_STYLE_FAT_OLD: stylestr = "WALK_fatold";
- case WALKING_STYLE_FAT: stylestr = "WALK_fat";
- case WALKING_STYLE_LADY: stylestr = "WOMAN_walknorm";
- case WALKING_STYLE_LADY_2: stylestr = "WOMAN_walkbusy";
- case WALKING_STYLE_WHORE: stylestr = "WOMAN_walkpro";
- case WALKING_STYLE_WHORE_2: stylestr = "WOMAN_walksexy";
- case WALKING_STYLE_DRUNK: stylestr = "WALK_drunk";
- case WALKING_STYLE_BLIND: stylestr = "Walk_Wuzi";
- case WALKING_STYLE_ARMED: stylestr = "WALK_armed";
- }
- if(CallLocalFunction("OnPlayerWalk", "ii", playerid, gWalkingStyle[playerid]))
- {
- return ApplyAnimation(playerid, "PED", stylestr, 4.1, 0, 0, 0, 0, 1);
- }
- }
- }
- }
- }
- return CallLocalFunction("HOoK_OnPlayerKeyStateChange", "iii", playerid, newkeys, oldkeys);
- }
- #if defined _ALS_OnPlayerKeyStateChange
- #undef OnPlayerKeyStateChange
- #else
- #define _ALS_OnPlayerKeyStateChange
- #endif
- #define OnPlayerKeyStateChange HOoK_OnPlayerKeyStateChange
- forward HOoK_OnPlayerKeyStateChange(playerid, newkeys, oldkeys);
- //script(not internal) callback
- forward OnPlayerWalk(playerid, style);
- //-----
- //playerstates.inc
- //-----
- stock IsPlayerSpawned(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- switch(GetPlayerState(playerid))
- {
- case PLAYER_STATE_ONFOOT, PLAYER_STATE_DRIVER, PLAYER_STATE_PASSENGER, PLAYER_STATE_SPAWNED: return true;
- default: return false;
- }
- return false;
- }
- stock IsPlayerSpectating(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) return true;
- return false;
- }
- stock IsPlayerDriver(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) return true;
- return false;
- }
- stock IsPlayerInClassSelection(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new Float: health = 0.0;
- GetPlayerHealth(playerid, health);
- if(GetPlayerState(playerid) == PLAYER_STATE_WASTED && health > 0.0) return true;
- return false;
- }
- stock IsPlayerDead(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- new Float: health = 0.0;
- GetPlayerHealth(playerid, health);
- if(GetPlayerState(playerid) == PLAYER_STATE_WASTED && health <= 0.0) return true;
- return false;
- }
- //-----
- //playerstats.inc
- //-----
- forward OnPlayerUpdateSecond(playerid);
- public OnPlayerUpdateSecond(playerid)
- {
- new seconds = gPlayer[playerid][P_TIME][0];
- new minutes = gPlayer[playerid][P_TIME][1];
- new hours = gPlayer[playerid][P_TIME][2];
- seconds += 1;
- if(seconds >= 60)
- {
- seconds = 0;
- minutes += 1;
- if(minutes >= 60)
- {
- minutes = 0;
- hours += 1;
- }
- }
- return 1;
- }
- public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
- {
- //headshot system
- if(GetPlayerTeam(issuerid) != GetPlayerTeam(playerid))
- {
- if(bodypart == 9)
- {
- if(CallLocalFunction("OnPlayerHeadshot", "iii", playerid, issuerid, weaponid))
- {
- gPlayer[issuerid][P_HEADSHOTS] += 1;
- }
- }
- gPlayer[issuerid][P_HITS] += 1;
- }
- return CallLocalFunction("HOoK_OnPlayerTakeDamage", "iifii", playerid, issuerid, Float: amount, weaponid, bodypart);
- }
- #if defined _ALS_OnPlayerTakeDamage
- #undef OnPlayerTakeDamage
- #else
- #define _ALS_OnPlayerTakeDamage
- #endif
- #define OnPlayerTakeDamage HOoK_OnPlayerTakeDamage
- forward HOoK_OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart);
- stock GetPlayerKills(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gPlayer[playerid][P_KILLS];
- }
- stock GetPlayerDeaths(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gPlayer[playerid][P_DEATHS];
- }
- stock GetPlayerSpree(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gPlayer[playerid][P_SPREE];
- }
- stock GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
- {
- if(! IsPlayerConnected(playerid)) return false;
- seconds = gPlayer[playerid][P_TIME][0];
- minutes = gPlayer[playerid][P_TIME][1];
- hours = gPlayer[playerid][P_TIME][2];
- return true;
- }
- stock GetPlayerHeadshots(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gPlayer[playerid][P_HEADSHOTS];
- }
- stock GetPlayerWeaponShots(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gPlayer[playerid][P_SHOTS];
- }
- stock GetPlayerWeaponHits(playerid)
- {
- if(! IsPlayerConnected(playerid)) return false;
- return gPlayer[playerid][P_HITS];
- }
- forward OnPlayerHeadshot(playerid, issuerid, weaponid);
Advertisement
Add Comment
Please, Sign In to add comment