19.05.2012, 13:03
Код:
RPName(name[],ret_first[],ret_last[]) { new len = strlen(name), point = -1, bool:done = false; for(new i = 0; i < len; i++) { if(name[i] == '_') { if(point != -1) return 0; else { if(i == 0) return 0; point = i + 1; } } else if(point == -1) ret_first[i] = name[i]; else { ret_last[i - point] = name[i]; done = true; } } if(!done) return 0; return 1; }
Код:
public OnPlayerConnect(playerid) { new name[MAX_PLAYER_NAME], first[MAX_PLAYER_NAME], last[MAX_PLAYER_NAME], ret; GetPlayerName(playerid,name,sizeof(name)); if(RPName(name,first,last)) { // Valid name, player is called first_last } else { // Invalid name, deal accordingly } return 1; }