Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- [Include] e_static | Check player state easily | v1
- By Excel
- Copyright (c) 2013
- */
- #include <a_samp>
- #include <YSI\y_hooks>
- #if defined _e_static_included
- #endinput
- #endif
- #define _e_static_included
- /*
- native IsPlayerSpawned(playerid);
- native IsPlayerDead(playerid);
- native IsPlayerInClassSelection(playerid);
- native IsPlayerOnBike(playerid);
- native IsPlayerInCar(playerid);
- native IsPlayerInBoat(playerid);
- native IsPlayerInHelicopter(playerid);
- native IsPlayerInAircraft(playerid);
- native IsPlayerAfk(playerid);
- native IsPlayerInjured(playerid);
- native IsPlayerGod(playerid);
- native IsPlayerMale(playerid);
- native IsPlayerFemale(playerid);
- native IsPlayerInWater(playerid);
- native IsPlayerOnLand(playerid);
- */
- #define \
- ENABLE \
- 1
- #define \
- DISABLE \
- 0
- #define \
- AFK_TIMER \
- 30000
- enum
- p_data_vars
- {
- spawned,
- dead,
- class,
- afk,
- afktimer
- }
- new
- player_info[ MAX_PLAYERS ][ p_data_vars ];
- forward OnPlayerUpdateEx(playerid);
- /*
- Function: IsPlayerSpawned(playerid);
- Usage: Checks wheater the player is spawned or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerSpawned(playerid)
- {
- if(player_info[ playerid ][ spawned ]==ENABLE) return true;
- else return false;
- }
- /*
- Function: IsPlayerDead(playerid);
- Usage: Checks wheater the player is dead or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerDead(playerid)
- {
- if(player_info[ playerid ][ dead ]==ENABLE) return true;
- else return false;
- }
- /*
- Function: IsPlayerInClassSelection(playerid);
- Usage: Checks wheater the player is selecting class or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInClassSelection(playerid)
- {
- if(player_info[ playerid ][ class ]==ENABLE) return true;
- else return false;
- }
- /*
- Function: IsPlayerOnBike(playerid);
- Usage: Checks wheater the player is on a bike or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerOnBike(playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return false;
- new
- Bikes[12]=
- { 581,509,481,421,462,510,463,522,461,448,586,468 },
- vehicleid=GetPlayerVehicleID(playerid);
- for(new i = 0; i < 12; i++)
- {
- if(GetVehicleModel(vehicleid) == Bikes[i])
- { return true; } else return false;
- }
- }
- /*
- Function: IsPlayerInCar(playerid);
- Usage: Checks wheater the player is in a car or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInCar(playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return false;
- new
- AllCars[93] = {
- 400,401,402,404,405,410,411,412,415,418,419,420,421,422,424,426,429,434,436,
- 438,439,442,445,451,458,466,467,470,474,475,477,478,480,480,480,480,489,490,
- 491,492,494,496,500,501,502,503,504,505,506,507,516,517,518,526,527,529,533,
- 534,535,536,540,541,542,543,545,546,547,549,550,551,555,558,559,560,561,562,
- 565,566,567,575,576,580,585,587,589,596,597,598,600,602,603,604,605 },
- vehicleid=GetPlayerVehicleID(playerid);
- for(new i = 0; i < 93; i++)
- {
- if(GetVehicleModel(vehicleid) == AllCars[i])
- { return true; } else return false;
- }
- }
- /*
- Function: IsPlayerInBoat(playerid);
- Usage: Checks wheater the player is in a boat or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInBoat(playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return false;
- new
- Boats[10] = {
- 472,473,595,493,430,453,484,446,452,454 },
- vehicleid=GetPlayerVehicleID(playerid);
- for(new i = 0; i < 10; i++)
- {
- if(GetVehicleModel(vehicleid) == Boats[i])
- { return true; } else return false;
- }
- }
- /*
- Function: IsPlayerInHelicopter(playerid);
- Usage: Checks wheater the player is in a helicopter or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInHelicopter(playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return false;
- new
- Helis[9] = {
- 548,425,488,487,417,563,497,447,469 },
- vehicleid=GetPlayerVehicleID(playerid);
- for(new i = 0; i < 9; i++)
- {
- if(GetVehicleModel(vehicleid) == Helis[i])
- { return true; } else return false;
- }
- }
- /*
- Function: IsPlayerInAircraft(playerid);
- Usage: Checks wheater the player is in a helicopter or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInAircraft(playerid)
- {
- if(!IsPlayerInAnyVehicle(playerid)) return false;
- new
- Aircrafts[20] = {
- 577,511,592,520,593,512,476,553,460,413,519,548,425,488,487,417,563,497,447,469 },
- vehicleid=GetPlayerVehicleID(playerid);
- for(new i = 0; i < 20; i++)
- {
- if(GetVehicleModel(vehicleid) == Aircrafts[i])
- { return true; } else return false;
- }
- }
- /*
- Function: IsPlayerAfk(playerid);
- Usage: Checks wheater the player is afk mode or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerAfk(playerid)
- {
- if(player_info[ playerid ][ afk ]==ENABLE) return true;
- else return false;
- }
- /*
- Function: IsPlayerInjured(playerid);
- Usage: Checks wheater the player is afk mode or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInjured(playerid)
- {
- new
- Float:hp;
- if(hp<11)
- { return true; } else return false;
- }
- /*
- Function: IsPlayerGod(playerid);
- Usage: Checks wheater the player is god mode or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerGod(playerid)
- {
- new
- Float:hp;
- if(hp>100)
- { return true; } else return false;
- }
- /*
- Function: IsPlayerMale(playerid);
- Usage: Checks wheater the player is male or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerMale(playerid)
- {
- new
- Males[204] = {
- 0,1,2,7,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32,33,34,35,36,37,43,44,45,46,47,48,
- 49,50,51,52,56,58,59,60,61,62,66,67,68,70,71,72,73,78,79,80,81,82,83,84,94,95,96,97,98,99,100,
- 101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,120,121,123,124,125,126,
- 127,128,132,133,134,135,136,137,142,143,144,146,147,153,154,155,156,158,159,160,161,162,163,164,
- 165,166,167,168,170,171,173,174,175,176,177,179,180,181,182,183,184,185,186,187,188,189,200,202,
- 203,204,206,209,210,217,220,222,221,223,227,228,229,230,234,235,256,239,240,241,242,247,248,249,
- 250,252,253,254,255,258,259,260,261,262,264,265,267,268,269,270,271,272,273,274,275,276,277,
- 278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,299 };
- for(new i = 0; i < 204; i++)
- {
- if(GetPlayerSkin(vehicleid) == Males[i])
- { return true; } else return false;
- }
- }
- /*
- Function: IsPlayerFemale(playerid);
- Usage: Checks wheater the player is female or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerFemale(playerid)
- {
- if(IsPlayerMale(playerid))
- { return false; } else return true;
- }
- /*
- Function: IsPlayerInWater(playerid);
- Usage: Checks wheater the player is in water or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerInWater(playerid)
- {
- new
- animlib[10],
- animname[10];
- GetAnimationName(GetPlayerAnimationIndex(playerid),
- animlib,
- sizeof(animlib),
- animname,
- sizeof(animname));
- return (!strcmp(animlib, "SWIM")) ? 1 : 0;
- }
- /*
- Function: IsPlayerOnLand(playerid);
- Usage: Checks wheater the player is in land or not,
- If he is then it return a value 1 (Yes) or 0 (No)
- */
- stock IsPlayerOnLand(playerid)
- {
- if(IsPlayerInWater(playerid))
- { return false; } else return true;
- }
- Hook:P_OnPlayerConnect(playerid)
- {
- SetTimerEx("OnPlayerUpdateEx",
- 1000,
- true,
- "i",
- playerid);
- return 1;
- }
- Hook:P_OnPlayerRequestClass(playerid, classid)
- {
- player_info[ playerid ][ spawned ]=DISABLE;
- player_info[ playerid ][ dead ]=DISABLE;
- player_info[ playerid ][ class ]=ENABLE;
- return 1;
- }
- Hook:P_OnPlayerSpawn(playerid)
- {
- player_info[ playerid ][ afktimer ]=0;
- player_info[ playerid ][ spawned ]=ENABLE;
- player_info[ playerid ][ dead ]=DISABLE;
- player_info[ playerid ][ class ]=DISABLE;
- return 1;
- }
- Hook:P_OnPlayerDeath(playerid, killerid, reason)
- {
- player_info[ playerid ][ spawned ]=DISABLE;
- player_info[ playerid ][ dead ]=ENABLE;
- player_info[ playerid ][ class ]=DISABLE;
- return 1;
- }
- Hook:P_OnPlayerUpdateEx(playerid)
- {
- if(player_info[ playerid ][ afktimer ]<0) return false;
- player_info[ playerid ][ afktimer ]++;
- if(player_info[ playerid ][ afktimer ]>AFK_TIMER)
- { player_info[ playerid ][ afk ]=ENABLE,
- player_info[ playerid ][ afktimer ]=-1; }
- return 1;
- }
- Hook:P_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- player_info[ playerid ][ afk ]=DISABLE,
- player_info[ playerid ][ afktimer ]=0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement