[Ajuda] CMD
#1

oque tem de errado? ta bugando nгo esta executando a mudanзa de nick

Код:
    if(strcmp(cmd,"/onmudarnick",true)==0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            if(AdminTrabalhando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != 1340 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341)
			{
			     SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб trabalhando! (/trabalhar)");
				 return 1;
		    }
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USE: /onmudarnick [ id ]");
				return 1;
			}
			new playa;
			playa = ReturnUser(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 1337)
			{
			    if(IsPlayerConnected(playa))
			    {
			        if(playa != INVALID_PLAYER_ID)
			        {
                        PodeMudarNick[playa] = 1;
                        GetPlayerName(playa, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
		         		format(string, sizeof(string), "Admin %s: Autorizou vocк a mudar o nick, digite /mudarnick.", sendername);
		        		SendClientMessage(playa, COLOR_LIGHTBLUE, string);
		        		format(string, sizeof(string), "ADMIN CMD: %s autorizou %s a mudar o nick !",sendername,giveplayer);
						ABroadCast(COLOR_LIGHTRED,string,1);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб autorizado a usar este comando!");
				return 1;
			}
		}
		return 1;
	}
	if(strcmp(cmd, "/offmudarnick", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] >= 1337)
	        {
		        if(AdminTrabalhando[playerid] < 1 && PlayerInfo[playerid][pAdmin] != 1340 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341)
				{
					SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб trabalhando! (/trabalhar)");
					return 1;
				}
	            tmp = strtok(cmdtext, idx);
				if(!strlen(tmp))
				{
				    SendClientMessage(playerid, COLOR_WHITE, "USE: /offmudarsenha [id]");
				    return 1;
				}
				giveplayerid = ReturnUser(tmp);
				if(IsPlayerConnected(giveplayerid))
				{
				    if(giveplayerid != INVALID_PLAYER_ID)
				    {
						PodeMudarNick[giveplayerid] = 0;
				        GetPlayerName(playerid, sendername, sizeof(sendername));
				        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        format(string, sizeof(string), "Admin %s : Tirou sua permissгo para mudar de nick.", sendername);
		        		SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, string);
				        format(string, sizeof(string), "ADMIN CMD: %s tirou a permissгo de %s para mudar o nick !",sendername,giveplayer);
						ABroadCast(COLOR_LIGHTRED,string,1);
				        return 1;
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GREY, "O Jogador Estб Offline !");
				    return 1;
				}
	        }
	        else
	        {
	            SendClientMessage(playerid, COLOR_GREY, "Vocк nгo estб autorizado a usar este comando !");
	            return 1;
	        }
	    }
	    return 1;
	}
Reply
#2

Nos seus comandos sу vi desperdнcios de linhas, Melhore seus cуdigos o Compilador agradece!
De 87 (linhas) para 38 (linhas)
PHP код:
    if(strcmp(cmd,"/onmudarnick",true)==0)
    {
        if(!
IsPlayerConnected(playerid)) return 1;
        if(
AdminTrabalhando[playerid] < && PlayerInfo[playerid][pAdmin] != 1340 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341) return SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo estб trabalhando! (/trabalhar)");
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return SendClientMessage(playeridCOLOR_GRAD2"USE: /onmudarnick [ id ]");
        new 
playa ReturnUser(tmp);
        if(
PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo estб autorizado a usar este comando!");
        if(!
IsPlayerConnected(playa)) return SendClientMessage(playeridCOLOR_GRAD2"Este player nao esta conectado");
        if(
playa == INVALID_PLAYER_ID) return 1;
        
PodeMudarNick[playa] = 1;
        
GetPlayerName(playagiveplayersizeof(giveplayer));
        
GetPlayerName(playeridsendernamesizeof(sendername));
        
format(stringsizeof(string), "Admin %s: Autorizou vocк a mudar o nick, digite /mudarnick."sendername);
        
SendClientMessage(playaCOLOR_LIGHTBLUEstring);
        
format(stringsizeof(string), "ADMIN CMD: %s autorizou %s a mudar o nick !",sendername,giveplayer);
        
ABroadCast(COLOR_LIGHTRED,string,1);
        return 
1;
    }
    if(
strcmp(cmd"/offmudarnick"true) == 0)
    {
        if(!
IsPlayerConnected(playerid)) return 1;
        if(
PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playeridCOLOR_GREY"Vocк nгo estб autorizado a usar este comando !");
        if(
AdminTrabalhando[playerid] < && PlayerInfo[playerid][pAdmin] != 1340 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341) return SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo estб trabalhando! (/trabalhar)");
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return SendClientMessage(playeridCOLOR_WHITE"USE: /offmudarsenha [id]");
        
giveplayerid ReturnUser(tmp);
        if(!
IsPlayerConnected(giveplayerid)) return SendClientMessage(playeridCOLOR_GREY"O Jogador Estб Offline !");
        if(
giveplayerid == INVALID_PLAYER_ID) return 1;
        
PodeMudarNick[giveplayerid] = 0;
        
GetPlayerName(playeridsendernamesizeof(sendername));
        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
        
format(stringsizeof(string), "Admin %s : Tirou sua permissгo para mudar de nick."sendername);
        
SendClientMessage(giveplayeridCOLOR_LIGHTBLUEstring);
        
format(stringsizeof(string), "ADMIN CMD: %s tirou a permissгo de %s para mudar o nick !",sendername,giveplayer);
        
ABroadCast(COLOR_LIGHTRED,string,1);
        return 
1;
    } 
Reply
#3

Quote:
Originally Posted by [BOPE]Seu._.Madruga
Посмотреть сообщение
Nos seus comandos sу vi desperdнcios de linhas, Melhore seus cуdigos o Compilador agradece!
De 87 (linhas) para 38 (linhas)
PHP код:
    if(strcmp(cmd,"/onmudarnick",true)==0)
    {
        if(!
IsPlayerConnected(playerid)) return 1;
        if(
AdminTrabalhando[playerid] < && PlayerInfo[playerid][pAdmin] != 1340 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341) return SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo estб trabalhando! (/trabalhar)");
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return SendClientMessage(playeridCOLOR_GRAD2"USE: /onmudarnick [ id ]");
        new 
playa ReturnUser(tmp);
        if(
PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo estб autorizado a usar este comando!");
        if(!
IsPlayerConnected(playa)) return SendClientMessage(playeridCOLOR_GRAD2"Este player nao esta conectado");
        if(
playa == INVALID_PLAYER_ID) return 1;
        
PodeMudarNick[playa] = 1;
        
GetPlayerName(playagiveplayersizeof(giveplayer));
        
GetPlayerName(playeridsendernamesizeof(sendername));
        
format(stringsizeof(string), "Admin %s: Autorizou vocк a mudar o nick, digite /mudarnick."sendername);
        
SendClientMessage(playaCOLOR_LIGHTBLUEstring);
        
format(stringsizeof(string), "ADMIN CMD: %s autorizou %s a mudar o nick !",sendername,giveplayer);
        
ABroadCast(COLOR_LIGHTRED,string,1);
        return 
1;
    }
    if(
strcmp(cmd"/offmudarnick"true) == 0)
    {
        if(!
IsPlayerConnected(playerid)) return 1;
        if(
PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playeridCOLOR_GREY"Vocк nгo estб autorizado a usar este comando !");
        if(
AdminTrabalhando[playerid] < && PlayerInfo[playerid][pAdmin] != 1340 && PlayerInfo[playerid][pAdmin] != 1342 && PlayerInfo[playerid][pAdmin] != 1341) return SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo estб trabalhando! (/trabalhar)");
        
tmp strtok(cmdtextidx);
        if(!
strlen(tmp)) return SendClientMessage(playeridCOLOR_WHITE"USE: /offmudarsenha [id]");
        
giveplayerid ReturnUser(tmp);
        if(!
IsPlayerConnected(giveplayerid)) return SendClientMessage(playeridCOLOR_GREY"O Jogador Estб Offline !");
        if(
giveplayerid == INVALID_PLAYER_ID) return 1;
        
PodeMudarNick[giveplayerid] = 0;
        
GetPlayerName(playeridsendernamesizeof(sendername));
        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
        
format(stringsizeof(string), "Admin %s : Tirou sua permissгo para mudar de nick."sendername);
        
SendClientMessage(giveplayeridCOLOR_LIGHTBLUEstring);
        
format(stringsizeof(string), "ADMIN CMD: %s tirou a permissгo de %s para mudar o nick !",sendername,giveplayer);
        
ABroadCast(COLOR_LIGHTRED,string,1);
        return 
1;
    } 


Eu nгo li isto.
Reply
#4

E assim o cуdigo fica super organizado nй
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)