Guest User

LSF

a guest
May 2nd, 2010
363
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  *  Simple functions by Lorenc
  3.  *  Created while practising loops
  4.  *  edited by Freddo [BINMAN] on v1
  5. */
  6.  
  7. #include <a_samp>
  8. #include <foreach>
  9.  
  10. /*
  11.     native GiveAllPlayersWeapon(Weaponid,Ammo);
  12.     native ResetAllPlayersCash();
  13.     native KickAllPlayers();
  14.     native BanAllPlayers();
  15.     native SetAllPlayersVirtualWorld(World);
  16.     native SetAllPlayersSkin(Skinid);
  17.     native SetAllPlayersInterior(Interior);
  18.     SetAllPlayersScore(Score);
  19.  
  20.     Version 2:
  21.     native ReturnNameGang(name[]);
  22.     native ReturnPlayerGang(playerid);
  23.     native NameContainsGang(playerid, clan[]);
  24.     native SetMapNameModeText(string[]);
  25.     native FindPlayer(const string[]);
  26. */
  27. stock SetMapNameModeText(string[])
  28. {
  29.     new str[32];
  30.     format(str, 32, "mapname %s", string);
  31.     SendRconCommand(str);
  32. }
  33.  
  34. stock ReturnNameGang( name[] )
  35. {
  36.     new gang[MAX_PLAYER_NAME] = "Unknown";
  37.     if ( strfind( name , "[" , true ) == -1 ) return gang;
  38.     if ( strfind( name , "]" , true ) == -1 ) return gang;
  39.     strmid( gang , name , strfind( name , "[" , true )+1 , strfind( name , "]" , true )-1 , sizeof( gang ) );
  40.     return gang;
  41. }
  42.  
  43. stock ReturnPlayerGang( playerid )
  44. {
  45.         new gang[MAX_PLAYER_NAME] = "Unknown";
  46.         new name[MAX_PLAYER_NAME];
  47.  
  48.         GetPlayerName(playerid,name,sizeof(name));
  49.  
  50.     if ( strfind( name , "[" , true ) == -1 ) return gang;
  51.     if ( strfind( name , "]" , true ) == -1 ) return gang;
  52.     strmid( gang , name , strfind( name , "[" , true )+1 , strfind( name , "]" , true )-1 , sizeof( gang ) );
  53.     return gang;
  54. }
  55.  
  56. stock NameContainsGang(playerid,clan[])
  57. {
  58.         new gang[MAX_PLAYER_NAME] = "Unknown";
  59.         new name[MAX_PLAYER_NAME];
  60.  
  61.         GetPlayerName(playerid,name,sizeof(name));
  62.  
  63.     if ( strfind( name , "[" , true ) == -1 ) return false;
  64.     if ( strfind( name , "]" , true ) == -1 ) return false;
  65.         strmid( gang , name , strfind( name , "[" , true )+1 , strfind( name , "]" , true )-1 , sizeof( gang ) );
  66.     if(strcpy(clan,gang)) return true;
  67.         else return false;
  68. }
  69.  
  70. stock FindPlayer(const string[])
  71. {
  72.     new id = strval(string);
  73.     if(isNumeric(string) && id >= 0 && id < GetMaxPlayers()) {
  74.         return IsPlayerConnected(id) ? id : INVALID_PLAYER_ID;
  75.     }
  76.     return ReturnPlayerID(string);
  77. }
  78.  
  79. stock SetAllPlayersScore(Score)
  80. {
  81.     foreach(Player, i)
  82.     {
  83.         SetPlayerScore( i, Score );
  84.     }
  85.  
  86.     return 1;
  87. }
  88.  
  89. stock GiveAllPlayersWeapon(Weaponid,Ammo)
  90. {
  91.     foreach(Player, i)
  92.     {
  93.         GivePlayerWeapon( i, Weaponid, Ammo );
  94.     }
  95. }
  96.  
  97. stock ResetAllPlayersCash()
  98. {
  99.     foreach(Player, i)
  100.     {
  101.         ResetPlayerMoney( i );
  102.     }
  103.  
  104.     return 1;
  105. }
  106.  
  107. stock KickAllPlayers()
  108. {
  109.     foreach(Player, i)
  110.     {
  111.         Kick( i );
  112.     }
  113.  
  114.     return 1;
  115. }
  116.  
  117. stock BanAllPlayers()
  118. {
  119.     foreach(Player, i)
  120.     {
  121.         Ban( i );
  122.     }
  123.  
  124.     return 1;
  125. }
  126.  
  127. stock SetAllPlayersVirtualWorld( World )
  128. {
  129.     foreach(Player, i)
  130.     {
  131.         SetPlayerVirtualWorld( i, World );
  132.     }
  133.  
  134.     return 1;
  135. }
  136.  
  137. stock SetAllPlayersSkin( SkinID )
  138. {
  139.     foreach(Player, i)
  140.     {
  141.         SetPlayerSkin( i, SkinID );
  142.     }
  143.  
  144.     return 1;
  145. }
  146.  
  147. stock SetAllPlayersInterior( Interior )
  148. {
  149.     foreach(Player, i)
  150.     {
  151.         SetPlayerInterior( i, Interior );
  152.     }
  153.  
  154.     return 1;
  155. }
RAW Paste Data