Advertisement
Guest User

AdminSight

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