Small help
#1

Hello, i have this command to drop the player weapons.

I wanna make just to drop ONLY the current weapon he's holding, how i can fix it?

pawn Код:
CMD:d(playerid, params[])
{
    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 Float:X = x + (random(3) - random(3));
        new Float:Y = y + (random(3) - random(3));
        if(playerweapons[i][1] != 0 && model != -1)
        {
            if(times > DropLimit) times = DropLimit;
            for(new a=0; a<times; a++)
            {
                new pickupid = CreatePickup(model, 3, X, Y, z);
                SetTimerEx("DeletePickup", DeleteTime*1000, false, "d", pickupid);
            }
        }
    }
    return 1;
}
Reply
#2

Код:
stock ResetPlayerWeapon(playerid,weaponid)
{
    new weap[12], ammo[12];
    for(new i = 0; i < 12; i++)
	{
        GetPlayerWeaponData(playerid,i,weap[i],ammo[i]);
    }
    ResetPlayerWeapons(playerid);
    for(new i = 0; i < 12; i++)
	{
        if(weap[i] != weaponid)
		{
            GivePlayerWeapon(playerid,weap[i],ammo[i]);
        }
    }
    return 0;
}
Reply
#3

Doesn't work.
Reply
#4

pawn Код:
forward DropWeapon(playerid,weaponid);
public DropWeapon(playerid,weaponid)
{
    if(weaponid > 0)
    {
        new tempweapon[13],tempammo[13];
        for (new x=0; x<13; x++)
        {
            GetPlayerWeaponData(playerid,x,tempweapon[x],tempammo[x]);
        }
        ResetPlayerWeapons(playerid);
        for (new x=0; x<13; x++)
        {
            if(tempweapon[x] != weaponid)
            {
                GivePlayerWeapon(playerid,tempweapon[x],tempammo[x]);
            }
        }
    }
    return 1;
}
[EIDT] lol I see now that lelemaster almost has te same...
Reply
#5

My codes are updated. That should work.
Reply
#6

Quote:
Originally Posted by lelemaster
Посмотреть сообщение
My codes are updated. That should work.
Now it will never work, you say else return 1; when the weaponid that should get removed is arrived in the loop, what about the other weapons that he has which will come after the removing weaponid in the loop?
You skip those, so this will not work.
Reply
#7

You are right. Re updated first post... xD

I,ll test it on my server, I'll have the result in 10 mins.

Edit: Codes works fine, the first one I gave, there codes of Roel ( I guess, it's not tested, but they are the same... xD), and the one I just gave you.

Edit2: To make it works, just do: ResetPlayerWeapon(playerid, GetPlayerWeapon(playerid));
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)