Advertisement
momo5502

Random Attachement

Jun 25th, 2013
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 KB | None | 0 0
  1. AddRandomAttachment( weapon )
  2. {
  3.     weapon = subWeapon( weapon );
  4.  
  5.     attachements = getAttachements( weapon );
  6.  
  7.     return weapon + attachements[ randomint( attachements.size ) ] + "_mp";
  8. }
  9.  
  10. getAttachements( weapon )
  11. {
  12.     attachements = [];
  13.     for(i=12;;i++)
  14.     {
  15.         _return = TableLookup( "mp/statstable.csv", 4, weapon, i );
  16.        
  17.         if( _return == "" )
  18.             return attachements;
  19.            
  20.         attachements[ attachements.size ] = "_" + _return;
  21.     }
  22. }
  23.  
  24. subWeapon( weapon )
  25. {
  26.     size = weapon.size;
  27.     string = "";
  28.    
  29.     for( i=3;i>0;i--)
  30.         string += weapon[ size-i ];
  31.        
  32.     if( string != "_mp" )
  33.         return weapon;
  34.    
  35.     string = "";   
  36.    
  37.     for( i=0;i<size-3;i++)
  38.         string += weapon[ i ];
  39.        
  40.     return string;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement