SA-MP Forums Archive
[Ajuda] /Daradmin - Correto ou Errado ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] /Daradmin - Correto ou Errado ? (/showthread.php?tid=595510)



/Daradmin - Correto ou Errado ? - iTzSwaaT - 04.12.2015

Galera, estou sem nenhum colega On pra me ajudar a testar
Alguem pode me dizer se esse comando esta certo ? Se quando eu der o admin para o id X, o admin sera dado a ele, e nao a mim

#EDIT Ja Resolvi

pawn Код:
if(strcmp(cmd, "/daradmin", true) == 0)
{
    if(PlayerInfo[playerid][Admin] == 6)
    {
        if(PlayerInfo[playerid][AdminTrabalhando] == 1 || PlayerInfo[playerid][Admin] == 6)
        {
            new tmp[128];
            new pid, adminlevel;

            tmp = strtok(cmdtext, idx);
            pid = strval(tmp);

            if(strlen(tmp) == 0)
            {
                SendClientMessage(playerid, COR_CINZA, "Use: /daradmin [ ID ] [ Nivel ]");
                return 1;
            }

            tmp = strtok(cmdtext,idx);
            adminlevel = strval(tmp);

            if(strlen(tmp) == 0)
            {
                SendClientMessage(playerid, COR_CINZA, "Use: /daradmin [ ID ] [ Nivel ]");
                return 1;
            }

            if(adminlevel < 1 || adminlevel > 6)
            {
                SendClientMessage(playerid, COR_CINZA, "Use: /daradmin [ ID ] [ 1-6 ]");
                return 1;
            }

            if(PlayerInfo[pid][Logado] == 1)
            {
                new NomePid[24];
                GetPlayerName(pid, NomePid, 24);
                   
                VagasAdmins(pid, NomePid, adminlevel);
            }
            else
            {
                SendClientMessage(playerid, COR_CINZA, "Este jogador nгo esta logado");
            }
        }
        else
        {
            SendClientMessage(playerid, COR_CINZA, "Vocк nгo esta trabalhando. Use: /trabalhar");
        }
    }
    else
    {
        SendClientMessage(playerid, COR_CINZA, "Vocк nгo tem permissгo para usar este comando");
    }
    return 1;
}
pawn Код:
forward VagasAdmins(playerid, Nome[], LevelAdmin);
public VagasAdmins(playerid, Nome[], LevelAdmin)
{
    new ArquivosAdmins[30], Texto[256];
    format(ArquivosAdmins, sizeof(ArquivosAdmins), "Configs/Admins.ini");
   
    if(strcmp(dini_Get(ArquivosAdmins, "Admin1"), Nome, true) == 0 || strcmp(dini_Get(ArquivosAdmins, "Admin1"), "Vazio", true) == 0)
    {
        dini_Set(ArquivosAdmins, "Admin1", Nome);
    }
   
    format(Texto, sizeof(Texto), "O jogador [ %s ] foi promovido a [ Admin Level %d ]", Nome, LevelAdmin); SendClientMessageToAll(COR_LIGHTRED, Texto);
    PlayerInfo[playerid][Admin] = LevelAdmin;
    return 1;
}



Re: /Daradmin - Correto ou Errado ? - F1N4L - 05.12.2015

Sу para esclarecer sua dъvida:
Quote:

Alguem pode me dizer se esse comando esta certo ? Se quando eu der o admin para o id X, o admin sera dado a ele, e nao a mim

Quando vc cria o comando e o executa ingame, automaticamente seta vc como 'playerid' (ou caso vc altere), ou seja, VOCК.
Quando vc executa o comando em algum outro player, este й chamado 'target' (alvo), ou defina outro nome (new target; )

Entenda isso...

Quote:

new string[144];
new target;
// target = alvo
format(string, sizeof(string), "Admin %s[%i] have ejected you from your vehicle.", NamePlayer(playerid), playerid);
SendClientMessage(>target<, -1, string);
// playerid = admin
format(string, sizeof(string), "You have ejected %s[%i] from his vehicle.", NamePlayer(target), target);
SendClientMessage(>playerid<, -1, string);




Re: /Daradmin - Correto ou Errado ? - naotenhonome - 05.12.2015

Mano teste o meu:

Код:
	dcmd_daradmin(playerid, params[])
	{
	     if(Player[playerid][pAdmin] < 6 && !IsPlayerAdmin(playerid))
	        return SendClientMessage(playerid, COLOR_RED, "[ERRO] Vocк nгo tem permissгo para usar este comando!");

       	new tmp[24], idx; tmp = strtok(params, idx);
		if(!strlen(tmp))
			return SendClientMessage(playerid, COLOR_GREY, "[USO] /daradmin [id/nick] [level(1-7)]");

		new level;
		new giveid = ReturnUser(tmp);
       	tmp = strtok(params, idx);
		level = strval(tmp);
		if(level < 0 || level > 8)
		    return SendClientMessage(playerid, COLOR_RED, "[ERRO] Levels entre 0 e 8");

		Player[giveid][pAdmin] = level;
		format(thestring, sizeof(thestring), "Vocк, %s, foi Promovido hб %s level %d pelo administrador %s.", Player[giveid][pName], AccountName(giveid), level, Player[playerid][pName]);
		SendClientMessage(giveid, COLOR_LIGHTBLUE, thestring);
		WriteLog("admins", thestring);
		format(thestring, sizeof(thestring), "Vocк setou %s para %s level %d.", Player[giveid][pName],AccountName(giveid), level);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, thestring);

		return 1;
	}
coloque no OnPlayerCommandText
Код:
dcmd(daradmin, 8, cmdtext);
mas cara o seu server nгo e igual ao meu, entгo hб grandes chance de erros.