Pickups cannot be picked

Started by Fjose, May 25, 2015, 03:40 PM

Previous topic - Next topic

Fjose

I can't take the weapons from the pickups, I'm not seeing any problems on the script.

        CreatePickup( 280, Vector( -1744.31, -299.216, 14.8683 ) ); // m4 group
CreatePickup( 274, Vector( -1741.35, -294.67, 14.8683 ) ); // col group
CreatePickup( 274, Vector( -1691.8, -177.954, 14.8683 ) );
CreatePickup( 289, Vector( -1663.16, -129.052, 14.8683 ) ); // m6 group


function onPickupPickedUp( player, pickup )
{
local model = pickup.Model, id = player.ID, p = pinfo[id];
switch( model )
{
case 274:
return player.SetWeapon( 274, 50 );
break;
case 280:
return player.SetWeapon( 280, 60 );
break;
case 289:
return player.SetWeapon( 289, 40 );
break;
case 408:
return gMessage( id, mGreen, "Your Financial Status - Cash: $" + Bytes( p.Cash ) + ", Bank: $" + Bytes( p.Bank ) );
default:
break;
}
pickup.RespawnTime = 5;
}

.

I think you need the function that decides whether a pickup can be picked by a player or not.

function onPickupClaimPicked(player, pickup)
{
return true; // true: Allow to pick-up. false: deny pick-up.
}
.

Fjose

Quote from: S.L.C on May 25, 2015, 03:47 PMI think you need the function that decides whether a pickup can be picked by a player or not.

function onPickupClaimPicked(player, pickup)
{
return true; // true: Allow to pick-up. false: deny pick-up.
}

nothing happens

jayant

#3
function onPickupPickedUp( player, pickup )
{
  pickup.RespawnTime = 5;
  local model = pickup.Model, id = player.ID, p = pinfo[id];
   if( model ==  274 )  player.SetWeapon( 274, 50 );
   else if ( model == 280 )  player.SetWeapon( 280, 60 );
   else if ( model ==  289 )   player.SetWeapon( 289, 40 );
   else if ( model ==  408 )  gMessage( id, mGreen, "Your Financial Status - Cash: $" + Bytes( p.Cash ) + ", Bank: $" + Bytes( p.Bank ) );
 }

A small mistake of else if..ty @Beztone

MacTavish

#4
Quote from: jayant on May 25, 2015, 04:36 PMfunction onPickupPickedUp( player, pickup )
{
  pickup.RespawnTime = 5;
  local model = pickup.Model, id = player.ID, p = pinfo[id];
   if( model ==  274 )  player.SetWeapon( 274, 50 );
   if ( model == 280 )  player.SetWeapon( 280, 60 );
   if ( model ==  289 )   player.SetWeapon( 289, 40 );
   if ( model ==  408 )  gMessage( id, mGreen, "Your Financial Status - Cash: $" + Bytes( p.Cash ) + ", Bank: $" + Bytes( p.Bank ) );
 }

It would be function onPickupPickedUp( player, pickup )
{
  pickup.RespawnTime = 5;
  local model = pickup.Model, id = player.ID, p = pinfo[id];
   if( model ==  274 )  player.SetWeapon( 274, 50 );
   else if ( model == 280 )  player.SetWeapon( 280, 60 );
  else if ( model ==  289 )   player.SetWeapon( 289, 40 );
  else if ( model ==  408 )  gMessage( id, mGreen, "Your Financial Status - Cash: $" + Bytes( p.Cash ) + ", Bank: $" + Bytes( p.Bank ) );
 }

Also try

function onPickupPickedUp( player, pickup )
{
 local model = pickup.Model, id = player.ID, p = pinfo[id];
 switch( model )
 {
  case 274:
    player.SetWeapon( 274, 50 );
   break;
  case 280:
   player.SetWeapon( 280, 60 );
   break;
  case 289:
   player.SetWeapon( 289, 40 );
   break;
  case 408:
   gMessage( id, mGreen, "Your Financial Status - Cash: $" + Bytes( p.Cash ) + ", Bank: $" + Bytes( p.Bank ) );
   break;
return;
 }
 pickup.RespawnTime = 5;
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Fjose


MacTavish


Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

Those aren't valid weapon IDs.

Stormeus

Quote from: Thijn on May 26, 2015, 05:44 AMThose aren't valid weapon IDs.

Bingo.

The server can also automatically handle weapon pickups. Pickup.Automatic = true, Pickup.Quantity = <AMMO>

Fjose

ok, I have this.

        CreatePickup( 280, 1, 60, Vector( -1744.31, -299.216, 14.8683 ), 255, true ); // m4 group
CreatePickup( 274, 1, 50, Vector( -1741.35, -294.67, 14.8683 ), 255, true ); // col group
CreatePickup( 274, 1, 50, Vector( -1691.8, -177.954, 14.8683 ), 255, true );
CreatePickup( 289, 1, 40, Vector( -1663.16, -129.052, 14.8683 ), 255, true ); // m6 group

function onPickupPickedUp( player, pickup )
{
local model = pickup.Model, id = player.ID, p = pinfo[id];
switch( model )
{
case 274:
case 280:
case 289:
FindPickup( pickup.ID ).Remove();
FindPickup( pickup.ID ).RespawnTime( 5 );
return;
break;
case 408:
return gMessage( id, mGreen, "Your Financial Status - Cash: $" + Bytes( p.Cash ) + ", Bank: $" + Bytes( p.Bank ) );
break;
default:
break;
}
}

but there is an error using FindPickup( pickup.ID ).RespawnTime( 5 ); or FindPickup( pickup.ID ).RespawnTime = 5;

>> Error: Attempt to call an integer. <<

How use that function? I had no problems with that function on the 0.3


.

#10
Quote from: Fjose on May 27, 2015, 03:32 PMFindPickup( pickup.ID ).RespawnTime( 5 );

Look closer. You are using RespawnTime as if it were a function, which it isn't (it's a property). See if this looks familiar:
local var = 243;

var();
.

Fjose

I've found another solution using pickup.Timer that does the same like pickup.RespawnTime ( I guess, this function doesn't work on 0.4)