thetwistedpanda

Untitled

Aug 30th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.99 KB | None | 0 0
  1. #define cDebugMode 1
  2.  
  3. enum HudStuff
  4. {
  5.     Handle:SpeedOne,
  6.     Handle:SpeedTwo,
  7.     Handle:MinusOne,
  8.     Handle:PressedOne,
  9.     Handle:PressedTwo,
  10.     Handle:PressedThree
  11. }
  12. new g_HudSyncs[HudStuff];
  13.  
  14. new g_iButtons[MAXPLAYERS + 1];
  15.  
  16. public Plugin:myinfo =
  17. {
  18.     name = "OWNSShowMyKeys",
  19.     description = "A speed and key HUD using HudText",
  20.     author = "OWNSyouAll",
  21.     version = "0.0.5",
  22.     url = ""
  23. };
  24.  
  25. public OnPluginStart()
  26. {
  27.     // This is supposed to print to server but doesn't
  28.     PrintToServer("Starting OWNSShowMyKeys by OWNSyouAll version 0.0.5");
  29.     #if defined cDebugMode
  30.     LogError("Starting OWNSShowMyKeys by OWNSyouAll version 0.0.5");
  31.     #endif
  32.  
  33.     //Huds can be created one and re-used.
  34.     g_HudSyncs[SpeedOne] = CreateHudSynchronizer();
  35.     g_HudSyncs[SpeedTwo] = CreateHudSynchronizer();
  36.     g_HudSyncs[MinusOne] = CreateHudSynchronizer();
  37.     g_HudSyncs[PressedOne] = CreateHudSynchronizer();
  38.     g_HudSyncs[PressedTwo] = CreateHudSynchronizer();
  39.     g_HudSyncs[PressedThree] = CreateHudSynchronizer();
  40. }
  41.  
  42. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  43. {
  44.     g_iButtons[client] = buttons;
  45. }
  46.  
  47. public OnGameFrame()
  48. {
  49.     decl String:sMinusBuffer[16];
  50.     decl String:sOneBuffer[16];
  51.     decl String:sTwoBuffer[16];
  52.     decl String:sThreeBuffer[16];
  53.  
  54.     for(new client = 1; client <= MaxClients; client++)
  55.     {
  56.         //IsFakeClient should include sourcetv/replay, see no reason why it wouldn't... But never tried
  57.         if(!IsClientInGame(client) || IsFakeClient(client))
  58.             continue;
  59.            
  60.         //You can't use buttons == something because it won't consider multiple button presses.
  61.         //if IN_ATTACK and IN_USE, the values are combined, thus == fails
  62.         //they're bit flags, so you can use bitwise operations on them
  63.         if(g_iButtons[client] & IN_ATTACK)
  64.             Format(sMinusBuffer, sizeof(sMinusBuffer), "+attack");
  65.         else
  66.             Format(sMinusBuffer, sizeof(sMinusBuffer), "______");
  67.  
  68.         if(g_iButtons[client] & IN_USE)
  69.             Format(sOneBuffer, sizeof(sOneBuffer), "+use");
  70.         else
  71.             Format(sOneBuffer, sizeof(sOneBuffer), "____");
  72.  
  73.         if(g_iButtons[client] & IN_FORWARD)
  74.             Format(sTwoBuffer, sizeof(sTwoBuffer), "   W  ");
  75.         else
  76.             Format(sTwoBuffer, sizeof(sTwoBuffer), "   _  ");
  77.  
  78.         if (g_iButtons[client] & IN_MOVELEFT)
  79.             Format(sThreeBuffer, sizeof(sThreeBuffer), "A");
  80.         else
  81.             Format(sThreeBuffer, sizeof(sThreeBuffer), "_");
  82.  
  83.         if (g_iButtons[client] & IN_BACK)
  84.             Format(sThreeBuffer, sizeof(sThreeBuffer), "%s S", sThreeBuffer);
  85.         else
  86.             Format(sThreeBuffer, sizeof(sThreeBuffer), "%s _", sThreeBuffer);
  87.  
  88.         if (g_iButtons[client] & IN_MOVERIGHT)
  89.             Format(sThreeBuffer, sizeof(sThreeBuffer), "%s D", sThreeBuffer);
  90.         else
  91.             Format(sThreeBuffer, sizeof(sThreeBuffer), "%s _", sThreeBuffer);
  92.  
  93.         //SetHudTextParams(Float:x, Float:y, Float:holdTime, r, g, b, a, effect = 0, Float:fxTime=6.0, Float:fadeIn=0.1, Float:fadeOut=0.2);
  94.         //This prototype requires Floats (0.0 vs 0) to be passed for several parameters, you were passing integers.
  95.  
  96.         #if defined cDebugMode
  97.         if(!GetRandomInt(0, 33)) //Fires every frame, i'm lazy.
  98.             LogError("%s %s %s %s", sMinusBuffer, sOneBuffer, sTwoBuffer, sThreeBuffer);
  99.         #endif
  100.         new Float:fDistance;
  101.         SetHudTextParams(0.5, 0.65, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
  102.         ShowSyncHudText(client, g_HudSyncs[SpeedOne], "%i", fDistance);
  103.  
  104.         SetHudTextParams(0.95, 0.65, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
  105.         ShowSyncHudText(client, g_HudSyncs[SpeedTwo], "HU/s");
  106.  
  107.         SetHudTextParams(0.5, 0.7, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
  108.         ShowSyncHudText(client, g_HudSyncs[MinusOne], "%s", sMinusBuffer);
  109.  
  110.         SetHudTextParams(0.5, 0.75, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
  111.         ShowSyncHudText(client, g_HudSyncs[PressedOne], "%s", sOneBuffer);
  112.  
  113.         SetHudTextParams(0.5, 0.5, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
  114.         ShowSyncHudText(client, g_HudSyncs[PressedTwo], "%s", sTwoBuffer);
  115.  
  116.         SetHudTextParams(0.5, 0.85, 1.0, 255, 255, 255, 255, 0, 0.0, 0.0, 0.0);
  117.         ShowSyncHudText(client, g_HudSyncs[PressedThree], "%s", sThreeBuffer);
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment