SA-MP Forums Archive
Weapon drop problem..Please help. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Weapon drop problem..Please help. (/showthread.php?tid=395839)



Weapon drop problem..Please help.(updated codes) help! - Mikkel_RE - 27.11.2012

I made that when a player dies, all the weapons he got will drop on the floor, but when they drop they lay above each other, can you help me to make them spread out or something?

This is my code:
pawn Код:
new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new weaponID[13], weaponammo[13], rpos[4];
    rpos[0] = random(7),rpos[1] = random(7),rpos[2] = random(2),rpos[3] = random(2);
    for(new i = 0; i < 13; i++)
    {
        if(rpos[3] == 0 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 0 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
    }
pawn Код:
stock DropWeapons(gunID,gunAmmo,Float:X,Float:Y,Float:Z,world,playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    if(IsBadGun(gunID)) { return 1; }
    if(gunID != 0 && gunAmmo != 0)
    {
        for(new i = 0; i < sizeof(DropInfo); i++)
        {
            if(DropInfo[i][dx] == 0.0 && DropInfo[i][dy] == 0.0 && DropInfo[i][dz] == 0.0)
            {
                DropInfo[i][dType] = 1;
                DropInfo[i][dAmount][0] = gunID;
                DropInfo[i][dAmount][1] = gunAmmo;
                DropInfo[i][dx] = X;
                DropInfo[i][dy] = Y;
                DropInfo[i][dz] = Z;
                DropInfo[i][dWorld] = world;
                strcpy(DropInfo[i][dPlayerName],name,MAX_PLAYER_NAME);
                DropObject[i] = CreateObject(gh_GetObjectID(gunID), X, Y, Z-1,93.7,120.0,120.0, world);
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
They lay like this:


Re: Weapon drop problem..Please help. - PlayLSX_Founder - 28.11.2012

Show me your "DropWeapon" function.


Re: Weapon drop problem..Please help. - Ballu Miaa - 28.11.2012

Addition of random position to your position can help splitting them!

pawn Код:
new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new weaponID[13], weaponammo[13], rpos[4];
    rpos[0] = random(4),rpos[1] = random(4),rpos[2] = random(4),rpos[3] = random(2);
    for(new i = 0; i < 13; i++)
    {
        if(rpos[3] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y + rpos[1], Z + rpos[2], GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y - rpos[1], Z + rpos[2], GetPlayerVirtualWorld(playerid), playerid);
        }
    }



Re: Weapon drop problem..Please help. - Mikkel_RE - 28.11.2012

Well, they lay more randomly now, but they still lay together, and sometimes they are laying in the air


Re: Weapon drop problem..Please help. - Ballu Miaa - 28.11.2012

Allright ohh yeah for that this will be fine

pawn Код:
new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new weaponID[13], weaponammo[13], rpos[4];
    rpos[0] = random(4),rpos[1] = random(4),rpos[2] = random(2),rpos[3] = random(2);
    for(new i = 0; i < 13; i++)
    {
        if(rpos[3] == 0 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 0 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
    }



Re: Weapon drop problem..Please help. - Mikkel_RE - 28.11.2012

Yeah now they aint flying anymore, but they still lay above each other like on the picture i posted.


Re: Weapon drop problem..Please help. - Ballu Miaa - 28.11.2012

Try doing this then!
pawn Код:
new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new weaponID[13], weaponammo[13], rpos[4];
    rpos[0] = random(11),rpos[1] = random(11),rpos[2] = random(2),rpos[3] = random(2);
    for(new i = 0; i < 13; i++)
    {
        if(rpos[3] == 0 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 0 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
    }



Re: Weapon drop problem..Please help. - Mikkel_RE - 28.11.2012

When i put this the guns dont even show on the ground


Re: Weapon drop problem..Please help. - Ballu Miaa - 28.11.2012

Maybe its making them dissappear!! Lower the randomization!
pawn Код:
new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new weaponID[13], weaponammo[13], rpos[4];
    rpos[0] = random(7),rpos[1] = random(7),rpos[2] = random(2),rpos[3] = random(2);
    for(new i = 0; i < 13; i++)
    {
        if(rpos[3] == 0 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 0 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 0)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
        if(rpos[3] == 1 && rpos[2] == 1)
        {
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X - rpos[0], Y - rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        }
    }



Re: Weapon drop problem..Please help. - Mikkel_RE - 28.11.2012

I did, but they still lay above each other as on the picture