Give gun
#1

I'm looking for /givegun command, /givegun [playerid] [ammo], im using zcmd and scnaff.
Any TUT? Searched but didn't find.
Reply
#2

If you searched for 'scnaff' then I'd reckon you didn't find anything. For your information: the function is called sscanf (string scan, according to a format).
Reply
#3

Paste "givegun sscanf site:forum.sa-mp.com" in ****** search, magic.
Reply
#4

Код:
#include <ocmd>

ocmd:givegun(playerid, params[])
{
  new id, wid, wam;
  if(sscanf(params, "uii", id, wid, wam))return SendClientMessage(playerid, -1, "USAGE: /givegun [Playername/ID]        [WeaponID] [Ammu]");
  if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, "Error:The player does not exist!");
  GivePlayerGun(id, wid, wam);
  return 1;
}
Here you have the givegun command, just written
Reply
#5

PHP код:
CMD:givegun(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= 3)
    {
        new 
targetgunstring[128];
        if(
sscanf(params"ud"targetgun))
        {
            
SendClientMessage(playeridCOLOR_GREY"Usage: /givegun <playerid> <gun>");
            return 
1;
        }
        if(
gun || gun 47) { SendClientMessage(playeridCOLOR_GREY"Don't go below 1 or above 47."); return 1; }
        if(
IsPlayerConnected(target))
        {
            if(
target != INVALID_PLAYER_ID && gun <= 20 || gun >= 22)
            {
                
GivePlayerValidWeapon(targetgun50000);
                
format(stringsizeof(string), "Admin %s has given you a weapon."GetName(playerid));
                
SendClientMessage(targetCOLOR_GREYstring);
                
format(stringsizeof(string), "You have given %s a weapon."GetName(target));
                
SendClientMessage(playeridCOLOR_GREYstring);
            }
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
        return 
1;
    }
    return 
1;

try this
Reply
#6

@CIBERKILLER i didn't mean this @ScripteRNaBEEL i didn't mean admincommand
i ment, player gives player a gun with ammo, /givegun [playerid] [ammo ammout], example:
/giveplayer 1 50
if player holding a mp5 ( gun, its just example ) with 250 bullets, its give the player id 1 a mp5 with 50 bullets, and the player who have 250 bullets, will lose 50 bullets. i hope you understand me.

here command from raven's roleplay, its not all command, and its not zcmd, it will help

Код:
			if(strcmp(x_nr,"gun",true) == 0)
			{
			    tmp = strtok(cmdtext, idx);
			    if(!strlen(tmp))
				{
					SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give gun [playerid/PartOfName] [amount]");
					return 1;
				}
				giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
				        new Float:x, Float:y, Float:z;
			            GetPlayerPos(giveplayerid,x,y,z);
				        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
			            if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z))
			            {
			                SendClientMessage(playerid, COLOR_GRAD1, "** Player is not near you!");
			                return 1;
			            }
						tmp = strtok(cmdtext, idx);
						if(!strlen(tmp))
						{
							SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /give gun [playerid/PartOfName] [amount]");
							return 1;
						}
						new sammo = GetPlayerAmmo(playerid);
						new weapon = GetPlayerWeapon(playerid);
						new ammo = strval(tmp);
						if(ammo > sammo)
						{
							SendClientMessage(playerid, COLOR_GREY, "* You don't have so many bullets.");
							return 1;
						}
						SafeGivePlayerWeapon(giveplayerid, weapon, ammo);
						SafeGivePlayerWeapon(playerid, weapon, -ammo);
						if(PlayerInfo[playerid][pSex] == 1)
						{
							format(string, sizeof(string), "* %s takes out his weapon and hands it to %s with %d bullets.", sendername, giveplayer, ammo);
						}
						else
						{
							format(string, sizeof(string), "* %s takes out her weapon and hands it to %s with %d bullets.", sendername, giveplayer, ammo);
						}
						ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
				        new y1, m, d;
						new h,mi,s;
						getdate(y1,m,d);
						gettime(h,mi,s);
						format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /give gun %s %d",d,m,y1,h,mi,s,sendername,giveplayer, ammo);
						CommandLog(string);
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GRAD1, "   Player is Offline!");
				    return 1;
				}
			}
Reply
#7

So you want the following, for example, I stand before you ingame & have a weapon in hand.
Let's say a Desert Eagle, then I give / givegun [deineid] [Munni] a.
And then you will be a Desert Eagle with ... Munnition passed or what?
Reply
#8

what this munni means lol,
okay let me explain good, i have a m4 with 300 bullets, i want to give you some bullets/gun, so i have to do /givegun [playerid] [bullets], example /givegun 0 50, so you will get a m4 with 50 bullets and i will lose 50 bullets.
Reply
#9

I meant with Munni, shots (bullet)
Yes it is easy to use SetPlayerAmmo & GivePlayerWeapon & GetPlayerAmmo
Reply
#10

can you make it for me?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)