Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Post your code snippets here

 
  • 0 Vote(s) - 0 Average
Pawn Post your code snippets here
Tama
Offline

Burgershot Member
Posts: 42
Threads: 8
Joined: Sep 2019
Reputation: 1
Location: India
#19
2021-10-27, 03:59 PM (This post was last modified: 2021-10-27, 04:03 PM by Tama.)
IsValidRoleplayName without regex.

PHP Code:
stock IsValidRoleplayName(const name[], short_name_len = 3) {
    new 
        len = strlen(name),
        underscore_pos = strfind(name, "_", true);

    // The name is empty
    if (isnull(name)) return false;

    // Underscore not found
    if (underscore_pos == -1) return false;
    
    
// Firstname and lastname is not capital
    #define isupper(%0) (%0 != (%0 | 0x20))
    if (!isupper(name[0]) || !isupper(name[underscore_pos + 1])) return false;

    // Firstname is too short
    if (underscore_pos < short_name_len) return false;

    // Lastname is too short
    if (((len - 1) - underscore_pos) < short_name_len) return false;

    // Invalid characters
    for (new i; i != len; i ++) {
        switch (name[i]) {
            case 'A'..'Z', 'a'..'z', '_': continue;
            default: {
                return false;
            }
        }
    }
    return true;
} 

IsValidRoleplayName with regex (PawnPlus)

PHP Code:
stock IsValidRoleplayName(const name[])
{
    new String:tmp = str_format(name);
    return str_match(tmp, "^[A-Z]{1}[a-z]{2,12}_[A-Z]{1}[a-z]{2,12}$");
} 


No Colors/Remove color format
PHP Code:
stock NoColors(str[], startPos = '{', len = 8) {
    for (new i = 0; i <= strlen(str) - len; i ++) {
        if (str[i] == startPos) {
            if (str[i + len - 1] == '}' || IsValidHex(str[i + len - 1])) {
                new 
                    pass;
                
                
for (new j = 1; j < len - 1; j ++) {
                    if (IsValidHex(str[i + j])) {
                        pass ++;
                    }
                }
                if (pass >= len - 2) {
                    strdel(str, i, i + len);
                    pass = 0;
                }
            }
        }
    }
    return 1;
} 
आपको अपने पापों पर पश्चाताप करना चाहिए, वे आपको नष्ट कर देंगे। आप कोई मौका नहीं खड़े हो रहे हैं। तुम उसके हाथ पर मर जाओगे। पछताना


« Next Oldest | Next Newest »



Messages In This Thread
Post your code snippets here - by DTV - 2019-04-14, 11:04 PM
RE: Post your code snippets here - by Gravityfalls - 2019-04-15, 01:46 AM
RE: Post your code snippets here - by iSpark - 2019-04-15, 03:50 AM
RE: Post your code snippets here - by DTV - 2019-04-15, 07:07 AM
RE: Post your code snippets here - by BlackBank - 2019-04-15, 05:17 PM
RE: Post your code snippets here - by Codeah - 2019-04-15, 06:55 PM
RE: Post your code snippets here - by Riddick - 2019-04-16, 06:24 AM
RE: Post your code snippets here - by Y_Less - 2019-04-16, 11:23 AM
RE: Post your code snippets here - by DTV - 2019-04-16, 06:10 PM
RE: Post your code snippets here - by Grate Maharlika - 2020-10-19, 03:22 PM
RE: Post your code snippets here - by KJason - 2019-04-16, 11:48 AM
RE: Post your code snippets here - by kristo - 2019-04-16, 12:50 PM
RE: Post your code snippets here - by Mike - 2019-04-17, 02:45 AM
RE: Post your code snippets here - by DTV - 2019-04-29, 07:24 PM
RE: Post your code snippets here - by DTV - 2020-01-03, 06:33 PM
RE: Post your code snippets here - by Awide - 2020-10-18, 07:33 PM
RE: Post your code snippets here - by Expert* - 2020-10-24, 12:40 PM
RE: Post your code snippets here - by Virsenas - 2021-02-26, 11:53 PM
RE: Post your code snippets here - by Tama - 2021-10-27, 03:59 PM

  • 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