Name Change with admin approval
#1

Hey!

So basically I wanna make a /namechange system where admin has to approve it. Now Im wondering what to do next after I made such command.

Quote:

CMD:changename(playerid, params[]) //not working
{
new name[256], string[256];
if(sscanf(params, "s[256]", name)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename (Name)");
RequestedName[playerid] = name;
RequestedNameID[playerid] = 1;
SendClientMessage(playerid, -1, "[NAME CHANGE] Admin will review your request. Please note that request might get denied.");
for (new i = 0; i != MAX_PLAYERS; ++i)
{
if(pInfo[i][pAdmin] >= 1)
{
format(string,sizeof(string), "{33CCFF}[NAME CHANGE] %s {FFFFFF}is requesting a name change to {33CCFF}%s. (/accept | /deny)", pInfo[playerid][pName], name);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}

I tried to make it under OnPlayerCommandText and then /accept or /deny but I couldnt get it to work, help appreciated.
Reply
#2

pawn Код:
CMD:changename(playerid, params[])
{
    new name[MAX_PLAYER_NAME+1], string[100];
    if(sscanf(params, "s", name)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename (Name)");
    RequestedName[playerid] = name;
    RequestedNameID[playerid] = 1;
    SendClientMessage(playerid, -1, "[NAME CHANGE] Admin will review your request. Please note that request might get denied.");
   
    for (new i = 0; i != MAX_PLAYERS; ++i)
    {
        if(pInfo[i][pAdmin] >= 1)
        {
            format(string,sizeof(string), "{33CCFF}[NAME CHANGE] %s {FFFFFF}is requesting a name change to {33CCFF}%s. (/accept | /deny)", pInfo[playerid][pName], name);
            SendClientMessage(playerid, -1, string);
        }
    }
    return 1;
}
CMD:accept(playerid, params[])
{
    new targetid;
    if(!pInfo[i][pAdmin]) return SendClientMessage(playerid, -1, "you're not an admin.");
   
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /accept (targetid)");
   
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player Isn't connected.");
   
    if(RequestedNameID[targetid] == 0) return SendClientMessage(playerid, -1, "invalid player specified");
   
    SetPlayerName(targetid, RequestedName[playerid]);
    SendClientMessage(targetid, -1, "Your namechange request was accepted.");
    RequestedName[playerid] = "None";
    RequestedNameID[playerid] = 0;
    return 1;
}

CMD:deny(playerid, params[])
{
    new targetid;
    if(!pInfo[i][pAdmin]) return SendClientMessage(playerid, -1, "you're not an admin.");

    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /deny (targetid)");

    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player Isn't connected.");

    if(RequestedNameID[targetid] == 0) return SendClientMessage(playerid, -1, "invalid player specified");

    SendClientMessage(targetid, -1, "Your namechange request was denied.");
    RequestedName[playerid] = "None";
    RequestedNameID[playerid] = 0;

    return 1;
}
try this.
Reply
#3

try this
Код:
new targetid;
CMD:changename(playerid, params[])
{
	new name[MAX_PLAYER_NAME+1], string[100];
	if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename (Name)");
	RequestedName[playerid] = name;
	RequestedNameID[playerid] = 1;
	targetid = playerid;
	SendClientMessage(playerid, -1, "[NAME CHANGE] Admin will review your request. Please note that request might get denied.");
	
	for (new i = 0; i != MAX_PLAYERS; ++i)
	{
		if(pInfo[i][pAdmin] >= 1)
		{
			format(string,sizeof(string), "{33CCFF}[NAME CHANGE] %s {FFFFFF}is requesting a name change to {33CCFF}%s. (/accept | /deny)", pInfo[playerid][pName], name);
			SendClientMessage(playerid, -1, string);
		}
	}
	return 1;
}
CMD:accept(playerid, params[])
{
	if(!pInfo[playerid][pAdmin]) return SendClientMessage(playerid, -1, "you're not an admin.");
	
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /accept (targetid)");
	
	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player Isn't connected.");
	
	if(RequestedNameID[targetid] == 0) return SendClientMessage(playerid, -1, "invalid player specified");
	
	SetPlayerName(targetid, RequestedName[targetid]);
	SendClientMessage(targetid, -1, "Your namechange request was accepted.");
	RequestedName[targetid] = "None";
	RequestedNameID[targetid] = 0;
	return 1;
}

CMD:deny(playerid, params[])
{
	if(!pInfo[playerid][pAdmin]) return SendClientMessage(playerid, -1, "you're not an admin.");

	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /deny (targetid)");

	if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "Player Isn't connected.");

	if(RequestedNameID[targetid] == 0) return SendClientMessage(playerid, -1, "invalid player specified");

	SendClientMessage(targetid, -1, "Your namechange request was denied.");
	RequestedName[targetid] = "None";
	RequestedNameID[targetid] = 0;

	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)