Weapon spread out.
#1

I made that when a player dies, he will drop all his weapons, 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);
        }
        printf("%d,%d,%f,%d,%f,%d,%f,%d,%d",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;
}
And this in the debug print
Код:
[14:39:44] [command] [Mikkel_Reimer]: /kill
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 23,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 27,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 31,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 34,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] [death] Mikkel_Reimer died 255
They lay like this:
Reply
#2

Can you show us the value of the debug print when a weapon is dropped?
Reply
#3

I get this in the debug print

Код:
[14:39:44] [command] [Mikkel_Reimer]: /kill
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 23,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 27,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 31,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 34,32767,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] 0,0,1819.057739,3,-1840.432617,0,13.414062,0,0
[14:39:44] [death] Mikkel_Reimer died 255
Reply
#4

The reason is because the random function is ran only once and then saved in a var.
Add the random function inside the cycle and then it should work
Reply
#5

Would you mind doing it for me?
Reply
#6

pawn Код:
new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    new weaponID[13], weaponammo[13], rpos[2];
    for(new i = 0; i < 13; i++)
    {
            rpos[0] = random(7), rpos[1] = random(7);
            GetPlayerWeaponData(playerid, i, weaponID[i], weaponammo[i]);
            DropWeapons(weaponID[i], weaponammo[i], X + rpos[0], Y + rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
        printf("%d,%d,%f,%d,%f,%d,%f,%d,%d",weaponID[i], weaponammo[i], X, rpos[0], Y, rpos[1], Z, GetPlayerVirtualWorld(playerid), playerid);
    }
I am using my iPhone so it hasn't been easy! :P
Reply
#7

Oh shit! , but thanks alot, it works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)