how to change name without tag -
rockys - 23.02.2019
i want some like this:
connectname = rocky[KING]
[KING] is clan tag
onplayerconnect i want to change name to rocky
like
SetPlayerName(playername-tag);
i use strfind to find clan tag, how can i remove clan tag from player name?
Re: how to change name without tag -
NaS - 23.02.2019
Is it about specific tags only (like only [KING] is going to be removed), or all clan tags?
You can use strfind (it returns the index where it was found, eg. 0 if it's at the start, or in your example 5, -1 if it wasn't found).
Then you know where the tag begins in the name, from there you can use strdel to remove it:
Код:
new idx = strfind(name, "[KING]", true);
if(idx != -1)
{
strdel(name, idx, idx + 6); // Deletes characters from (idx) to (idx+6), since 6 is the length of the tag
SetPlayerName(playerid, name);
}
Re: how to change name without tag -
rockys - 23.02.2019
not work
Код:
new name[30];
GetPlayerName(playerid, name, sizeof name);
for(new clanid; clanid < clanss; clanid++)
{
new idx = strfind(name, ClanInfo[clanid][cClanTag], true),
ctr = strlen(ClanInfo[clanid][cClanTag]);
if(idx != -1)
{
strdel(name, idx, idx + ctr);
SetPlayerName(playerid, name);
break;
}
}
not work
Re: how to change name without tag -
NaS - 24.02.2019
Код:
new search[] = "[tag]", name[] = "dog[tag]test",
idx = strfind(name, search, true);
if(idx != -1)
{
print("Found Tag");
strdel(name, idx, idx + strlen(search));
printf("New name: \"%s\"", name);
}
This works, the result is "dogtest".
Your code is (except the source of the strings) the same, so the error is either in the ClanInfo array or SetPlayerName.
Print out the result to see what's happening.
If there are uninitialized/invalid clans make sure they are skipped, otherwise it will delete 0 characters as an empty string is 0 characters long and break the loop.
Also make sure the playername remains at least 3 characters as that is the minimum name length.
Re: how to change name without tag -
rockys - 26.02.2019
not work..
Re: how to change name without tag -
RoboN1X - 27.02.2019
Quote:
Originally Posted by rockys
onplayerconnect i want to change name to rocky
like
SetPlayerName(playername-tag);
|
Don't use SetPlayerName OnPlayerConnect, the name will not update for the connecting player (other players will see it changed).
Read notes in
https://sampwiki.blast.hk/wiki/SetPlayerName
Re: how to change name without tag -
TheToretto - 27.02.2019
Use it under OnPlayerSpawn