SA-MP Forums Archive
Small 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: Small help (/showthread.php?tid=385808)



Small help - Face9000 - 17.10.2012

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;
}



Re : Small help - lelemaster - 17.10.2012

Код:
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;
}



Re: Small help - Face9000 - 18.10.2012

Doesn't work.


Re: Small help - Roel - 18.10.2012

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...


Re : Small help - lelemaster - 18.10.2012

My codes are updated. That should work.


Re: Re : Small help - Roel - 18.10.2012

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.


Re : Small help - lelemaster - 18.10.2012

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));