04.07.2016, 03:31
pawn Code:
// ** INCLUDES
#include <a_samp>
// ** DEFINES
// *** ROLEPLAY NAME TYPES
#define ROLEPLAY_NAME_FALSE 0
#define ROLEPLAY_NAME_TRUE 1
#define ROLEPLAY_NAME_UNCAPPED 2
#define ROLEPLAY_NAME_CONTAINS_NUMBERS 3
// ** MAIN
main()
{
print("Loaded \"rp_name_detector.amx\".");
switch(IsRoleplayName("Test_Test"))
{
case ROLEPLAY_NAME_FALSE:
{
print("Name is not a roleplay name.");
}
case ROLEPLAY_NAME_TRUE:
{
print("Name is a roleplay name.");
}
case ROLEPLAY_NAME_UNCAPPED:
{
print("Name is uncapped.");
}
case ROLEPLAY_NAME_CONTAINS_NUMBERS:
{
print("Name can\'t contain numbers.");
}
}
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// ** FUNCTIONS
stock IsRoleplayName(player_name[])
{
for(new i = 0, j = strlen(player_name); i < j; i ++)
{
switch(player_name[i])
{
case \'0\'..\'9\':
{
return ROLEPLAY_NAME_CONTAINS_NUMBERS;
}
}
}
if(65 <= player_name[0] <= 90)
{
new underscore_1 = strfind(player_name, "_");
if(underscore_1 >= 3)
{
if(65 <= player_name[underscore_1 + 1] <= 90)
{
if(strfind(player_name, "_", false, (underscore_1 + 1)) == -1)
{
if(((strlen(player_name) - underscore_1) - 1) >= 3)
{
return ROLEPLAY_NAME_TRUE;
}
}
}
else
{
if(((strlen(player_name) - underscore_1) - 1) <= 2)
{
return ROLEPLAY_NAME_FALSE;
}
else
{
return ROLEPLAY_NAME_UNCAPPED;
}
}
}
}
else
{
if(strfind(player_name, "_") <= 3)
{
return ROLEPLAY_NAME_FALSE;
}
else
{
return ROLEPLAY_NAME_UNCAPPED;
}
}
return ROLEPLAY_NAME_FALSE;
}