Weapon Drop on Death issue
#1

hi,

i wanted to script a code that creates a weapon pickup when a player dies.
So other players might pick the weapon up of the player theyve killed.
Ive tried it like in the code below but there are several bugs...
First of all i use incognitos streamer plugin so i use the callback
pawn Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
This is the code:
pawn Код:
forward DropPlayerWeapons(playerid);
forward DeletePickup(pickupid);
forward GetWeaponModel(weaponid);

new WeaponDrop;

new DropLimit = 4;//max. 4 pickups can be dropped per player
new DeleteTime = 30;//deletes the pickup after 30 secs if not picked up


//OnPlayerDeath

DropPlayerWeapons(playerid);


//OnPlayerPickUpDynamicPickup

if(pickupid == WeaponDrop)
{
DestroyDynamicPickup(WeaponDrop);//delete the pickup after pickup
}


public DropPlayerWeapons(playerid)
{
    new playerweapons[13][2];
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid, x, y, z);

    for(new i=0;i<13;i++){
        GetPlayerWeaponData(playerid, i, playerweapons[i][0], playerweapons[i][1]);
        new model=GetWeaponModel(playerweapons[i][0]);
        new times=floatround(playerweapons[i][1]/10.0001);
        new string[256];
        format(string, sizeof(string), "%d", times);
        times=strval(string);
        new Float:X=x+(random(3)-random(3));
        new Float:Y=y+(random(3)-random(3));
        if(playerweapons[i][1]!=0)
        {
            if(times>DropLimit) times=DropLimit;
            for(new a=0;a<times;a++)
            {
                if(model!=-1)
                {
                    WeaponDrop = CreateDynamicPickup(model, 4, X, Y, z);
                    SetTimerEx("DeletePickup", DeleteTime*1000, false, "d", WeaponDrop);
                }
            }
        }
    }
    return 1;
}

public DeletePickup(pickupid)//delete timer
{
    DestroyDynamicPickup(WeaponDrop);
    return 1;
}

public GetWeaponModel(weaponid)
{
    new model;

    switch(weaponid)
    {
        case 1: model=331; case 2: model=333; case 3: model=334;
        case 4: model=335; case 5: model=336; case 6: model=337;
        case 7: model=338; case 8: model=339; case 9: model=341;
        case 10: model=321; case 11: model=322; case 12: model=323;
        case 13: model=324; case 14: model=325; case 15: model=326;
        case 16: model=342; case 17: model=343; case 18: model=344;
        case 22: model=346; case 23: model=347; case 24: model=348;
        case 25: model=349; case 26: model=350; case 27: model=351;
        case 28: model=352; case 29: model=353; case 30: model=355;
        case 31: model=356; case 32: model=372; case 33: model=357;
        case 34: model=358; case 35: model=359; case 36: model=360;
        case 37: model=361; case 38: model=362; case 39: model=363;
        case 41: model=365; case 42: model=366; case 46: model=371;
    }
    if(model < 300 || model == 342 || model == 346 || model == 348 || model == 355 || model == 356 || model == 359 || model == 362) return -1;//weapons i dont want to be dropped

    return model;
}
Now the main problem is that if i die the weapon drops are created but if they are picked up by me for example and i die again there are pickups created at both locations. At the location of my first death and at the loaction of my second death.
Also the pickups are not the same for all players: If a player dies and the pickups are created and one player picks up the weapon drop they are not visible for him anymore but for another player they are still isible and pickupable.
I really hope that there is a pro scripter able to help me
Id be sooo happy about any help here cause i really dont know what to do anymore...

regards, BlackWolf.
Reply
#2

this is very important so i would be so happy about some hints
Pls, someone ?
Reply
#3

Try something like:

pawn Код:
public DeletePickup(pickupid)//delete timer
{
    DestroyDynamicPickup(WeaponDrop);
    // your var for storing position = 0;
    return 1;
}
Reply
#4

could u give me a short example using var?
pls, that would be great!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)