SA-MP Forums Archive
first letters of name - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: first letters of name (/showthread.php?tid=384389)



first letters of name - Yako - 11.10.2012

Hello, I want to ask how to get the first letters of Firstname and Surname?


Re: first letters of name - alanhutch - 11.10.2012

Use this:
Код:
stock GetPlayerFirstName(playerid)
{
	new namestring[2][MAX_PLAYER_NAME];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	split(name, namestring, '_');
	return namestring[0];
}
stock GetPlayerLastName(playerid)
{
	new namestring[2][MAX_PLAYER_NAME];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	split(name, namestring, '_');
	return namestring[1];
}
Rep+?


Re: first letters of name - zSuYaNw - 11.10.2012

Quote:
Originally Posted by alanhutch
Посмотреть сообщение
Use this:
Код:
stock GetPlayerFirstName(playerid)
{
	new namestring[2][MAX_PLAYER_NAME];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	split(name, namestring, '_');
	return namestring[0];
}
stock GetPlayerLastName(playerid)
{
	new namestring[2][MAX_PLAYER_NAME];
	new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid,name,MAX_PLAYER_NAME);
	split(name, namestring, '_');
	return namestring[1];
}
Rep+?
Split is not native function.



PHP код:
stock GetPlayerSurName(pid){
    static
        
Name[24],
        
Position
    
;
    
    
GetPlayerName(pidName24);
    
Position strfind(Name"_"true);
    
    
strdel(Name0Position+1);
    return 
Name;
}
stock GetPlayerFirstName(pid){
    static
        
Name[24],
        
Position
    
;
    
GetPlayerName(pidName24);
    
Position strfind(Name"_"true);
    
strdel(NamePositionstrlen(Name));
    return 
Name;