[Pawn] Find the number into a text - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Find the number into a text (/showthread.php?tid=2496) |
Find the number into a text - BotLevel.Bobu - 2023-11-29 Hi ! I need your help. I want to find the number in a random text. For example: Code: #include <open.mp> RE: Find the number into a text - denNorske - 2023-12-05 The best approach is to use a plugin for adding regex functionality to your script. Regex is good at pattern matching, and it is a breeze to find numbers with it. I have taken in consideration that you might not use regex or that you are not familiar with it, considering you asked this question. The approach to find a number in a string can be a bit convoluted. The approach I would do is as follows: 1. Assign the string to a variable, and loop through it. 2. Every time you find a space, check the part of the string that has been looped over (the current word) 3. Check if it is a number. If it is, voila! Here is an example; PHP Code: stock bool:IsNumber(const string[]) RE: Find the number into a text - BotLevel.Bobu - 2023-12-09 denNorske - the code works perfect ! Thank you ! |