SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 02/08/2018, 12:53 PM   #4681
[HLF]Southclaw
High-roller
 
[HLF]Southclaw's Avatar
 
Join Date: Apr 2009
Location: England
Posts: 4,987
Reputation: 1558
Default Re: Useful Functions

Quote:
Originally Posted by GRiMMREAPER View Post
pawn Code:
#include <Pawn.Regex>

isValidMail(mail) {
    new Regex:r = Regex_New("([a-z0-9._-]{6,30})(@{1})([a-z]+)([.]{1})([a-z]{2,})"),
        RegexMatch:m;
   
    if(Regex_Match(mail, r, m)) {
        return 1;
    }

    return 0;
   
}

[I]: cmenezes@gmail.com
[O]: true

[I]: cmenezes22@gmail.com
[O]: true

[I]: cmenezes2@1333@hotmail.pt
[O]: false (@ is not allowed in emails)

[I]: cmen@gmail.com
[O]: false (most email service providers need you to register with an handle ranging from 6 to 30 characters long)

[I]: c23ddsadmen@gmail.c
[O]: false (domain must be equal or longer than 2 characters)
https://davidcel.is/posts/stop-valid...es-with-regex/
__________________
Tools:

Plugins:

Links:

[HLF]Southclaw is offline   Reply With Quote
Old 02/08/2018, 12:58 PM   #4682
GRiMMREAPER
Huge Clucker
 
GRiMMREAPER's Avatar
 
Join Date: Jan 2018
Posts: 232
Reputation: 61
Default Re: Useful Functions

Just skimmed through the post and pieced a few bits. Thanks for the link.
GRiMMREAPER is offline   Reply With Quote
Old 19/08/2018, 02:50 PM   #4683
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 281
Reputation: 72
Default Re: Useful Functions

PHP Code:
IsPlayerInRangeOfPointEx(playeridFloat:radiusFloat:heightFloat:xFloat:yFloat:z)
{
    new 
Float:pxFloat:pyFloat:pz;
    if(!
IsPlayerConnected(playerid)) return 0;
    
GetPlayerPos(playeridpxpypz);
    if(
floatabs((px-x) + (py-y)) <= radius && floatabs((pz-z)) <= height) return 1;
    return 
0;

Lokii is offline   Reply With Quote
Old 11/11/2018, 07:09 PM   #4684
Lokii
Huge Clucker
 
Join Date: Sep 2017
Posts: 281
Reputation: 72
Default Re: Useful Functions

PHP Code:
precent(Float:minFloat:max)
{
    return 
_:(floatabs((min/max)*100));

Lokii is offline   Reply With Quote
Old 11/11/2018, 07:31 PM   #4685
kvann
Huge Clucker
 
kvann's Avatar
 
Join Date: Jun 2012
Location: Estonia
Posts: 395
Reputation: 152
Default Re: Useful Functions

Quote:
Originally Posted by Lokii View Post
PHP Code:
precent(Float:minFloat:max)
{
    return 
_:(floatabs((min/max)*100));

  1. The name of the first argument doesn't make any sense in this context and the second one is only a bit better.
  2. Quote:
    Originally Posted by Merriam-Webster dictionary
    Precent definition is - to act as precentor: lead a choir or congregation in singing.
  3. You are multiplying a float by an integer, the runtime has to cast the integer to a float, producing unnecessary overhead.
  4. De-tagging a float doesn't round it, the function will just return a value that's meaningless in this context. I wouldn't even round it since the user might need the extra precision.
  5. Getting the absolute value doesn't make much sense either. If someone uses the function with values with different signs, they probably have a reason.

PHP Code:
Float:percentage(Float:valueFloat:max_value) {
    return (
value max_value) * 100.0;

__________________




kvann is offline   Reply With Quote
Old 18/11/2018, 07:23 AM   #4686
Flofey
Little Clucker
 
Flofey's Avatar
 
Join Date: Oct 2018
Location: South the moon
Posts: 11
Reputation: 3
Default PlayerPlaySoundForAll Function

PlayerPlaySoundForAll function.


PHP Code:
PlayerPlaySoundForAll(soundidFloat:xFloat:yFloat:z)
{
   for(new 
0MAX_PLAYERSi++)
   {
    
PlayerPlaySound(i,soundid,Float:xFloat:yFloat:z);
   }
   return 
1;

__________________
Flofey's Signature:
Discord: Flofey#8478
Flofey 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] [INC] LSF - Lorenc's Simple Functions (w/ gang/clan functions) Lorenc_ Includes 14 21/04/2018 05:06 AM
Functions? sciman001 Help Archive 7 19/03/2011 04:03 PM
How to get functions? Twain32 Help Archive 4 08/10/2010 08:37 PM
[Include] [INC] SA:MP New Functions 0.4a DKN ipsBruno Lançamentos/Releases 22 17/06/2010 09:38 AM
What this functions do? harrold Help Archive 2 09/05/2009 12:30 AM


All times are GMT. The time now is 04:12 AM.


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