Guest User

AdminSight v1.0

a guest
Nov 24th, 2010
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.10 KB | None | 0 0
  1.                     /***************************************\
  2.                     **                                    **
  3.                     **            AdminSight v1.0         **
  4.                     **            by Gigi-The-Beast       **
  5.                     **                                    **
  6.                     \***************************************/
  7.  
  8. /*
  9. Credits:
  10. - JernejL = DistanceCameraTargetToLocation
  11. - CracK = IsPlayerAimingAt
  12. */
  13. //=============================[1][ INCLUDES ]==================================
  14. //==============================================================================
  15. #include <a_samp>
  16. //=============================[2][ DEFINITIONS ]===============================
  17. //==============================================================================
  18. #define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  19. //=============================[3][ FORWARDS ]==================================
  20. //==============================================================================
  21. forward AdminTimer(playerid);
  22. //=============================[4][ NEWS ]======================================
  23. //==============================================================================
  24. new pAdminDuty[MAX_PLAYERS];
  25. new pAdminTimerOn[MAX_PLAYERS];
  26. new pAdminTimer[MAX_PLAYERS];
  27. new Text:pAdminText[MAX_PLAYERS];
  28. //=============================[5][ DEFAULT PUBLICS ]===========================
  29. //==============================================================================
  30. public OnFilterScriptInit()
  31. {
  32.     print("\n--------------------------------------");
  33.     print(" AdminSight v1.0 Loaded Sucessfully!    ");
  34.     print("--------------------------------------\n");
  35.     ConnectNPC("testa","onfoot_test");
  36.     ConnectNPC("testb","onfoot_test");
  37.     ConnectNPC("testc","onfoot_test");
  38.     ConnectNPC("testd","onfoot_test");
  39.     for(new i = 0; i < MAX_PLAYERS; i++)
  40.     {
  41.         pAdminText[i] = TextDrawCreate(497.000000, 99.000000, "~b~Ime Igraca~n~~r~Health:~w~~n~~r~Armour:~w~~n~~r~Weapon:~w~~n~~r~Ammo:");
  42.         TextDrawBackgroundColor(pAdminText[i], 255);
  43.         TextDrawFont(pAdminText[i], 2);
  44.         TextDrawLetterSize(pAdminText[i], 0.310000, 1.100000);
  45.         TextDrawSetShadow(pAdminText[i], 1);
  46.     }
  47.     return 1;
  48. }
  49. public OnFilterScriptExit()
  50. {
  51.     print("\n--------------------------------------");
  52.     print(" AdminSight v1.0 UnLoaded Sucessfully!   ");
  53.     print("--------------------------------------\n");
  54.     return 1;
  55. }
  56. public OnPlayerConnect(playerid)
  57. {
  58.     pAdminDuty[playerid] = 0;
  59.     pAdminTimerOn[playerid] = 0;
  60.     return 1;
  61. }
  62. public OnPlayerDisconnect(playerid, reason)
  63. {
  64.     if(pAdminDuty[playerid] == 1)
  65.     {
  66.         if(pAdminTimerOn[playerid] == 1)
  67.         {
  68.             TextDrawHideForPlayer(playerid,pAdminText[playerid]);
  69.             KillTimer(pAdminTimer[playerid]);
  70.         }
  71.     }
  72.     return 1;
  73. }
  74. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  75. {
  76.     if((newkeys & KEY_HANDBRAKE) && !(oldkeys & KEY_HANDBRAKE))
  77.     {
  78.         if(pAdminDuty[playerid] == 1)
  79.         {
  80.             if(pAdminTimerOn[playerid] == 0)
  81.             {
  82.                 pAdminTimerOn[playerid] = 1;
  83.                 pAdminTimer[playerid] = SetTimerEx("AdminTimer",200,1,"i",playerid);
  84.             }
  85.         }
  86.     }
  87.     if((oldkeys & KEY_HANDBRAKE) && !(newkeys & KEY_HANDBRAKE))
  88.     {
  89.         if(pAdminDuty[playerid] == 1)
  90.         {
  91.             if(pAdminTimerOn[playerid] == 1)
  92.             {
  93.                 pAdminTimerOn[playerid] = 0;
  94.                 KillTimer(pAdminTimer[playerid]);
  95.             }
  96.         }
  97.     }
  98.     if(PRESSED(KEY_LOOK_BEHIND))
  99.     {
  100.         if(pAdminDuty[playerid] == 1)
  101.         {
  102.             TextDrawSetString(pAdminText[playerid],"~b~Ime Igraca~w~~n~~r~Health:~w~~n~~r~Armour:~w~~n~~r~Weapon:~w~~n~~r~Ammo:");
  103.             TextDrawShowForPlayer(playerid,pAdminText[playerid]);
  104.         }
  105.     }
  106.     return 1;
  107. }
  108. public OnRconLoginAttempt(ip[], password[], success)//beter to use it with your's gm admin system with cmd Adminduty(if you have one)
  109. {
  110.     if(success)
  111.     {
  112.         new pIP[16];
  113.         for(new i=0; i<MAX_PLAYERS; i++)
  114.         {
  115.             GetPlayerIp(i, pIP, sizeof(pIP));
  116.             if(!strcmp(ip, pIP, true))
  117.             {
  118.                 pAdminDuty[i] = 1;
  119.                 GivePlayerWeapon(i,34,10);
  120.             }
  121.         }
  122.     }
  123.     return 1;
  124. }
  125. //=============================[6][ CUSTOM PUBLICS ]============================
  126. //==============================================================================
  127. public AdminTimer(playerid)
  128. {
  129.     new
  130.         Float:pX,
  131.         Float:pY,
  132.         Float:pZ,
  133.         Float:Hp,
  134.         Float:Armour,
  135.         iGun,
  136.         iAmmo,
  137.         iname[MAX_PLAYER_NAME],
  138.         string[128];
  139.        
  140.     for(new i = 0; i<MAX_PLAYERS; i++)
  141.     {
  142.         if(IsPlayerConnected(i) && i != playerid)
  143.         {
  144.             GetPlayerPos(i,pX,pY,pZ);
  145.             if(IsPlayerAimingAt(playerid,pX,pY,pZ,0.8) == 1)
  146.             {
  147.                 GetPlayerName(i,iname,sizeof(iname));
  148.                 GetPlayerHealth(i,Hp);
  149.                 GetPlayerArmour(i,Armour);
  150.                 new iHp = floatround(Hp);
  151.                 new iArmour = floatround(Armour);
  152.                 /* This way you can use this code to implement it in your gamemode,
  153.                 so you can check for player's organization and other stuff ;)
  154.                 if(gTeam[i] == 3 || gTeam[i] == 4) orgname = "Civil";
  155.                 else if(PlayerInfo[i][pMember] == 1 || PlayerInfo[i][pLeader] == 1) orgname = "Policija";
  156.                 else if(PlayerInfo[i][pMember] == 2 || PlayerInfo[i][pLeader] == 2) orgname = "FBI";
  157.                 else if(PlayerInfo[i][pMember] == 3 || PlayerInfo[i][pLeader] == 3) orgname = "Hitna Pomoc";
  158.                 format(string,sizeof(string),"~b~%s~n~~r~Org:~w~ %s~n~~r~Health:~w~ %d~n~~r~Armour:~w~ %d~n~~r~Weapon:~w~ %d~n~~r~Ammo:~w~ %d",iname,orgname,iHp,iArmour,iGun,iAmmo);
  159.                 */
  160.                 format(string,sizeof(string),"~b~%s~n~~r~Health:~w~ %d~n~~r~Armour:~w~ %d~n~~r~Weapon:~w~ %d~n~~r~Ammo:~w~ %d",iname,iHp,iArmour,iGun,iAmmo);
  161.                 TextDrawSetString(pAdminText[playerid],string);
  162.                 TextDrawShowForPlayer(playerid,pAdminText[playerid]);
  163.             }
  164.         }
  165.     }
  166. }
  167. //=============================[7][ COMMANDS ]==================================
  168. //==============================================================================
  169. //none, but i suggest to implement this code in your gm with your admin system
  170. //=============================[8][ STOCKS & OTHER ]============================
  171. //==============================================================================
  172. Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ,  Float:ObjX, Float:ObjY, Float:ObjZ,  Float:FrX, Float:FrY, Float:FrZ)
  173. {
  174.     new Float:TGTDistance;
  175.     TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));
  176.     new Float:tmpX, Float:tmpY, Float:tmpZ;
  177.     tmpX = FrX * TGTDistance + CamX;
  178.     tmpY = FrY * TGTDistance + CamY;
  179.     tmpZ = FrZ * TGTDistance + CamZ;
  180.     return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
  181. }
  182. stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
  183. {
  184.     new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
  185.     GetPlayerCameraPos(playerid, cx, cy, cz);
  186.     GetPlayerCameraFrontVector(playerid, fx, fy, fz);
  187.     return (radius >= DistanceCameraTargetToLocation(cx, cy, cz, x, y, z, fx, fy, fz));
  188. }
  189. //=============================[ END OF FILE ]==================================
  190. //==============================================================================
  191. //If you find any bugs, or you have some suggestions, please contact me on Samp Forum, thank you ;)
Advertisement
Add Comment
Please, Sign In to add comment