[HELP]sscanf with specifiers
#1

Hello, i have a question, let's say i have the following line :

pawn Code:
if(sscanf(params,"us[10]",targetid,weapon))
How can i allow "weapon" to be entered as string or as an integer not only as a string or only as an integer?
Reply
#2

Check if the string is numerical, if it is, then use strval to get a number from the string, if it is too high, invalid or too low to be a weapon, return an error. You just need the IsNumeric function, and then swap it to strval if it is numeric, or leave it as it is, if it's a string.

*JUST REALISED I HAD LEFT THIS WITHOUT PRESSING 'SUBMIT' FOR MORE THAN 2 HOURS -____-*
Reply
#3

Thanks, i can do that.
Reply
#4

Quote:
Originally Posted by ******
View Post
Or use the "k<weapon>" specifier.
Ehm, how to use it, i looked before opening this thread, but found only k<playerstate> specifier,how to use the weapon one?
and how to forbid some weapon id?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)