SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 24/01/2013, 06:48 AM   #1
CoDeZ
Huge Clucker
 
Join Date: Apr 2012
Location: Egypt
Posts: 236
Reputation: 12
Default [HELP]sscanf with specifiers

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?
CoDeZ is offline   Reply With Quote
Old 24/01/2013, 09:50 AM   #2
Threshold
High-roller
 
Threshold's Avatar
 
Join Date: Nov 2012
Location: Australia
Posts: 3,122
Reputation: 529
Default Re: [HELP]sscanf with specifiers

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 -____-*
__________________


Kar's Cops and Robbers 2020
Threshold is offline   Reply With Quote
Old 24/01/2013, 11:33 AM   #3
CoDeZ
Huge Clucker
 
Join Date: Apr 2012
Location: Egypt
Posts: 236
Reputation: 12
Default Re: [HELP]sscanf with specifiers

Thanks, i can do that.
CoDeZ is offline   Reply With Quote
Old 24/01/2013, 06:06 PM   #4
CoDeZ
Huge Clucker
 
Join Date: Apr 2012
Location: Egypt
Posts: 236
Reputation: 12
Default Re: [HELP]sscanf with specifiers

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?
CoDeZ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] FingerPrint - new sscanf2 custom specifiers Babul Includes 7 29/01/2013 05:11 AM
[Ajuda] sscanf sem usar sscanf EduardoRFS Português/Portuguese 4 10/08/2012 02:11 AM
help !! sscanf - sscanf error: System not initialised. zod23 Scripting Help 1 03/08/2012 08:54 AM
sscanf - sscanf error: System not initialised. Deal-or-die Scripting Help 4 26/06/2012 02:44 PM
[HELP] With sscanf V4at Scripting Help 2 24/06/2012 09:40 PM


All times are GMT. The time now is 04:56 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.