[Ajuda] colocar status de adm(ocupado e disponivel)
#1

ola pessoal queria pedir uma ajuda ae pra vcs que entendem de pawno bem ae. queria colocar um sistema de status dos adm's no /admins. tipo se eles estiverem ocupado ou disponivel.
Reply
#2

PHP код:
//Й sу criar uma variavel e usar os valores 0 quando tiver ocupado e 1 quando tiver disponivel.
new statsadm[MAX_PLAYERS];
//Quando o Player for "trabalhar" vc usa:
statsadm[playerid] = 1;
//Quando o Player for ficar ocupado vc usa:
statsadm[playerid] = 0;
//Aui esta um exemplo que vc pode no seu comando /admins por meio de format.
stock PegarStatus(playerid)
{
    new 
stats[20];
    switch(
statsadm[playerid])
    {
        case 
0:           { stats "Ocupado"; }
        case 
1:           { stats "Disponнvel"; }
    }
    return 
stats;

Reply
#3

SampSampa, por curiosidade, depois pode pegar esse status e colocar em um dialog usando uma string para pegar o nome do player e o status ?
Reply
#4

Sim, um exemplo bбsico usando SendClientMessage, o mesmo pode ser feito com um dialog.
PHP код:
CMD:meunome(playerid)
{
    new 
string[75];
    
format(string,sizeof(string), "Seu Nome й:%s e Seu Status й:%s"Nome(playerid), PegarStatus(playerid));
    
SendClientMessage(playerid, -string);
    return 
1;
}
//Essa й a funзгo criada anteriormente.
stock PegarStatus(playerid

    new 
stats[20]; 
    switch(
statsadm[playerid]) 
    { 
        case 
0:           { stats "Ocupado"; } 
        case 
1:           { stats "Disponнvel"; } 
    } 
    return 
stats
}  
// E essa й uma funзгo que uso para pegar o nome do player, existem outros jeitos, mas esse eu acho o mais compacto =)
stock Nome(playerid)
{
    new 
nome[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnomesizeof(nome));
    return 
nome;

ps. nгo estou testando esses cуdigos nгo, mas devem funcionar.
Reply
#5

Explicativo, Obrigado, sу por curiosidade mesmo...
Reply
#6

cara esse й o comando: queria colocar o status nele.

COMMAND:admins(playerid, params[])
{
// Setup local variables
new AdminList[500], Name[24];

// Send the command to all admins so they can see it
SendAdminText(playerid, "/admins", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Scan through all players
for (new i; i < MAX_PLAYERS; i++)
{
// Check if this player is connected
if (IsPlayerConnected(i))
{
// Get the name of the player
GetPlayerName(i, Name, sizeof(Name));

// Check if this player is an RCON admin
if (IsPlayerAdmin(i))
{
// Add all admin players to the list
format(AdminList, 500, "%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF})\n", AdminList, Name, i, AdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel]); // Add the name of the admin-player to the list
// Re-start the for loop (skipping the remaining code for this iteration)
continue;
}

//Check if that player is an admin (using the PlayerLevel)
if (APlayerData[i][PlayerLevel] > 0)
{
// Add all admin players to the list
format(AdminList, 500, "%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF})\n", AdminList, Name, i, AdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel]); // Add the name of the admin-player to the list
}
}
}

// Check if there were admin-names added to the list
if (strlen(AdminList) > 0)
ShowPlayerDialog(playerid, DialogNoResponse, DIALOG_STYLE_MSGBOX, "Admins Online:", AdminList, "OK", "Cancelar");
else
SendClientMessage(playerid, 0xFF0000FF, "Administraзгo Offline no Momento!"); // No admins are online
}
else
return 0;

// Let the server know that this was a valid command
return 1;
}
Reply
#7

° Sem necessidade de usar uma variбvel inteira para obter apenas dois valores: 0 e 1.
Quote:
Originally Posted by SampSampa
Посмотреть сообщение
PHP код:
new statsadm[MAX_PLAYERS]; 
° Que no caso pode ser substituнdo e usado corretamente com uma variбvel booleana: true e false.
PHP код:
new bool:statsadm[MAX_PLAYERS] = true
° Modo de usar para o player estar disponнvel:
PHP код:
statsadm[playerid] = true
° Modo de usar para quando o player estiver ocupado:
PHP код:
statsadm[playerid] = false
° Criou uma stock certo, porйm nгo tinha necessidade de usar uma switch para setar um status dependendo do valor de uma variбvel, sendo que estб variбvel pode apenas obter dois valores.
Quote:
Originally Posted by SampSampa
Посмотреть сообщение
PHP код:
stock PegarStatus(playerid)
{
    new 
stats[20];
    switch(
statsadm[playerid])
    {
        case 
0:           { stats "Ocupado"; }
        case 
1:           { stats "Disponнvel"; }
    }
    return 
stats;

° Poderia ter usado operaзхes ternбria, como citado abaixo:
PHP код:
stock PegarStatus(playerid)
{
    static 
stats[20];
    
stats statsadm[playerid] == true ? ("Disponнvel") : ("Ocupado");
    return 
stats;

° (Bфnus) Sistema completo + Comando /admins pronto:
PHP код:
new bool:statsadm[MAX_PLAYERS] = true
PHP код:
CMD:admins(playerid)
{
    static 
string[75], bool:count falseaname[MAX_PLAYER_NAME];
    
SendClientMessage(playerid0x00FF80AA"[ADMINS] Administradores Onlines no servidor!");
    for( new 
0<GetMaxPlayers( ) ; i++ )
    {
        if(
IsPlayerConnected(i))
        {
            
GetPlayerName(ianamesizeof(aname));
            
format(string,sizeof(string), "%s :: %s"anamePegarStatus(i));
            
SendClientMessage(playerid0xFFFF00AA string);
            
count true;
        }
    }
    if(
count == false) return SendClientMessage(playerid, -1"[ADMINS] {FF0000}No momento nгo tem admins online no servidor!");
    return 
1;

PHP код:
stock PegarStatus(playerid)
{
    new 
stats[20];
    
stats statsadm[playerid] == true ? ("Disponнvel") : ("Ocupado");
    return 
stats;

Reply
#8

Quote:
Originally Posted by SampSampa
Посмотреть сообщение
PHP код:
//Й sу criar uma variavel e usar os valores 0 quando tiver ocupado e 1 quando tiver disponivel.
new statsadm[MAX_PLAYERS];
//Quando o Player for "trabalhar" vc usa:
statsadm[playerid] = 1;
//Quando o Player for ficar ocupado vc usa:
statsadm[playerid] = 0;
//Aui esta um exemplo que vc pode no seu comando /admins por meio de format.
stock PegarStatus(playerid)
{
    new 
stats[20];
    switch(
statsadm[playerid])
    {
        case 
0:           { stats "Ocupado"; }
        case 
1:           { stats "Disponнvel"; }
    }
    return 
stats;

Com booleanas ficaria melhor e bem mais atrativo.
Reply
#9

Quote:
Originally Posted by Hades12
Посмотреть сообщение
cara esse й o comando: queria colocar o status nele.

COMMAND:admins(playerid, params[])
{
// Setup local variables
new AdminList[500], Name[24];

// Send the command to all admins so they can see it
SendAdminText(playerid, "/admins", params);

// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Scan through all players
for (new i; i < MAX_PLAYERS; i++)
{
// Check if this player is connected
if (IsPlayerConnected(i))
{
// Get the name of the player
GetPlayerName(i, Name, sizeof(Name));

// Check if this player is an RCON admin
if (IsPlayerAdmin(i))
{
// Add all admin players to the list
format(AdminList, 500, "%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF})\n", AdminList, Name, i, AdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel]); // Add the name of the admin-player to the list
// Re-start the for loop (skipping the remaining code for this iteration)
continue;
}

//Check if that player is an admin (using the PlayerLevel)
if (APlayerData[i][PlayerLevel] > 0)
{
// Add all admin players to the list
format(AdminList, 500, "%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF})\n", AdminList, Name, i, AdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel]); // Add the name of the admin-player to the list
}
}
}

// Check if there were admin-names added to the list
if (strlen(AdminList) > 0)
ShowPlayerDialog(playerid, DialogNoResponse, DIALOG_STYLE_MSGBOX, "Admins Online:", AdminList, "OK", "Cancelar");
else
SendClientMessage(playerid, 0xFF0000FF, "Administraзгo Offline no Momento!"); // No admins are online
}
else
return 0;

// Let the server know that this was a valid command
return 1;
}
Tente assim e utilizando o sistema que jб deixei acima.
PHP код:
COMMAND:admins(playeridparams[])
{
    new 
AdminList[500], Name[24];
    
SendAdminText(playerid"/admins"params);
    if(
APlayerData[playerid][LoggedIn] == false) return SendClientMessage(playerid, -1"[ ERRO ] {FF0000}Vocк nгo estб logado no servidor!");
    for(new 
iMAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(iNamesizeof(Name));
            if(
IsPlayerAdmin(i))
            {
                
format(AdminList500"%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF}) [%s]\n"AdminListNameiAdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel], PegarStatus(i));
                continue;
            }
            if(
APlayerData[i][PlayerLevel] > 0format(AdminList500"%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF}) [%s]\n"AdminListNameiAdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel], PegarStatus(i));
        }
    }
    if(
strlen(AdminList) > 0ShowPlayerDialog(playeridDialogNoResponseDIALOG_STYLE_MSGBOX"Admins Online:"AdminList"OK""Cancelar");
    else 
SendClientMessage(playerid0xFF0000FF"Administraзгo Offline no Momento!");
    return 
1;

Reply
#10

Quote:
Originally Posted by [BOPE]Seu._.Madruga
Посмотреть сообщение
Tente assim e utilizando o sistema que jб deixei acima.
PHP код:
COMMAND:admins(playeridparams[])
{
    new 
AdminList[500], Name[24];
    
SendAdminText(playerid"/admins"params);
    if(
APlayerData[playerid][LoggedIn] == false) return SendClientMessage(playerid, -1"[ ERRO ] {FF0000}Vocк nгo estб logado no servidor!");
    for(new 
iMAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(iNamesizeof(Name));
            if(
IsPlayerAdmin(i))
            {
                
format(AdminList500"%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF}) [%s]\n"AdminListNameiAdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel], PegarStatus(i));
                continue;
            }
            if(
APlayerData[i][PlayerLevel] > 0format(AdminList500"%s {FFFFFF}%s {FFFFFF}(id: {FF8000}%i{FFFFFF}) - {FF8000}%s {FFFFFF}(Level de adm {FF8000}%i{FFFFFF}) [%s]\n"AdminListNameiAdminLevelName[APlayerData[i][PlayerLevel]], APlayerData[i][PlayerLevel], PegarStatus(i));
        }
    }
    if(
strlen(AdminList) > 0ShowPlayerDialog(playeridDialogNoResponseDIALOG_STYLE_MSGBOX"Admins Online:"AdminList"OK""Cancelar");
    else 
SendClientMessage(playerid0xFF0000FF"Administraзгo Offline no Momento!");
    return 
1;

vlw ae cara consegui
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)