/changename
#1

How can i make a changename Command, and that it work only for Admins? I script with sscanf and zcmd, for help.
Reply
#2

Here you go, just put the save variables that you have there
PHP код:
CMD:changename(playeridparams[])
{
    new 
name[MAX_PLAYER_NAME],
        
id,
        
pname[MAX_PLAYER_NAME],
        
string[128],
        
nick[20];
    if(
PlayerInfo[playerid][Admin] > 5)
    {
        if(
sscanf(params"us[20]"idnick)) return SendClientMessage(playeridCOLOR_RED"SYNTAX: /changename <playername/id> <nickname>");
        if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Invalid-Playerid!");
        if(
IsPlayerNPC(id)) return SendClientMessage(playeridCOLOR_RED"You cannot change NPC Bot's name!");
        
GetPlayerName(idnamesizeof(name));
        
GetPlayerName(playeridpnamesizeof(pname));
        
SetPlayerName(idnick);
        
format(stringsizeof(string), "Administrator %s(ID:%d) has set %s(ID:%d)'s name to %s"pnameplayeridnameidnick);
        
SendClientMessageToAll(COLOR_REDstring);
        
format(stringsizeof(string), "You set %s(ID:%d)'s name to %s"nameidnick);
        
SendClientMessage(playeridCOLOR_GREENstring);
        
format(stringsizeof(string), "Administrator %s(ID:%d) has set your name to %s"pnameplayeridnick);
        
SendClientMessage(idCOLOR_REDstring);
        
format(stringsizeof(string), "ADMIN-SPEC: %s has used /changename"pname);
        
SentMessageToAdmins(COLOR_GREYstring);
    }
    else return 
SendClientMessage(playeridCOLOR_RED"You must be Administrator Level 5 or higher to use this command!");
    return 
1;

Reply
#3

PHP код:
CMD:changename(playerid,params[])
{
    new 
ID,newname[24];
    if(
sscanf(params"us[24]"ID,newname)) return SendClientMessage(playerid, -1"/changename [id] [name]");
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid, -1"[ERROR] Player is off.");
    
SetPlayerName(ID,newname);
    return 
1;

Reply
#4

Quote:
Originally Posted by Squirrel
Посмотреть сообщение
Here you go, just put the save variables that you have there
PHP код:
CMD:changename(playeridparams[])
{
    new 
name[MAX_PLAYER_NAME],
        
id,
        
pname[MAX_PLAYER_NAME],
        
string[128],
        
nick[20];
    if(
PlayerInfo[playerid][Admin] > 5)
    {
        if(
sscanf(params"us[20]"idnick)) return SendClientMessage(playeridCOLOR_RED"SYNTAX: /changename <playername/id> <nickname>");
        if(
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Invalid-Playerid!");
        if(
IsPlayerNPC(id)) return SendClientMessage(playeridCOLOR_RED"You cannot change NPC Bot's name!");
        
GetPlayerName(idnamesizeof(name));
        
GetPlayerName(playeridpnamesizeof(pname));
        
SetPlayerName(idnick);
        
format(stringsizeof(string), "Administrator %s(ID:%d) has set %s(ID:%d)'s name to %s"pnameplayeridnameidnick);
        
SendClientMessageToAll(COLOR_REDstring);
        
format(stringsizeof(string), "You set %s(ID:%d)'s name to %s"nameidnick);
        
SendClientMessage(playeridCOLOR_GREENstring);
        
format(stringsizeof(string), "Administrator %s(ID:%d) has set your name to %s"pnameplayeridnick);
        
SendClientMessage(idCOLOR_REDstring);
        
format(stringsizeof(string), "ADMIN-SPEC: %s has used /changename"pname);
        
SentMessageToAdmins(COLOR_GREYstring);
    }
    else return 
SendClientMessage(playeridCOLOR_RED"You must be Administrator Level 5 or higher to use this command!");
    return 
1;

Only 1 error: error 017: undefined symbol "Admin"
Reply
#5

Quote:
Originally Posted by Blackazur
Посмотреть сообщение
Only 1 error: error 017: undefined symbol "Admin"
What line? I'll fix it.
Reply
#6

lol i dont need a fix its all about he dont have the login/register system of Squirrel try
Код:
CMD:changename(playerid, params[]) 
{ 
    new name[MAX_PLAYER_NAME], 
        id, 
        pname[MAX_PLAYER_NAME], 
        string[128], 
        nick[20]; 
    if(PlayerInfo[playerid][pAdmin] > 5) 
    { 
        if(sscanf(params, "us[20]", id, nick)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /changename <playername/id> <nickname>"); 
        if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Invalid-Playerid!"); 
        if(IsPlayerNPC(id)) return SendClientMessage(playerid, COLOR_RED, "You cannot change NPC Bot's name!"); 
        GetPlayerName(id, name, sizeof(name)); 
        GetPlayerName(playerid, pname, sizeof(pname)); 
        SetPlayerName(id, nick); 
        format(string, sizeof(string), "Administrator %s(ID:%d) has set %s(ID:%d)'s name to %s", pname, playerid, name, id, nick); 
        SendClientMessageToAll(COLOR_RED, string); 
        format(string, sizeof(string), "You set %s(ID:%d)'s name to %s", name, id, nick); 
        SendClientMessage(playerid, COLOR_GREEN, string); 
        format(string, sizeof(string), "Administrator %s(ID:%d) has set your name to %s", pname, playerid, nick); 
        SendClientMessage(id, COLOR_RED, string); 
        format(string, sizeof(string), "ADMIN-SPEC: %s has used /changename", pname); 
        SentMessageToAdmins(COLOR_GREY, string); 
    } 
    else return SendClientMessage(playerid, COLOR_RED, "You must be Administrator Level 5 or higher to use this command!"); 
    return 1; 
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)