Gun id?
#1

How do i can make a script

/gun id gives your the gun with 500 ammo i searched on web but i didnt find.
Reply
#2

Learn Pawn and then you'll figure it out.
Reply
#3

You'll need,
GivePlayerWeapon: https://sampwiki.blast.hk/wiki/GivePlayerWeapon
and weapon IDs: https://sampwiki.blast.hk/wiki/Weapons

It'll look something like this in your { } braces:
pawn Код:
GivePlayerWeapon(playerid, weapid, 500)
Reply
#4

Click You didn't search at all. It would have taken 3 seconds.
Reply
#5

I Made this.

Код:
CMD:givegun(playerid, params[])
{
	new gID, weap, ammo;
 	if(PlayerInfo[playerid][pOnDuty] < 1) return 0;
	if(PlayerInfo[playerid][pAdminLevel] < 2) return 0;
	SendClientMessage(playerid, 8, "USAGE:/givegun [id/name] [ammo]");
	if(!IsPlayerConnected(gID)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
	if(weap == 0 && 0 && 0) return SendClientMessage(playerid,COLOR_RED,"ERROR: Invalid weapon ID");
	GivePlayerWeapon(gID,weap,ammo);
	return 1;
}
Reply
#6

I'll ignore all of the responses on this thread that completely neglected the fact that you asked how to structure the command itself, and not the physical aspect of giving the player a weapon. While I still think you could of found this on ****** or the forums with about three minutes of effort, I'll go ahead and help you out.

Seeing as how you are a new scripter, I would recommend using ZCMD. It really simplifies the process of making commands. You'll also need the Sscanf2 plugin. Pardon the poor indentation, I'm

ZCMD Link
Sscanf2 Link

Код:
COMMAND:gun(playerid, params[])
{
	return 1;
}
Place this to create the command. Now we need to decide what happens inside of it. The following block of code basically says that if the player types /gun but doesn't type a gun ID, it will show them the command syntax.

Код:
COMMAND:gun(playerid, params[])
{
	new gunid;
	if(sscanf(params, "i", gunid))
	{
		SendClientMessage(playerid, 0xFFFFFF, "/gun (gunid)");
	}	
	return 1;
}
Now we add what happens when the player types /gun (some number).

Код:
COMMAND:gun(playerid, params[])
{
	new gunid;
	if(sscanf(params, "i", gunid))
	{
		SendClientMessage(playerid, 0xFFFFFF, "/gun (gunid)");
	}
	else
	{
		GivePlayerWeapon(playerid, gunid, 500);
	}	
	return 1;
}
If you want to be thorough, you will need to add a check to ensure that gunid is a valid gun id. I'm going to assume you can finish that off by yourself.
Reply
#7

Could take a look at the fsdebug filterscript.
Reply
#8

pawn Код:
CMD:gun(playerid, params[])
{
    GivePlayerWeapon(playerid, weaponID, Amount);
    return 1;
}
Not that hard.

If you are using weapons that has the same slot you will only receive one of them.
https://sampwiki.blast.hk/wiki/Weapons
Reply
#9

Код:
COMMAND:gun(playerid, params[])
{
	if(PlayerInfo[playerid][pOnDuty] < 1) return 0;
	if(PlayerInfo[playerid][pAdminLevel] < 2) return 0;
	new gunid;
	if(sscanf(params, "i", gunid))
	{
		SendClientMessage(playerid, 0xFFFFFF, "/gun (gun-id)");
	}
	else
	{
		GivePlayerWeapon(playerid, gunid, 100000);
	}
	return 1;
}
I do /gun 38 no works only
melee weapons sword knuckle etc.
Reply
#10

Quote:
Originally Posted by AmsterdamCopsAndRobbers
Посмотреть сообщение
Код:
COMMAND:gun(playerid, params[])
{
	if(PlayerInfo[playerid][pOnDuty] < 1) return 0;
	if(PlayerInfo[playerid][pAdminLevel] < 2) return 0;
	new gunid;
	if(sscanf(params, "i", gunid))
	{
		SendClientMessage(playerid, 0xFFFFFF, "/gun (gun-id)");
	}
	else
	{
		GivePlayerWeapon(playerid, gunid, 100000);
	}
	return 1;
}
I do /gun 38 no works only
melee weapons sword knuckle etc.
Unless you are using an enumeration called PlayerInfo which has the variables pOnDuty and pAdminLevel, his code won't work in your script. I'm not sure why he gave you code that is so static that it can really only be used in one script. Besides, you didn't ask for the command to be admin only. Looks like this was just copied from someone's script.

Use the code I posted if you want something that works.

Quote:
Originally Posted by NathNathii
Посмотреть сообщение
pawn Код:
CMD:gun(playerid, params[])
{
    GivePlayerWeapon(playerid, weaponID, Amount);
    return 1;
}
Not that hard.

If you are using weapons that has the same slot you will only receive one of them.
https://sampwiki.blast.hk/wiki/Weapons
That command will do absolutely nothing at all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)