Closed Jameskmonger closed 11 years ago
Did you create a sscanf "kustom specifier" for weapons?
There's already one in the sscanf2.inc file in the main "include" folder
Perhaps the sscanf plugin is outdated. I can't test that at the moment, could you?
What do you mean by test it? If you mean download the "latest" plugin, add it to my server and try it then, then yeah sure :)
Yeah, do that please.
I've updated both the plugin and the include and I still get this printed into the chatlog and the command does not work:
[12:08:46] sscanf warning: Unenclosed specifier parameters are deprecated, consider using something like p<k>.
[12:08:46] sscanf warning: Unknown format specifier '<', skipping.
[12:08:46] sscanf warning: Unknown format specifier 'w', skipping.
[12:08:46] sscanf error: No specified parameters found.
Here is my whole command:
CommandDescription<spawnweapon> = @"Spawn a weapon for the specified player.";
YCMD(GROUP_ADMIN, GROUP_MANAGEMENT, GROUP_RCON):spawnweapon(playerid, params[], help) {
if(help) {
SendClientMessage(playerid, COLOR_COMMAND_HELP, @"Spawn a weapon for a specified player");
} else {
new target, weapon, ammo;
if(sscanf(params, "pk<weapon>i(-1)", target, weapon, ammo)) {
SendClientMessage(playerid, COLOR_COMMAND_USAGE, @"* Usage: /spawnweapon [player] [weapon] [OPTIONAL: ammo-amount]");
} else {
if(playerid == INVALID_PLAYER_ID) {
SendClientMessage(playerid, COLOR_COMMAND_ERROR, @"Invalid player ID");
return 1;
}
if(weapon != -1) {
if(ammo == -1) {
GivePlayerWeapon(target, weapon, 99999);
SendClientMessage(playerid, 0xFF87E9FF, @"You have given %p %w with unlimited ammo.", target, weapon);
SendClientMessage(target, 0xFF87E9FF, @"%p has given you %w with unlimited ammo.", playerid, weapon);
} else {
GivePlayerWeapon(target, weapon, ammo);
SendClientMessage(playerid, 0xFF87E9FF, @"You have given %p %w with %d round of ammo.", target, weapon, ammo);
SendClientMessage(target, 0xFF87E9FF, @"%p has given you %w with %d rounds of ammo.", playerid, weapon, ammo);
}
} else {
SendClientMessage(playerid, COLOR_COMMAND_ERROR, @"You entered an invalid weapon.");
}
}
}
return 1;
}
When I type /spawnweapon 0 24 1, I get the above error and I also get the "* Usage: /spawnweapon..." message sent to my client.
I see what's wrong now. You should be using u
for player - p
is to specify delimiters.
Thanks, it works a lot better now. However, I get the "Usage:" line if I leave the "ammo" field blank, whereas it should work with or without the specification of ammo.
Ask in the sscanf forum topic.
To anyone experiencing this same problem, capitalise the optional parameter! In the example above, I would need to use
"rk<weapon>I(-1)"
rather than
"rk<weapon>i(-1)"
I was writing a spawn weapon command I get an error on the sscanf line.
The command does not work (I get the Usage: message, which occurs if the player does not use the command correctly, and this is determined by the line above).
In the console, I get this printed: