Sorry For To Much Help! -
[Lsgw]LoL - 18.05.2011
hello there i know that i say help to much but i realy want to do this for done every thing hard by you guys now what i need acommands name:
/setname [playername] [newname]
Like this but what i need other when i rename in game for example: /setname Hello Ghost
now i need it to change name inside server files inside scriptfiles ! and change in game what i mean in last change both at 1 time ingame and in scriptfiles please help! me !
![Cheesy](images/smilies/biggrin.png)
! and sorry again for much help!
Re: Sorry For To Much Help! -
Marco_Valentine - 18.05.2011
this might work
if(strcmp(cmd, "/setname", true) == 0)
{
giveplayerid = ReturnUser(tmp);
GetPlayerName(playerid, sendername, sizeof(sendername));
new tmpp[256];
tmpp = strtok(cmdtext, idx);
if(!strlen(tmpp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid] [Name]");
return 1;
}
giveplayerid = strval(tmpp);
tmp = strtok(cmdtext, idx);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
SetPlayerName(giveplayerid, tmp);
return 1;
}
Re: Sorry For To Much Help! -
[Lsgw]LoL - 18.05.2011
i know this but what i need is
/setname [oldname] [newname]
i want oldname and newname i dont want [playerid] [name]
Re: Sorry For To Much Help! -
Marco_Valentine - 18.05.2011
I don't understand what you want it to do...... what will that command achieve? and what is it supposed to do?
Re: Sorry For To Much Help! -
misho1 - 18.05.2011
he mean
he want cmd that /setname [player's old name] [player's new name]
Re: Sorry For To Much Help! -
iggy1 - 18.05.2011
I just wrote this not tested it but should work. Requires sscanf plugin and zcmd.
pawn Код:
COMMAND:setname(playerid, params[])
{
new
oldname[MAX_PLAYER_NAME], newname[MAX_PLAYER_NAME];
if(sscanf(params, "s[24]s[24]", oldname, newname))
{
SendClientMessage(playerid, -1, "ERROR: Usage /setname [oldname][newname]");
return 1;
}
else
{
new
pCount,
p_zName[MAX_PLAYER_NAME];
for(new i; i != MAX_PLAYERS; i++)//would be better using foreach
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, p_zName, MAX_PLAYER_NAME);
if(!strcmp(oldname, p_zName))//read about strcmp on the wiki you could make it only require a partial string to match or change the case sensitivity on the comparisons.
{
SetPlayerName(i, newname);
count++;
break;
}
}
}
if(!pCount)
SendClientMessage(playerid, -1, "ERROR: Player Not Found!");
}
return 1;
}
EDIT: I messed the loop up, i fixed it now silly mistake sorry.
Re: Sorry For To Much Help! -
[Lsgw]LoL - 18.05.2011
its not work shit
when i do /setname Killer Ghost
its stay say to me
ERROR: Usage /setname [oldname][newname]
Re: Sorry For To Much Help! -
iggy1 - 18.05.2011
I messed up a bit sorry try this, i've tested and it works.
pawn Код:
COMMAND:setname(playerid, params[])
{
new
oldname[MAX_PLAYER_NAME], newname[MAX_PLAYER_NAME];
if(sscanf(params, "s[24]s[24]", oldname, newname))
{
SendClientMessage(playerid, -1, "ERROR: Usage /setname [oldname][newname]");
return 1;
}
else
{
new
pCount,
p_zName[MAX_PLAYER_NAME];
for(new i; i != MAX_PLAYERS; i++)//would be better using foreach
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, p_zName, MAX_PLAYER_NAME);
if(!strcmp(oldname, p_zName, true, 4))//case insensitive and only the first four letters of the name are compared.
{
SetPlayerName(i, newname);
pCount++;
break;
}
}
}
if(!pCount)
SendClientMessage(playerid, -1, "ERROR: Player Not Found!");
}
return 1;
}