Advertisement
Guest User

MEOWABO

a guest
May 25th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.04 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. public Plugin:myinfo =
  5. {
  6.     name = "Engineer ThirdView",
  7.     author = "Ice :D",
  8.     description = "Ce plugin permet changer son mode de vue",
  9.     version = "1.0",
  10.     url = "http://engineer.redby.fr"
  11. }
  12.  
  13. public OnPluginStart()
  14. {
  15.     RegConsoleCmd("say", Command_Say) // It's override the say command ;P
  16. }
  17.  
  18. // THe console command
  19. public Action:Command_Say(client, args)
  20. {
  21.     new String:text[192]
  22.     GetCmdArgString(text, sizeof(text))
  23.    
  24.     new startidx = 0
  25.     if (text[0] == '"')
  26.     {
  27.         startidx = 1
  28.         /* Strip the ending quote, if there is one */
  29.         new len = strlen(text);
  30.         if (text[len-1] == '"')
  31.         {
  32.             text[len-1] = '\0'
  33.         }
  34.     }
  35.     if (StrEqual(text[startidx], "!thirdperson"))  
  36.     {
  37.         ActiveThirdPerson(client);
  38.     }
  39.     if (StrEqual(text[startidx], "!firstperson"))
  40.     {
  41.         ActiveFirstPerson(client);
  42.     }
  43.    
  44.  
  45.     /* Let say continue normally */
  46.     return Plugin_Continue
  47. }
  48.  
  49. public IsClientConnectedIngameAlive(client) // If player is alive and ingame but now u can make better with SM function
  50. {
  51.     if(IsClientConnectedIngame(client))
  52.     {
  53.    
  54.         if(IsPlayerAlive(client) == true && IsClientObserver(client) == false)
  55.         {          
  56.             return true;
  57.         }
  58.         else
  59.         {
  60.             return false;
  61.         }
  62.     }
  63.     else
  64.     {  
  65.         return false;
  66.     }
  67. }
  68.  
  69. public IsClientConnectedIngame(client)
  70. {
  71.    
  72.     if(client > 0 && client <= MaxClients){
  73.    
  74.         if(IsClientInGame(client) == true){
  75.            
  76.             return true;
  77.                
  78.         }else{
  79.                
  80.             return false;
  81.                
  82.         }
  83.        
  84.     }else{
  85.        
  86.         return false;
  87.        
  88.     }
  89.    
  90. }
  91.  
  92. public ActiveThirdPerson(client){ //Simple function
  93.    
  94.     if(IsClientConnectedIngameAlive(client)){
  95.        
  96.         SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", 0);
  97.         SetEntProp(client, Prop_Send, "m_iObserverMode", 1);
  98.         SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 0);  
  99.     }
  100.    
  101. }
  102.  
  103. public ActiveFirstPerson(client){
  104.    
  105.     if(IsClientConnectedIngameAlive(client)){
  106.        
  107.         SetEntPropEnt(client, Prop_Send, "m_hObserverTarget", -1);
  108.         SetEntProp(client, Prop_Send, "m_iObserverMode", 0);
  109.         SetEntProp(client, Prop_Send, "m_bDrawViewmodel", 1);
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement