29.07.2012, 08:14
pawn Код:
DropWeapons(playerid){
new Float: px, Float: py, Float: pz;
new hour,minute,second;
new year, month,day;
gettime(hour, minute, second);
getdate(year, month, day);
GetPlayerPos( playerid, px, py, pz );
GivePlayerMoney(playerid,-500);
new weapon_slots[WEAPON_SLOTS + 1][2];
new used_weapon_slots;
for( new i = 0; i < WEAPON_SLOTS; i ++ ){
GetPlayerWeaponData( playerid, i, weapon_slots[ i ][ 0 ], weapon_slots[ i ][ 1 ]);
if( i == 0 && weapon_slots[ i ][ 0 ] == 0 ) weapon_slots[ i ][ 1 ] = 0; // no fist...
if( weapon_slots[ i ][ 1 ] > 0 && weapon_slots[ i ][ 0 ] < sizeof( weapons ) && weapons[ weapon_slots[ i ][ 0 ] ] != -1 ){
used_weapon_slots ++;}
else{
weapon_slots[ i ][ 0 ] = 0;
weapon_slots[ i ][ 1 ] = 0;}}
// Create the pickups
new used_weapon_slots2 = used_weapon_slots;
for( new i = 0; i < WEAPON_SLOTS; i ++ ){
if( weapon_slots[ i ][ 1 ] > 0 ){
new Float:angle = 360.0 - float(used_weapon_slots--) * ( 360.0 / float(used_weapon_slots2) );
// see... if there's a pickup we create by any chance
new p = CreateDynamicPickup( weapons[ weapon_slots[ i ][ 0 ] ], PICKUP_TYPE, px + floatsin(angle,degrees) * (used_weapon_slots2/2 + 1.0), py + floatcos(angle,degrees) * (used_weapon_slots2/2 + 1.0), pz );
if( p == INVALID_PICKUP ){
new lowest_time;
new _id;
for( new j = 0; j < MAX_PICKUPS; j ++ ){
if( pickups[ j ][ creation_time ] < lowest_time ){
lowest_time = pickups[ j ][ creation_time ];
_id = j;}}
DestroyPickupEx( _id );
KillTimer( pickups[ _id ][ ptimer ] );
p = CreateDynamicPickup( weapons[ weapon_slots[ i ][ 0 ] ], PICKUP_TYPE, px + floatsin(angle,degrees) * (used_weapon_slots2/2 + 1.0), py + floatcos(angle,degrees) * (used_weapon_slots2/2 + 1.0), pz );}
pickups[ p ][ creation_time ] = nmktime(hour,minute,second,day,month,year);
pickups[ p ][ weapon ] = weapon_slots[ i ][ 0 ];
pickups[ p ][ dammo ] = weapon_slots[ i ][ 1 ];
#if MAX_DROP_AMOUNT != -1
if( pickups[ p ][ dammo ] > MAX_DROP_AMOUNT ){
pickups[ p ][ dammo ] = MAX_DROP_AMOUNT;}
#endif
pickups[ p ][ ptimer ] = SetTimerEx("DestroyPickupEx", MAX_DROP_LIFETIME * 1000, 0, "i", p);}}}