Ativar e Desativar CMD -
Paulo18 - 19.08.2014
Bom Pessoal Queria Ajuda de vcs tentei varias vezes mais quando compilo fica com erro... Entгo venho pedir a ajuda!!!
Queria que ao usar este CMD (( /autorizarpd )) ativasse e usando ele novamente desativasse !! Mais nгo consigo entгo tive que criar 2 CMD 1 para ativar e outro para desativar !!
pawn Код:
if(strcmp(cmd,"/autorizarpd",true)==0)
{
if((gTeam[playerid] = 16))
{
if(IsPlayerConnected(playerid))
{
if(!IsACop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Vocк nгo й um policial civil!");
return true;
}
if(OnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GREY, " Vocк nгo Bateu o cartгo!");
return true;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /autorizarpd [ id ]");
return true;
}
new playa;
playa = ReturnUser(tmp);
if (PlayerInfo[playerid][pLider] >= 1 || PlayerInfo[playerid][pCargo] == 5)
{
if(IsPlayerConnected(playa))
if(playa != INVALID_PLAYER_ID)
{
LiberarDadosSuspeitos[playa] = 1;
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s recebeu permissгo para coletar dados do suspeito, por %s.",giveplayer,sendername);
SendFamilyMessage(16, COLOR_LIGHTBLUE, string);
printf("%s", string);
return true;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб autorizado a usar este comando!");
return true;
}
}
return true;
}
if(strcmp(cmd,"/desautorizarpd",true)==0)
{
if((gTeam[playerid] = 16))
{
if(IsPlayerConnected(playerid))
{
if(!IsACop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Vocк nгo й um policial civil!");
return true;
}
if(OnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GREY, " Vocк nгo Bateu o cartгo!");
return true;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /desautorizarpd [ id ]");
return true;
}
new playa;
playa = ReturnUser(tmp);
if (PlayerInfo[playerid][pLider] >= 1 || PlayerInfo[playerid][pCargo] == 5)
{
if(IsPlayerConnected(playa))
if(playa != INVALID_PLAYER_ID)
{
LiberarDadosSuspeitos[playa] = 0;
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s perdeu permissгo para coletar dados do suspeito, por %s.",giveplayer,sendername);
SendFamilyMessage(16, COLOR_LIGHTBLUE, string);
printf("%s", string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб autorizado a usar este comando!");
return true;
}
}
return true;
}
Re: Ativar e Desativar CMD -
Ley - 19.08.2014
Irei dar um exemplo simples e rбpido.
Primeiramente criaremos uma booleana no topo do Game Mode:
PHP код:
new bool:Ligado[MAX_PLAYERS];
Utilizaremos a funзгo
else if no comando, justamente para verificar se o mesmo estб ou nгo autorizado:
PHP код:
if(strcmp(cmd, "/autorizarpd",true) == 0)
{
if(Ligado[playerid] == false) // Se for falso, muda para verdadeiro.
{
SendClientMessage(playerid, -1, "Comando ligado.");
Ligado[playerid] = true;
return 1;
}
else if(Ligado[playerid] == true) // Se for verdadeiro, muda para faзo.
{
SendClientMessage(playerid, -1, "Comando desligado.");
Ligado[playerid] = false;
return 1;
}
return 1;
}
Com isso, toda vez que digitar o comando ele irб fazer uma verificaзгo na booleana para decifrar se o comando estб ativado ou nгo. Se nгo for um comando utilizado somente para o playerid, remova o [MAX_PLAYERS] e retire as "[playerid]" que estгo localizadas apуs a booleana "Ligado".
Boa sorte.
Re: Ativar e Desativar CMD -
Paulo18 - 19.08.2014
Ley Obrigado por estб ajudando fiz como vc falou mais acho que errei em algo.... tenta me dar outra forзa ai por favor .... deu 1 warning e 2 erros
pawn Код:
if(strcmp(cmd,"/autorizarcd",true)==0)
{
if((gTeam[playerid] = 16))
{
if(IsPlayerConnected(playerid))
{
if(!IsACop(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " Vocк nгo й um policial civil!");
return true;
}
if(OnDuty[playerid] != 1)
{
SendClientMessage(playerid, COLOR_GREY, " Vocк nгo Bateu o cartгo!");
return true;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USE: /autorizarcd [ id ]");
return true;
}
new playa;
playa = ReturnUser(tmp);
if (PlayerInfo[playerid][pLider] >= 1 || PlayerInfo[playerid][pCargo] == 5)
{
if(IsPlayerConnected(playa))
if(playa != INVALID_PLAYER_ID)
{
LiberarDadosSuspeitos[playa] = 1;
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s recebeu permissгo para coletar dados do suspeito, por %s.",giveplayer,sendername);
SendFamilyMessage(16, COLOR_LIGHTBLUE, string);
printf("%s", string);
return true;
}
}
}
else if(LiberarDadosSuspeitos[giveplayerid] = 0;
{
format(string, sizeof(string), "* %s perdeu permissгo para coletar dados do suspeito, por %s.",giveplayer,sendername);
SendFamilyMessage(16, COLOR_LIGHTBLUE, string);
printf("%s", string);
return true;
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб autorizado a usar este comando!");
return true;
}
deu 2 erros e 1 warning
pawn Код:
C:\Users\Paulo\Desktop\GM's Samp\gm'sss\BNW1\gamemodes\BNW1.pwn(46981) : warning 211: possibly unintended assignment
C:\Users\Paulo\Desktop\GM's Samp\gm'sss\BNW1\gamemodes\BNW1.pwn(46981) : error 001: expected token: ")", but found ";"
C:\Users\Paulo\Desktop\GM's Samp\gm'sss\BNW1\gamemodes\BNW1.pwn(46981) : error 036: empty statement
nessa linha
pawn Код:
else if(LiberarDadosSuspeitos[giveplayerid] = 0;
Alguem mais puder ajudar ai eu agradeзo
Re: Ativar e Desativar CMD -
ViniBorn - 19.08.2014
pawn Код:
else if(LiberarDadosSuspeitos[giveplayerid] == 0)
Re: Ativar e Desativar CMD -
Paulo18 - 19.08.2014
Bom
ViniBorn ... Retirou os 2 erros e a warning .... mais meu CMD nao ficou certo uso /autorizarpd e ativa uso de novo ai ativa de novo nao ta desativando.... e quando aperto a Letra (( F )) em qualquer lugar da essa MSG
pawn Код:
SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo estб autorizado a usar este comando!");
ta compilando tudo certo !! mais o CMD ta Errado !!
se puder dar uma editada no meu ultimo CMD e me mostrar agradeзo !!!
Quem Puder ajudar tb agradeзo desda jб !!
Re: Ativar e Desativar CMD -
Ley - 20.08.2014
Sobre a questгo da tecla (F), tente usar a lуgica para evitar o problema. Improvise, nгo custa nada.
Vб na callback OnPlayerKey... e tente fazer algo como por exemplo:
PHP код:
if(!PlayerToPoint(1.5, playerid, x, y, z)) return 1;
Em x, y, z, vocк adiciona as coordenadas que irб identificar onde o usuбrio poderб utilizar a tecla, caso ele nгo esteja no local e consulte a tecla a funзгo darб um retorno para evitar a mensagem.
Boa sorte.