Get player name > temp store
#1

Hi guys, I'm currently trying to develop an admin duty command.

Here's what I got:

Код:
	new TempOldName[MAX_PLAYER_NAME];
	if(strcmp(cmd,"/aduty",true) == 0)
	{
	if(PlayerInfo[playerid][pAdmin] < 1)
			{
				SendClientMessage(playerid, COLOR_GREY, "[System] You are not authorized to use that command !");
				return 1;
			}
	if(AdminDutyStatus[playerid] == 0)
	{
	SendClientMessage(playerid,COLOR_YELLOW,"You are now on Admin Duty!");
	AdminDutyStatus[playerid] = 1;
	new name[MAX_PLAYER_NAME];
	TempOldName[playerid] = GetPlayerName(playerid, name, sizeof(name));
	SetPlayerName(playerid, GetPlayerFirstName(playerid));
	//string
	return 1;
	}
	else if(AdminDutyStatus[playerid] == 1)
	{
	SendClientMessage(playerid,COLOR_YELLOW,"You have gone off Admin Duty!");
	AdminDutyStatus[playerid] = 0;
	SetPlayerName(playerid, PlayerInfo[playerid][TempOldName[playerid]]);
	return 1;
	}
	return 1;
	}
Everything works except when it gets the players name and stores it, then it sets it back, it sets it as something random like iIfjq1n.
Reply
#2

Your code is weird, I'M really confused... why did you GetPlayerName inside a variable? then SetPlayerName? woah, can't you simply use name return?
pawn Код:
stock GetPlayerNameEx(playerid) {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
Reply
#3

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Your code is weird, I'M really confused... why did you GetPlayerName inside a variable? then SetPlayerName? woah, can't you simply use name return?
pawn Код:
stock GetPlayerNameEx(playerid) {
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
But then it still doesn't set it back to that name after storing it into TempOldName.
Reply
#4

change
pawn Код:
TempOldName[playerid] = GetPlayerName(playerid, name, sizeof(name));
to
pawn Код:
GetPlayerName(playerid, TempOldName[playerid], MAX_PLAYER_NAME);
Reply
#5

Why do you need to store it into a variable? sorry for being pain in the ass, but this is dumb.
What is the point of storing an name? I really don't get it.
Reply
#6

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Why do you need to store it into a variable? sorry for being pain in the ass, but this is dumb.
What is the point of storing an name? I really don't get it.
When an Admin logs in, his auto-off duty. Therefore he has to have an RP name, so when he does /aduty he goes on duty, giving him only a one worded name, so people know his doing administration duties, when he goes off, it needs to go back to his original name, but instead of changing his name, i just want it temporally stored.
Reply
#7

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
Why do you need to store it into a variable? sorry for being pain in the ass, but this is dumb.
What is the point of storing an name? I really don't get it.
If you look at his code (as hard as it is to read) hes wants it so he can set their name to just the firstname when going onduty, then when off duty he wants the name changed back the the original.
Reply
#8

Quote:
Originally Posted by PrawkC
Посмотреть сообщение
If you look at his code (as hard as it is to read) hes wants it so he can set their name to just the firstname when going onduty, then when off duty he wants the name changed back the the original.
Yes, exactly.
Reply
#9

My bad for not reading it completely, here you go and It works, I have tested it.
pawn Код:
if(strcmp(cmd, "/aduty", true) == 0) {
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "[System] You are not authorized to use that command !");
    new name[MAX_PLAYER_NAME];
    if(AdminDutyStatus[playerid] == 0) {
        SendClientMessage(playerid,COLOR_YELLOW,"You are now on Admin Duty!");
        AdminDutyStatus[playerid] = 1;
        GetPlayerName(playerid, name, sizeof(name));
        SetPlayerName(playerid, GetPlayerFirstName(playerid));
        return 1;
    } else if(AdminDutyStatus[playerid] == 1) {
        SendClientMessage(playerid,COLOR_YELLOW,"You have gone off Admin Duty!");
        AdminDutyStatus[playerid] = 0;
        SetPlayerName(playerid, name);
        return 1;
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by EliranPesahov
Посмотреть сообщение
My bad for not reading it completely, here you go and It works, I have tested it.
pawn Код:
if(strcmp(cmd, "/aduty", true) == 0) {
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "[System] You are not authorized to use that command !");
    new name[MAX_PLAYER_NAME];
    if(AdminDutyStatus[playerid] == 0) {
        SendClientMessage(playerid,COLOR_YELLOW,"You are now on Admin Duty!");
        AdminDutyStatus[playerid] = 1;
        GetPlayerName(playerid, name, sizeof(name));
        SetPlayerName(playerid, GetPlayerFirstName(playerid));
        return 1;
    } else if(AdminDutyStatus[playerid] == 1) {
        SendClientMessage(playerid,COLOR_YELLOW,"You have gone off Admin Duty!");
        AdminDutyStatus[playerid] = 0;
        SetPlayerName(playerid, name);
        return 1;
    }
    return 1;
}
Nice try but you gave me what I already had, only thing that didn't work for me was it didn't set the Admins name back to what it was before they did /aduty - which your script doesn't either.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)