[HELP] Create weapons on the floor!!!
#1

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

Reply
#2

https://sampwiki.blast.hk/wiki/Pickup_help
https://sampwiki.blast.hk/wiki/CreatePickup
Reply
#3

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.
Reply
#4

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)