07.02.2013, 00:00
Hi,
Why this command doesn't give the weapon to the targetid?
That's what I saw on sscanf2:
That's why I did:
Thanks
Why this command doesn't give the weapon to the targetid?
PHP код:
CMD:giveweapon(playerid, params[])
{
new weap,targetid, string[128];
if(sscanf(params,"uk<weapon>", targetid, weap)) return SendClientMessage(playerid, NO_PARAMS, "USAGE: /giveweapon [ID or Name] [Weapon]");
if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, ERROR, "Error: Player is not connected or is yourself");
GivePlayerWeapon(targetid, weap, 99999);
format(string, sizeof(string), "You have given a weapon to %s", Name(targetid));
SendClientMessage(playerid, SUCCESS, string);
format(string, sizeof(string), "You have received a weapon from %s", Name(playerid));
SendClientMessage(targetid, SUCCESS, string);
return 1;
}
PHP код:
SSCANF:weapon(string[])
{
// This function is VERY basic, needs VASTLY improving to detect variations.
if ('0' <= string[0] <= '9')
{
new
ret = strval(string);
if (0 <= ret <= 18 || 22 <= ret <= 46)
{
return ret;
}
}
else if (!strcmp(string, "Unarmed")) return 0;
else if (!strcmp(string, "Brass Knuckles")) return 1;
else if (!strcmp(string, "Golf Club")) return 2;
else if (!strcmp(string, "Night Stick")) return 3;
else if (!strcmp(string, "Knife")) return 4;
else if (!strcmp(string, "Baseball Bat")) return 5;
else if (!strcmp(string, "Shovel")) return 6;
else if (!strcmp(string, "Pool cue")) return 7;
else if (!strcmp(string, "Katana")) return 8;
else if (!strcmp(string, "Chainsaw")) return 9;
else if (!strcmp(string, "Purple Dildo")) return 10;
else if (!strcmp(string, "White Dildo")) return 11;
else if (!strcmp(string, "Long White Dildo")) return 12;
else if (!strcmp(string, "White Dildo 2")) return 13;
else if (!strcmp(string, "Flowers")) return 14;
else if (!strcmp(string, "Cane")) return 15;
else if (!strcmp(string, "Grenades")) return 16;
else if (!strcmp(string, "Tear Gas")) return 17;
else if (!strcmp(string, "Molotovs")) return 18;
else if (!strcmp(string, "Pistol")) return 22;
else if (!strcmp(string, "Silenced Pistol")) return 23;
else if (!strcmp(string, "Desert Eagle")) return 24;
else if (!strcmp(string, "Shotgun")) return 25;
else if (!strcmp(string, "Sawn Off Shotgun")) return 26;
else if (!strcmp(string, "Combat Shotgun")) return 27;
else if (!strcmp(string, "Micro Uzi")) return 28;
else if (!strcmp(string, "Mac 10")) return 28;
else if (!strcmp(string, "MP5")) return 29;
else if (!strcmp(string, "AK47")) return 30;
else if (!strcmp(string, "M4")) return 31;
else if (!strcmp(string, "Tec9")) return 32;
else if (!strcmp(string, "Rifle")) return 33;
else if (!strcmp(string, "Sniper Rifle")) return 34;
else if (!strcmp(string, "RPG")) return 35;
else if (!strcmp(string, "Missile Launcher")) return 36;
else if (!strcmp(string, "Flame Thrower")) return 37;
else if (!strcmp(string, "Minigun")) return 38;
else if (!strcmp(string, "Sachel Charges")) return 39;
else if (!strcmp(string, "Detonator")) return 40;
else if (!strcmp(string, "Spray Paint")) return 41;
else if (!strcmp(string, "Fire Extinguisher")) return 42;
else if (!strcmp(string, "Camera")) return 43;
else if (!strcmp(string, "Nightvision Goggles")) return 44;
else if (!strcmp(string, "Thermal Goggles")) return 45;
else if (!strcmp(string, "Parachute")) return 46;
return -1;
}
Код:
k<weapon>