[HELP] Create weapons on the floor!!!
#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


Messages In This Thread
[HELP] Create weapons on the floor!!! - by J. - 26.04.2010, 17:30
Re: [HELP] Create weapons on the floor!!! - by XRVX - 26.04.2010, 17:32
Re: [HELP] Create weapons on the floor!!! - by russo666 - 26.04.2010, 17:48
Re: [HELP] Create weapons on the floor!!! - by FlashInTheNighT - 08.05.2010, 23:44
Re: [HELP] Create weapons on the floor!!! - by luigifan9 - 09.05.2010, 01:15
Re: [HELP] Create weapons on the floor!!! - by Scenario - 10.05.2010, 20:44

Forum Jump:


Users browsing this thread: 1 Guest(s)