Quote:
Originally Posted by Seif_
Quote:
Originally Posted by Norn
First you need:
pawn Код:
forward split(const strsrc[], strdest[][], delimiter); public split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)){ if(strsrc[i]==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; }
GetPlayerRpName(playerid); Will remove the "_" and make it a space, for roleplay. Will only work with Firstname_Lastname format.
pawn Код:
stock GetPlayerRpName(playerid) { new namestring[2][MAX_PLAYER_NAME]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,MAX_PLAYER_NAME); split(name, namestring, '_'); new wstring[25]; format(wstring, sizeof(wstring), "%s %s", namestring[0],namestring[1]); return wstring; }
Example:
pawn Код:
if(strcmp(cmd, "/test", true) == 0) { new pName[MAX_PLAYER_NAME]; new wstring[128]; pName=GetPlayerFirstName(playerid); format(wstring, sizeof(wstring), "Hello %s!", GetPlayerRpName(playerid)); SendClientMessage(playerid,COLOR_WHITE, wstring); return 1; }
|
Why do that if you can just use a loop in a string to get the _ and replace it by a space like this:
http://forum.sa-mp.com/index.php?top...7932#msg457932
|
Didn't find this when i searched, thanks.