Get old PlayerName after changed by SetPlayerName ?? -
Bearfist - 24.04.2009
Hey Guys...
I Added a command which sets the name on %s[GRoVe],
but how to get my old name ?
To Change It To %s[Ballas] if he spawns as one ^^
MFG Bearfist
Re: Get old PlayerName after changed by SetPlayerName ?? -
Weirdosport - 24.04.2009
Is the name:
Weirdosport[Grove]
pawn Code:
GetPlayerName(playerid, Name, sizeof(Name));
strdel(string, strlen(string)-7, strlen(string));
SetPlayerName(playerid, Name);
_________________________________________________
[Grove]Weirdosport?
pawn Code:
GetPlayerName(playerid, Name, sizeof(Name));
strdel(Name, 0, 7);
SetPlayerName(playerid, Name);
The second is easier, but the first isn't impossible.
Of course for different gang tags you'd have to change the number 7.
[Grove]
1234567
To suit the gang-tag length.
Re: Get old PlayerName after changed by SetPlayerName ?? -
Bearfist - 24.04.2009
Thanks...
but what to do if the name (strleng i think) is unknown and variable
U answered it xDDD
Thank Much =)
MFG Bearfist
Re: Get old PlayerName after changed by SetPlayerName ?? -
*BueNoOo* - 24.04.2009
Damn I don't understand you Wierdo

and I have the same problem, get an old name after changing it to whatever...
Re: Get old PlayerName after changed by SetPlayerName ?? -
Weirdosport - 24.04.2009
strlen in a function, it works out the length of the name the player entered.
EDIT: This script only works with tag lengths that are set in stone, if you had players with varying tag lengths it wouldn't work.
Re: Get old PlayerName after changed by SetPlayerName ?? -
*BueNoOo* - 24.04.2009
yeah cos' I lost some of letters of my previous name

( can u give me the code to make for example /lv it will make a tag [LV]my_name and then when I type /ls it will just remove that [LV] tag ??

sorry i am noob but i really want to learn it

thanks
Re: Get old PlayerName after changed by SetPlayerName ?? -
Weirdosport - 24.04.2009
It seemed to work on my quick test but i'll try it again when I get home later, might be a long wait..
PM me or something to remind me!
Re: Get old PlayerName after changed by SetPlayerName ?? -
Bearfist - 24.04.2009
Strdel doesn't work o.O =(
I tried both Variations but none worked ...
Re: Get old PlayerName after changed by SetPlayerName ?? -
Weirdosport - 24.04.2009
It works for me...
pawn Code:
#include <a_samp>
public OnFilterScriptInit()
{
new string[20] = "Weirdosport[LS]";
print("\n");
printf("Before: %s", string);
strdel(string, strlen(string)-4, strlen(string));
printf("After: %s",string);
print("\n");
string = "[LS]Weirdosport";
printf("Before: %s", string);
strdel(string, 0, 4);
printf("After: %s",string);
print("\n");
return 1;
}
Compile + load that, it works.
_________________________________________________
Made some stocks to use:
pawn Code:
stock RemoveClanTagFromFront(playerid,taglen)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
strdel(string, 0, taglen);
SetPlayerName(playerid, string);
return 1;
}
stock RemoveClanTagFromEnd(playerid,taglen)
{
new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
strdel(string, strlen(string)-taglen, strlen(string));
SetPlayerName(playerid, string);
return 1;
}
"taglen" is counted as:
Re: Get old PlayerName after changed by SetPlayerName ?? -
Joe Staff - 24.04.2009
pawn Code:
RemoveGangTag(name[])
{
new first,last;
for(new i; i<strlen(name);i++)
{
if(strfind(name,"[",true,i)>-1)first = strfind(name,"[",true,i);
else continue;
}
last = strfind(name,"]",true,first);
printf("%d,%d",first,last);
if(first>-1)
{
if(last>first)
{
strdel(name,first,last+1);
}
}
if(strfind(name,"[",true)>-1)RemoveGangTag(name);
}
Use
pawn Code:
OnPlayerConnect(playerid,ip[])
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
RemoveGangTag(name);
SetPlayerName(playerid,name);
}
=)
EDIT* Fixed it a couple times through lol