SA-MP Forums Archive
[HELP] Create weapons on the floor!!! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Create weapons on the floor!!! (/showthread.php?tid=144323)



[HELP] Create weapons on the floor!!! - J. - 26.04.2010

How to create weapons to the ground as in the picture below?




Re: [HELP] Create weapons on the floor!!! - XRVX - 26.04.2010

https://sampwiki.blast.hk/wiki/Pickup_help
https://sampwiki.blast.hk/wiki/CreatePickup


Re: [HELP] Create weapons on the floor!!! - russo666 - 26.04.2010

Here is an example, hope you learn something from it.

pawn Код:
if(strcmp(cmd, "/objectdeagle", true) == 0)
    {
        new Float: X, Float: Y, Float: Z;
      GetPlayerPos(playerid, X, Y, Z);
      new weapon = GetPlayerWeapon(playerid);
      if(weapon != 0)
      {
       if(weapon == 24)
       {
        RemovePlayerWeapon(playerid, 24);
        CreateObject(348,X, Y, Z-1,85,0,0);
            return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "You don't have a Desert Eagle!");
        }
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, "You don't have any weapon!");
        }
        return 1;
    }
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
    if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
      return;
    new
      saveweapon[13],
      saveammo[13];
    // Probably could be done using one loop
    for(new slot = 0; slot < 13; slot++)
    GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);
    ResetPlayerWeapons(playerid);
    for(new slot; slot < 13; slot++)
    {
        if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
            continue;
        GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
    }
    // give them weapon ID 0 to reset the current armed weapon
    // to a fist and not the last weapon in their inventory
    GivePlayerWeapon(playerid, 0, 1);

}
If you got any errors like undefined "cmd" you need to put in on the begining of your OnPlayerCommandText:

pawn Код:
new cmd[256];
cmd = strtok(cmdtext, idx);

THAT CODE ISN'T MINE!

Font: http://forum.sa-mp.com/index.php?top...1067#msg961067

The RemovePlayerWeapon function i got it from somewhere and i can't remember where. So the credits goes for the creator. =D

EDIT: If you want pickups just look the post before.



Re: [HELP] Create weapons on the floor!!! - FlashInTheNighT - 08.05.2010

what if I want to remove all of the player's weapons ?


Re: [HELP] Create weapons on the floor!!! - luigifan9 - 09.05.2010

Quote:
Originally Posted by FlashInTheNighT
what if I want to remove all of the player's weapons ?
pawn Код:
ResetPlayerWeapons(playerid);



Re: [HELP] Create weapons on the floor!!! - Scenario - 10.05.2010

Quote:
Originally Posted by luigifan9
Quote:
Originally Posted by FlashInTheNighT
what if I want to remove all of the player's weapons ?
pawn Код:
ResetPlayerWeapons(playerid);
Yeah, you would use
pawn Код:
ResetPlayerWeapons(playerid);