new WeaponNames[47][] =
{
"Fist","BrassKnuckles","Golfclub","Nitestick","Knife","BaseballBat","Shovel","Poolcue","Katana","Chainsaw","PurpleDildo","SmallWhiteVibrator","LargeWhiteVibrator","SilverVibrator",
"Flowers","Cane","Grenade","Tearcas Grenade","Molotov Cocktail","Jetpack"," "," ","9mm","Silenced9mm","Deagle","Shotgun","Sawn-OffShotgun","SPAS-12",
"MicroUzi","MP5","AK-47","M4","Tec-9","Rifle","Sniperrifle","RPG","Heatseeker","Flamethrower","Minigun","SatchelCharge","Detonator","SprayCan","FireExtinguisher",
"Camera","NightvisionGoggles", "ThermalGoggles","Parachute"
};
command(giveweapon, playerid, params[])
{
new sWeapon;
new str[128];
new wepid, id, ammo;
if(sscanf(params, "udd", id, wepid, ammo)) return SendClientMessage(playerid, 0x66666666, "Usage: /giveweapon [Player ID] [Weapon ID] [Ammo] * You can only give 5000 ammo with the weapon *");
{
//sWeapon = GetWeaponModelIDFromName(wepid);
//if(sWeapon < 1 || sWeapon > 47) return SendClientMessage(playerid, 0x66666666, "That weapon model or ID doesn't exist.");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0x66666666, "That player is not connected.");
if(ammo > 5000 || ammo < 0) return SendClientMessage(playerid, 0x66666666, "You can only give between 1-5000 ammo");
if(playerid == id)
{
format(str, sizeof(str), "You have given yourself a %s [ID %d] with '%d' ammo.", WeaponNames[sWeapon], sWeapon, ammo);
SendClientMessage(id, 0x99000000, str);
GivePlayerWeapon(id, wepid, ammo);
}
else
{
format(str, sizeof(str), "You have given %s a '%s [ID %d]' with '%d' ammo.", RemoveUnderScore(id), WeaponNames[sWeapon], sWeapon, ammo);
SendClientMessage(playerid, 0x99000000, str);
format(str, sizeof(str), "You have been given a '%s [ID %d]' with '%d' ammo by %s", WeaponNames[sWeapon], sWeapon, ammo, RemoveUnderScore(playerid));
SendClientMessage(id, 0x99000000, str);
GivePlayerWeapon(id, wepid, ammo);
}
}
return 1;
}
GetWeaponModelIDFromName(wname[])
{
for(new i = 0; i < 47; i++)
{
if (i == 19 || i == 20 || i == 21) continue;
if (strfind(WeaponNames[i], wname, true) != -1)
{
return i;
}
}
return 1;
}
if(sscanf(params, "us[256]", id, wepid, ammo))
pawn Код:
|
//sWeapon = GetWeaponModelIDFromName(wepid);
//if(sWeapon < 1 || sWeapon > 47) return SendClientMessage(playerid, 0x66666666, "That weapon model or ID doesn't exist.");
command(giveweapon, playerid, params[])
{
new sWeapon;
new str[128];
new id, ammo;
if(sscanf(params, "usd[20]", id, params, ammo)) return SendClientMessage(playerid, 0x66666666, "Usage: /giveweapon [Player ID] [Weapon ID] [Ammo] * You can only give 5000 ammo with the weapon *");
{
sWeapon = GetWeaponModelIDFromName(params);
if(sWeapon < 1 || sWeapon > 47) return SendClientMessage(playerid, 0x66666666, "That weapon model or ID doesn't exist.");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0x66666666, "That player is not connected.");
if(ammo > 5000 || ammo < 0) return SendClientMessage(playerid, 0x66666666, "You can only give between 1-5000 ammo");
if(playerid == id)
{
format(str, sizeof(str), "You have given yourself a %s [ID %d] with '%d' ammo.", WeaponNames[sWeapon], sWeapon, ammo);
SendClientMessage(id, 0x99000000, str);
GivePlayerWeapon(id, sWeapon, ammo);
}
else
{
format(str, sizeof(str), "You have given %s a '%s [ID %d]' with '%d' ammo.", RemoveUnderScore(id), WeaponNames[sWeapon], sWeapon, ammo);
SendClientMessage(playerid, 0x99000000, str);
format(str, sizeof(str), "You have been given a '%s [ID %d]' with '%d' ammo by %s", WeaponNames[sWeapon], sWeapon, ammo, RemoveUnderScore(playerid));
SendClientMessage(id, 0x99000000, str);
GivePlayerWeapon(id, sWeapon, ammo);
}
}
return 1;
}
// we use k<function>
if(sscanf(params, "uk<weapon>d", id, sWeapon, ammo)) return SendClientMessage(playerid, 0x66666666, "Usage: /giveweapon [Player ID] [Weapon ID] [Ammo] * You can only give 5000 ammo with the weapon *");
// If its an invalid weapon the custom function returns -1
if(sWeapon == -1) return SendClientMessage(playerid, 0x66666666, "That weapon model or ID doesn't exist.");
Just use the custom specifier weapon, it should be included in the newest sscanf include
pawn Код:
|
Okay, I fixed it by commenting one of the lines out..
Now, the ID works the name works, but it has to be EXACT and Case Sensitive, is there a way to change this? |