give his gun to a player?
#4

I've created this:

pawn Код:
if(strcmp(cmd,"/givegun",true)==0)
  {
  tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, _COLOR_WHITE, "Usage: /givegun [ID]");
        return 1;
    }
    giveplayerid = strval(tmp);
    if(IsPlayerConnected(giveplayerid))
    {
        new weaponname[30];
        new ammo = GetPlayerAmmo(playerid);
        new weapon = GetPlayerWeapon(playerid);
        if(weapon == 0){format(weaponname,sizeof(weaponname),"Unarmed (Fist)"); ammo = 0;}
        else if(weapon == 1){format(weaponname,sizeof(weaponname),"Brass Knuckles"); ammo = 0;}
        else if(weapon == 2){format(weaponname,sizeof(weaponname),"Golf Club"); ammo = 0;}
        else if(weapon == 3){format(weaponname,sizeof(weaponname),"Nite Stick"); ammo = 0;}
        else if(weapon == 4){format(weaponname,sizeof(weaponname),"Knife"); ammo = 0;}
        else if(weapon == 5){format(weaponname,sizeof(weaponname),"Baseball Bat"); ammo = 0;}
        else if(weapon == 6){format(weaponname,sizeof(weaponname),"Shovel"); ammo = 0;}
        else if(weapon == 7){format(weaponname,sizeof(weaponname),"Pool Cue"); ammo = 0;}
        else if(weapon == 8){format(weaponname,sizeof(weaponname),"Katana"); ammo = 0;}
        else if(weapon == 9){format(weaponname,sizeof(weaponname),"Chainsaw"); ammo = 0;}
        else if(weapon == 10){format(weaponname,sizeof(weaponname),"Purple Dildo"); ammo = 0;}
        else if(weapon == 11){format(weaponname,sizeof(weaponname),"Small White Vibrator"); ammo = 0;}
        else if(weapon == 12){format(weaponname,sizeof(weaponname),"Large White Vibrator"); ammo = 0;}
        else if(weapon == 13){format(weaponname,sizeof(weaponname),"Silver Vibrator"); ammo = 0;}
        else if(weapon == 14){format(weaponname,sizeof(weaponname),"Flowers"); ammo = 0;}
        else if(weapon == 15){format(weaponname,sizeof(weaponname),"Cane"); ammo = 0;}
        else if(weapon == 18){format(weaponname,sizeof(weaponname),"Molotov Cocktail"); ammo = GetPlayerAmmo(playerid);}
        else if(weapon == 44){format(weaponname,sizeof(weaponname),"Nightvision Goggles"); ammo = 0;}
        else if(weapon == 45){format(weaponname,sizeof(weaponname),"Thermal Goggles"); ammo = 0;}
        else
        {
      GetWeaponName(weapon, weaponname, sizeof(weaponname));
      }
        GivePlayerWeapon(playerid,weapon,-ammo);
      GivePlayerWeapon(playerid,weapon,ammo);
      GetPlayerName(playerid, playername, sizeof(playername));
      GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
      format(string,sizeof(string),"You give %s the weapon \"%s\" with %d ammo.",giveplayer, weaponname, ammo);
      SendClientMessage(playerid,_COLOR_YELLOW,string);
      format(string,sizeof(string),"You got from %s the weapon \"%s\" with %d ammo.",playername, weaponname, ammo);
      SendClientMessage(playerid,_COLOR_YELLOW,string);
    }
    else
    {
        SendClientMessage(playerid, _COLOR_WHITE, "This ID doesn't exists.");
        return 1;
    }
    return 1;
    }

Everyone can use it, if you like.
Reply


Messages In This Thread
give his gun to a player? - by Headshot1108 - 10.04.2010, 21:58
Re: give his gun to a player? - by Dark_Kostas - 10.04.2010, 22:05
Re: give his gun to a player? - by johnnyc - 10.04.2010, 22:40
Re: give his gun to a player? - by Headshot1108 - 10.04.2010, 22:58
Re: give his gun to a player? - by johnnyc - 10.04.2010, 23:45
Re: give his gun to a player? - by [LF]Mr.Lucci - 02.05.2010, 03:23

Forum Jump:


Users browsing this thread: 2 Guest(s)