/givegun question
#1

hi guys.
can anyone give me a /givegun playerid weapname / id ammo

i use dcmd & sscanf

i hope anyone can help me out
Reply
#2

Try to make your self...IF you dont know how to make look at FS Debug there is something like that you looking for!
Reply
#3

ye for vehicles but not for weapons
Reply
#4

Use sscanf.

pawn Код:
new id, weapon[32];
if(sscanf(params, "rs[32])) return SendClientMessage(playerid, red, "USAGE: /giveweapon [player name/id] [weapon name]");
Then get the weapon ID from the name (there are functions for this).
Reply
#5

like the same as GetVehicleIdFromName ?
Reply
#6

Quote:
Originally Posted by Tigerkiller
Посмотреть сообщение
ye for vehicles but not for weapons
Also have for weapons....
Reply
#7

can anyone give me the code pls also for GiveWeaponIdFromName ?
Reply
#8

GiveWeaponIDFromName? umad.
Код:
GetPlayerID(name[]);
About the other thing - Make it yourself.
Reply
#9

Here, have mine.

Код:
#include <a_samp>
#include "../include/sscanf.inc"

public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256], params[256];
	sscanf(cmdtext, "ss", cmd, params);

	// Give a weapon to a player
	if(!strcmp(cmd, "/giveweapon", true)) // Give a weapon to a player
	{
		if(IsPlayerAdmin(playerid)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN {FFFF00}: You are not an admin.");
		new target;
		new weapon;
		new ammo;
	    if(sscanf(params, "ddd", target, weapon, ammo)) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Usage: {FF4040}/GIVEGUN [player id] [weapon id] [ammo]{FFFF00}.");
		if(IsPlayerConnected(target)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEWEAPON{FFFF00}: Invalid player ID.");
		if(weapon < 1 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 44 || weapon == 45 || weapon == 47) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid weapon ID.");
		if(ammo <= 0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid ammo amount.");
	    GivePlayerWeapon(target,weapon,ammo);
	    new targetname[MAX_PLAYER_NAME];
	    GetPlayerName(target,targetname,sizeof(targetname));
	    new sendername[MAX_PLAYER_NAME];
	    GetPlayerName(playerid,sendername,sizeof(sendername));
		new string[128];
		if(target == playerid)
		{
		    format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave yourself {0080FF}weapon %d{FFFF00}.", weapon);
		    SendClientMessage(playerid,0xFFFFFFFF,string);
		    return 1;
		}
		format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave {0080FF}weapon %d {FFFF00}to {FF40FF}%s{FFFF00}.",weapon,targetname);
		SendClientMessage(playerid,0xFFFFFFFF,string);
		format(string,sizeof(string),"{FF40FF}%s {FFFF00}gave you {0080FF}weapon %d{FFFF00}.", sendername, weapon);
		SendClientMessage(target,0xFFFFFFFF,string);
		return 1;
	}

	return 0;
}
Please rep this post if I helped you.
Reply
#10

Quote:
Originally Posted by Superthijs
Посмотреть сообщение
Here, have mine.

Код:
#include <a_samp>
#include "../include/sscanf.inc"

public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[256], params[256];
	sscanf(cmdtext, "ss", cmd, params);

	// Give a weapon to a player
	if(!strcmp(cmd, "/giveweapon", true)) // Give a weapon to a player
	{
		if(IsPlayerAdmin(playerid)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN {FFFF00}: You are not an admin.");
		new target;
		new weapon;
		new ammo;
	    if(sscanf(params, "ddd", target, weapon, ammo)) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Usage: {FF4040}/GIVEGUN [player id] [weapon id] [ammo]{FFFF00}.");
		if(IsPlayerConnected(target)==0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEWEAPON{FFFF00}: Invalid player ID.");
		if(weapon < 1 || weapon == 19 || weapon == 20 || weapon == 21 || weapon == 44 || weapon == 45 || weapon == 47) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid weapon ID.");
		if(ammo <= 0) return SendClientMessage(playerid,0xFFFFFFFF,"{FF0000}/GIVEGUN{FFFF00}: Invalid ammo amount.");
	    GivePlayerWeapon(target,weapon,ammo);
	    new targetname[MAX_PLAYER_NAME];
	    GetPlayerName(target,targetname,sizeof(targetname));
	    new sendername[MAX_PLAYER_NAME];
	    GetPlayerName(playerid,sendername,sizeof(sendername));
		new string[128];
		if(target == playerid)
		{
		    format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave yourself {0080FF}weapon %d{FFFF00}.", weapon);
		    SendClientMessage(playerid,0xFFFFFFFF,string);
		    return 1;
		}
		format(string,sizeof(string),"{FF0000}/GIVEGUN{FFFF00}: You gave {0080FF}weapon %d {FFFF00}to {FF40FF}%s{FFFF00}.",weapon,targetname);
		SendClientMessage(playerid,0xFFFFFFFF,string);
		format(string,sizeof(string),"{FF40FF}%s {FFFF00}gave you {0080FF}weapon %d{FFFF00}.", sendername, weapon);
		SendClientMessage(target,0xFFFFFFFF,string);
		return 1;
	}

	return 0;
}
Please rep this post if I helped you.
He doesnt want this.your script aloows him to type playerid,weaponid and ammo while he wants playerid/name weaponsid/name ammo.so this is wrong.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)