change name
#1

Hello i need help whit making /changename [new name] command it will send a massage to online admins after that admins can use /setname [id] and it will change to new name.
Reply
#2

I've done you a solid of making the command and explaining it.

Instead of asking to be handed a command though, do your best to learn. It gets pretty easy once you try too learn.

PHP код:
#include zcmd
#include foreach
new namechangeTimer[MAX_PLAYERS]; 
// Put this at the top of your script. 
CMD:requestname(playeridparams[])
{
    if (
isnull(params))
        return 
SendClientMessage(playerid, -1"Usage: /requestname [new name] to notify admins of a name change request.");
        
    if(
strlen(params) > MAX_PLAYER_NAME || strlen(params) < 3)
        return 
SendClientMessage(playerid, -1"** Your name must be at least 24 characters and greater than 3."); 
    
// This checks the params' string length. https://sampwiki.blast.hk/wiki/SetPlayer...1.26199727
    // Players are denied entry to the server if their name is below 3 chars. 
    
    
if(gettime() - namechangeTimer[playerid] < 60)
        return 
SendClientMessage(playerid, -1"* You need to wait 60 seconds before sending another request."); 
        
    
// This is just to avoid the command being spammable. Remove it if you don't want it. 
    // It'll make sure that 60 seconds have passed before the player can send in another request. 
    
    
new string[128], currentName[MAX_PLAYER_NAME]; 
    
GetPlayerName(playeridcurrentNamesizeof(currentName)); 
    
    
namechangeTimer[playerid] = gettime();  
    
// Get the current time to use for the 60 second check above.
    
    
foreach (new Player)
    {
        if(
IsPlayerAdmin(i))
        {
            
format (stringsizeof(string), "[Admin] %s is requesting a namechange to %s."currentNameparams); 
            
SendClientMessage(i0x0000FFFFstring);
        }
    }
    
// This checks if a player is an admin and sends them the notification. 
    // If you have your own variable for a player being an admin, change IsPlayerAdmin to that. 
    
    
format (stringsizeof(string), "** You requested a namechange from %s to %s. Admins were notified."currentNameparams);
    
SendClientMessage(playerid0x0000FFFFstring); 
    
    
    return 
true;

If you don't have foreach, remove #include foreach and replace foreach (new i : Player) with a MAX_PLAYERS loop.

I'll leave it up to you to make the /setname command.

https://sampforum.blast.hk/showthread.php?tid=570927
https://sampwiki.blast.hk/wiki/SetPlayerName
Reply
#3

PHP код:
#include a_samp
#include sscanf
#include zcmd
CMD:setname(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= || IsPlayerAdmin(playerid)) {
        new 
player1tmp2[32];
        if(
sscanf(params,"is[32]",player1,tmp2)) return SendClientMessage(playeridred"USAGE: /setname [playerid] [new name]");
        new 
length strlen(tmp2), string[128];
        if(
length || length MAX_PLAYER_NAME+1) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
        if(
PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            
CMDMessageToAdmins(playerid,"SETNAME");
            
format(stringsizeof(string), "You have set \"%s's\" name to \"%s\" "pName(player1), tmp2); SendClientMessage(playerid,blue,string);
            if(
player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your name to \"%s\" "pName(playerid), tmp2); SendClientMessage(player1,blue,string); }
            
PlayerInfo[playerid][God] = 0;
            
SetPlayerHealth(player1100);
            
SetPlayerName(player1tmp2);
               return 
OnPlayerConnect(player1);
        } else return 
SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
stock CMDMessageToAdmins(playerid,command[])
{
      if(
ServerInfo[AdminCmdMsg] == 0) return 0;
      new 
string[128];
      
GetPlayerName(playerid,string,sizeof(string));
      
format(string,sizeof(string),"[ADMIN] '%s' (Level: %d) | Command: %s",string,PlayerInfo[playerid][Level],command);
      
MessageToAdmins(blue,string);
      return 
1;
}
forward MessageToAdmins(color,const string[]);
public 
MessageToAdmins(color,const string[])
{
    foreach (new 
Player) if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= || IsPlayerAdmin(i)) SendClientMessage(icolorstring);
    
//return 1;

Reply
#4

Quote:
Originally Posted by HoussamMaroc
Посмотреть сообщение
PHP код:
#include a_samp
#include sscanf
#include zcmd
CMD:setname(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= || IsPlayerAdmin(playerid)) {
        new 
player1tmp2[32];
        if(
sscanf(params,"is[32]",player1,tmp2)) return SendClientMessage(playeridred"USAGE: /setname [playerid] [new name]");
        new 
length strlen(tmp2), string[128];
        if(
length || length MAX_PLAYER_NAME+1) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
        if(
PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            
CMDMessageToAdmins(playerid,"SETNAME");
            
format(stringsizeof(string), "You have set \"%s's\" name to \"%s\" "pName(player1), tmp2); SendClientMessage(playerid,blue,string);
            if(
player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your name to \"%s\" "pName(playerid), tmp2); SendClientMessage(player1,blue,string); }
            
PlayerInfo[playerid][God] = 0;
            
SetPlayerHealth(player1100);
            
SetPlayerName(player1tmp2);
               return 
OnPlayerConnect(player1);
        } else return 
SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
stock CMDMessageToAdmins(playerid,command[])
{
      if(
ServerInfo[AdminCmdMsg] == 0) return 0;
      new 
string[128];
      
GetPlayerName(playerid,string,sizeof(string));
      
format(string,sizeof(string),"[ADMIN] '%s' (Level: %d) | Command: %s",string,PlayerInfo[playerid][Level],command);
      
MessageToAdmins(blue,string);
      return 
1;
}
forward MessageToAdmins(color,const string[]);
public 
MessageToAdmins(color,const string[])
{
    foreach (new 
Player) if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= || IsPlayerAdmin(i)) SendClientMessage(icolorstring);
    
//return 1;

Credits pls.
Reply
#5

Quote:
Originally Posted by HoussamMaroc
Посмотреть сообщение
PHP код:
#include a_samp
#include sscanf
#include zcmd
CMD:setname(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= || IsPlayerAdmin(playerid)) {
        new 
player1tmp2[32];
        if(
sscanf(params,"is[32]",player1,tmp2)) return SendClientMessage(playeridred"USAGE: /setname [playerid] [new name]");
        new 
length strlen(tmp2), string[128];
        if(
length || length MAX_PLAYER_NAME+1) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
        if(
PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            
CMDMessageToAdmins(playerid,"SETNAME");
            
format(stringsizeof(string), "You have set \"%s's\" name to \"%s\" "pName(player1), tmp2); SendClientMessage(playerid,blue,string);
            if(
player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your name to \"%s\" "pName(playerid), tmp2); SendClientMessage(player1,blue,string); }
            
PlayerInfo[playerid][God] = 0;
            
SetPlayerHealth(player1100);
            
SetPlayerName(player1tmp2);
               return 
OnPlayerConnect(player1);
        } else return 
SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
stock CMDMessageToAdmins(playerid,command[])
{
      if(
ServerInfo[AdminCmdMsg] == 0) return 0;
      new 
string[128];
      
GetPlayerName(playerid,string,sizeof(string));
      
format(string,sizeof(string),"[ADMIN] '%s' (Level: %d) | Command: %s",string,PlayerInfo[playerid][Level],command);
      
MessageToAdmins(blue,string);
      return 
1;
}
forward MessageToAdmins(color,const string[]);
public 
MessageToAdmins(color,const string[])
{
    foreach (new 
Player) if(IsPlayerConnected(i) == 1) if (PlayerInfo[i][Level] >= || IsPlayerAdmin(i)) SendClientMessage(icolorstring);
    
//return 1;

You can't just post your code like everyone uses the same variables as you and not explain a single thing.

Quote:
Originally Posted by XeonMaster
Посмотреть сообщение
Credits pls.
Why're you going around threads asking for credits?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)