Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Plugin] Sscanf problem

 
  • 0 Vote(s) - 0 Average
Plugin Sscanf problem
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#1
2020-08-27, 07:50 PM (This post was last modified: 2020-08-27, 07:51 PM by Pinch.)
Code:
if(sscanf(inputtext, "{s[32]'@'s[32]'.'s[16]}"))


Always positive, even if I enter something like [email protected]

I'm using sscanf 2.10.2
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
Tama
Offline

Burgershot Member
Posts: 42
Threads: 8
Joined: Sep 2019
Reputation: 1
Location: India
#2
2020-08-27, 09:10 PM
I think it's nearly impossible using only sscanf, you should replace '@' and '.' to space and check it like this:

PHP Code:
if (sscanf(inputtext, "{sss}")) 

Or you can just see my code below:
https://gist.github.com/se8870/ca137f685298c06fea7d7abb861f2202
आपको अपने पापों पर पश्चाताप करना चाहिए, वे आपको नष्ट कर देंगे। आप कोई मौका नहीं खड़े हो रहे हैं। तुम उसके हाथ पर मर जाओगे। पछताना


Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#3
2020-08-27, 09:41 PM
(2020-08-27, 09:10 PM)Tama Wrote: I think it's nearly impossible using only sscanf, you should replace '@' and '.' to space and check it like this:

PHP Code:
if (sscanf(inputtext, "{sss}")) 

Or you can just see my code below:
https://gist.github.com/se8870/ca137f685298c06fea7d7abb861f2202
Nope, you cannot use s without length.
I already fixed this but this is an sscanf bug I think

idk why is search ' ' broken smh
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
Tama
Offline

Burgershot Member
Posts: 42
Threads: 8
Joined: Sep 2019
Reputation: 1
Location: India
#4
2020-08-28, 07:49 AM (This post was last modified: 2020-08-28, 07:50 AM by Tama.)
(2020-08-27, 09:41 PM)Pinch Wrote: Nope, you cannot use s without length.

Still work but you're get an error.
That code it's just example for older version.
आपको अपने पापों पर पश्चाताप करना चाहिए, वे आपको नष्ट कर देंगे। आप कोई मौका नहीं खड़े हो रहे हैं। तुम उसके हाथ पर मर जाओगे। पछताना


Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#5
2020-08-28, 09:20 AM
I'm using sscanf 2.10.2 which turns warnings into errors...
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#6
2020-09-23, 11:50 AM
Search works fine, but you don't want search. `s` can contain `@`, so if you type `[email protected]` sscanf will do the following:

`s[32]` - Gathers everything until the first separator (whitespace by default), so `[email protected]`.
`'@'` - Looks for another `@`, but there isn't one, so the check fails.

You are missing up searches and delimiters. sscanf doesn't have look-ahead/look-behind, so while it is reading a string it doesn't know that the NEXT instruction is to look for an `@`. You've not told sscanf to stop reading strings at `@`, so it doesn't. You want:

"p<@>s[32]s[32] "

(you also don't want to check for a `.`, as valid e-mail addresses don't have to have one. Really all you want is `strfind(input, "@") != -1` - that's the simplest way to look for a valid e-mail address. Of course the only truly correct way is to send an e-mail it it.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode