Pickup issues
#1

Hello, im having a problem with onplayerpickuppickup....In my server when you die you drop the weapon you using at the moment...so i maked the player spawn a pickup type 1...So when you pick it up it gives u the weapon and self destroys...it works ok until the person dies 2 times in a row before pick up that item..so as an example if a person dies and drops an ak47 he comes back and dies again....you can grab the last ak 47..the first one stills there forever, no one else can touch it not even you...Whats the problem? its because 2 pickup haves same name or somethinG?

I just dont know how to fix that, tryed to delete every ak47 pickup before..and it wor ks, the first one spawnes deletes and a new one apears.but...if u pick it up it gives all weapons...WTF?? this haves no sense, and everything its ok its just if 2 picks up are at same time in the world the older one will get glitched and cant be picked up...so probably i will have to add a timer to pick up the weapon or it dissapears, but i dont know how exactly to do it, most times i add a timer in this game it makes random weird stuff, and loops forever even when i set the loop option to 0
Reply
#2

1. If I were you I would use a streamer, because you can create dynamic pickups in interiors.
2. Then you can use OnPlayerPickupDynamicPickup
3. Try pickup type 19 instead.
4. You can use an array to store the pickupid, and the weapon type, and also a number that represents how long the pickup has existed.
5. You can use a 5 or 10 second timer to check the gunpickup array, decrememnt the 'timer' element, and delete the pickup if the 'time variable' is zero.

here is a good streamer.
http://forum.sa-mp.com/showthread.ph...gnito+streamer

pawn Код:
#define MAX_GUN_PICKUPS 200

forward FiveSecond(); // on gamemode init you need to SetTimer("FiveSecond",5000,true);

enum gpdat { gp_time, gp_type };
new gunpickups[MAX_GUN_PICKUPS][gpdat];

...

public OnPlayerDeath(playerid, reason)
{
  ...
new player_interior = GetPlayerInterior(playerid);
new player_world = GetPlayerVirtualWorld(playerid);
new Float:px,Float:py,Float:pz;
GetPlayerPos(playerid,px,py,pz);

... //you will need to script the weapon detection and icon selection

new pickup = CreateDynamicPickup(358,19,px,py,pz,player_world,player_interior, -1, 50.0); //see streamer for details
gunpickups[pickup][gp_type] = // weaponid
gunpickups[pickup][gp_time] = 5; // variable for checking when to destroy the pickup

...

public OnPlayerPickupDynamicPickup(playerid, pickupid )
{
     if(pickupid < MAX_GUN_PICKUPS)
     {
          if(gunpickups[pickupid][gp_type] > 0)
          {
             //code to add weapon
             DestroyDynamicPickup(pickupid); //destroy the pickup manually when someone collects it
             gunpickups[pickupid][gp_type] = 0; //reset array variables
             gunpickups[pickupid][gp_time] = 0;
           }
...


public FiveSecond()
{
     for(new i = 0; i < MAX_GUN_PICKUPS;i++)
     {
           if(gunpickups[i][gp_time] > 0)
           {
                   gunpickups[i][gp_time]--;
                   if(gunpickups[i][gp_time] <= 0)
                   {
                         DestroyDynamicPickup(i);
                         gunpickups[i][gp_type] = 0;
                         gunpickups[i][gp_time] = 0;
                   }
            }
      }
      return 1;
}
This is rough code that I put here to give you the idea ( so don't just copy paste it ) if you don't want to use a streamer you will have to change the callbacks and pickup commands to suit. You don't have to do it this way, but at least it is a start for you.

good luck.
Reply
#3

im learning so i prefer to dont use stuff that idont understand anymore...i kinda dont understand ome stuff there....well i have no problem with interiors if someone dies inside a house i can see and take the pick up..t he problem is when 2 of same pick up are in the game..so i guess you meant to place the id into a variable or soemthing and delete all of them afther 50 seconds?
Reply
#4

CreatePickup will return a unique ID for each created pickup, if you use this ID as the reference for the array, they won't get mixed up.
Reply
#5

i just have...when you pick up it gives the weapon and destroys the pickupid so its supossed it must be different but its messed up anywais D=....

I have something like this..this is an example about one of the drops..the anothers are copy but different 3d model and gives the different weapons....It is there any way to easily fix this? XD

public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerWeapon(playerid) == 30)
{
aka_pickup = CreatePickup(355,1,X,Y,Z,1);
}
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == aka_pickup)
{

GivePlayerWeapon(playerid,30,99999);
DestroyPickup(pickupid);
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)