FlacoBey

Untitled

Jan 9th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdkhooks>
  3. #include <sdktools>
  4.  
  5. char sDataFilePath[PLATFORM_MAX_PATH];
  6.  
  7. public OnPluginStart()
  8. {
  9.     BuildPath(Path_SM, sDataFilePath, sizeof(sDataFilePath), "data/prefix.ini");
  10.     if (!FileExists(sDataFilePath))
  11.     {
  12.         new Handle:open_path = OpenFile(sDataFilePath, "w");
  13.         WriteFileLine(open_path, "");
  14.         CloseHandle(open_path);
  15.         PrintToServer("Error Code: WSP-EC-01A");
  16.     }
  17. }
  18.  
  19. public OnClientPutInServer(i)
  20. {
  21.     if(IsValidClient(i))
  22.     {
  23.         KeyValues kv = new KeyValues("prefix");
  24.         if (kv.ImportFromFile(sDataFilePath))
  25.         {
  26.             decl String:name[32];
  27.             GetClientName(i, name, sizeof(name))
  28.             if (KvJumpToKey(kv, name, false))
  29.             {
  30.                 char szBuffer[32];
  31.                 KvGetString(kv, "prefix", szBuffer, sizeof(szBuffer));
  32.                 Format(name, sizeof(name), "[%s]%N", szBuffer, name)
  33.                 SetClientInfo(i, "name", name);
  34.                 kv.ExportToFile(sDataFilePath);
  35.             }
  36.             else
  37.             {
  38.                 KvJumpToKey(kv, name, true);
  39.                 {
  40.                     kv.SetString("prefix", "[Noob]");
  41.                     SetClientInfo(i, "name", name);
  42.                     kv.ExportToFile(sDataFilePath);
  43.                 }
  44.             }
  45.         }
  46.     }
  47. }
  48.  
  49. stock bool:IsValidClient( client )
  50. {
  51.     if ( client < 1 || client > MaxClients ) return false;
  52.     if ( !IsClientConnected( client )) return false;
  53.     if ( !IsClientInGame( client )) return false;
  54.     if ( GetClientTeam( client ) != 2 ) return false;
  55.     if ( !IsPlayerAlive( client )) return false;
  56.     return true;
  57. }
  58.  
  59. stock bool bIsSurvivor(int client)
  60. {
  61.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment