strcmp erros e outros -
Hatiro - 30.03.2019
nгo sei se a causa de todos й o "strcmp"
codigo:
Код:
public OnPlayerCommandText(playerid, cmd[])
{
new tmp[128];
if(strcmp(cmd, "/convidar", true) == 0)
{
tmp = strtok(cmd, idx);
new PlayerB;
if(!strlen(tmp)) return SendClientMessage(playerid, Branco, "Uso correto: /convidar [id]");
PlayerB = strval(tmp);
if(!IsPlayerConnected(PlayerB)) return SendClientMessage(playerid, Branco, "Este jogador nгo estб conectado");
if(PlayerInfo[playerid][PMilitar] >= 6)
{
PlayerInfo[PlayerB][PMilitar] = 1;
SendClientMessage(PlayerB, Branco, "Vocк entrou а Polнcia Militar");
SetPlayerColor(PlayerB, Cor_PMilitar);
return 1;
}
else if(PlayerInfo[playerid][Groove] >= 6)
{
PlayerInfo[PlayerB][Groove] = 1;
SendClientMessage(PlayerB, Branco, "Vocк entrou а Groove");
SetPlayerColor(PlayerB, Cor_Groove);
return 1;
}
else if(PlayerInfo[playerid][Ballas] >= 6)
{
PlayerInfo[PlayerB][Ballas] = 1;
SendClientMessage(PlayerB, Branco, "Vocк entrou aos Ballas");
SetPlayerColor(PlayerB, Cor_Ballas);
return 1;
}
return 0;
}
if(strcmp(cmd, "/promover", true) == 0)
{
tmp = strtok(cmdtext, idx);
new PlayerB, level;
if(!strlen(tmp)) return SendClientMessage(playerid, Branco, "Uso correto: /promover [id] [cargo]");
PlayerB = strval(tmp);
if(!IsPlayerConnected(PlayerB)) return SendClientMessage(playerid, Branco, "Este jogador nгo estб conectado");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, Branco, "Uso correto: /promover [id] [cargo]");
level = strval(tmp);
if(level < 1 || level > 6) return SendClientMessage(playerid, Branco, "O level deve ser maior que 0 e menor que 7");
new string[128], promovedor[MAX_PLAYER_NAME];
GetPlayerName(playerid, promovedor, sizeof(promovedor));
if(PlayerInfo[playerid][PMilitar] >= 6)
{
if(PlayerInfo[PlayerB][PMilitar] < 1) return SendClientMessage(playerid, Branco, "Este jogador nгo й da sua org");
PlayerInfo[PlayerB][PMilitar] = level;
format(string, sizeof(string), "Vocк foi promovido a level %d por %s", level, promovedor););
SendClientMessage(PlayerB, Branco, string);
return 1;
}
else if(PlayerInfo[playerid][Groove] >= 6)
{
if(PlayerInfo[PlayerB][Groove] < 1) return SendClientMessage(playerid, Branco, "Este jogador nгo й da sua org");
PlayerInfo[PlayerB][Groove] = level;
format(string, sizeof(string), "Vocк foi promovido a level %d por %s", level, promovedor););
SendClientMessage(PlayerB, Branco, string);
return 1;
}
else if(PlayerInfo[playerid][Ballas] >= 6)
{
if(PlayerInfo[PlayerB][Ballas] < 1) return SendClientMessage(playerid, Branco, "Este jogador nгo й da sua org");
PlayerInfo[PlayerB][Ballas] = level;
format(string, sizeof(string), "Vocк foi promovido a level %d por %s", level, promovedor););
SendClientMessage(PlayerB, Branco, string);
return 1;
}
return 0;
}
if(strcmp(cmd, "/demitir", true) == 0)
{
tmp = strtok(cmdtext, idx);
new PlayerB, string[128], demitidor[MAX_PLAYER_NAME];
if(!strlen(tmp)) return SendClientMessage(playerid, Branco, "Uso correto: /demitir [id]");
PlayerB = strval(tmp);
GetPlayerName(playerid, demitidor, sizeof(demitidor));
if(!IsPlayerConnected(PlayerB)) return SendClientMessage(playerid, Branco, "Este jogador nгo estб conectado");
if(PlayerInfo[playerid][PMilitar] >= 6)
{
if(PlayerInfo[PlayerB][PMilitar] < 1) return SendClientMessage(playerid, Branco, "Este jogador nгo й da sua organizaзгo");
PlayerInfo[PlayerB][PMilitar] = 0;
format(string, sizeof(string), "Vocк foi demitido por %s", demitidor);
SendClientMessage(PlayerB, Branco, string);
return 1;
}
else if(PlayerInfo[playerid][Groove] >= 6)
{
if(PlayerInfo[PlayerB][Groove] < 1) return SendClientMessage(playerid, Branco, "Este jogador nгo й da sua organizaзгo");
PlayerInfo[PlayerB][Groove] = 0;
format(string, sizeof(string), "Vocк foi demitido por %s", demitidor);
SendClientMessage(PlayerB, Branco, string);
return 1;
}
else if(PlayerInfo[playerid][Ballas] >= 6)
{
if(PlayerInfo[PlayerB][Ballas] < 1) return SendClientMessage(playerid, Branco, "Este jogador nгo й da sua organizaзгo");
PlayerInfo[PlayerB][Ballas] = 0;
format(string, sizeof(string), "Vocк foi demitido por %s", demitidor);
SendClientMessage(PlayerB, Branco, string);
return 1;
}
return 0;
}
codigo completo:
https://pastebin.com/er2TttKL
https://prnt.sc/n528w3
includes:
a_samp + dini
Re: strcmp erros e outros -
NWDMadara - 30.03.2019
26 erros = Provavelmente alguma chave faltando
faltou fechar uma chave ali no final, depois de return 0, que deveria ser return 1.
Re: strcmp erros e outros -
Hatiro - 30.03.2019
oi poderia rever o codigo upei ele no pastebin (completo)
no return do final eles tava com 1 ae coloquei para 0 para testa
nгo estou familiarizado com "strcmp"
Re: strcmp erros e outros -
NWDMadara - 30.03.2019
Como eu disse, estб faltando fechar uma chave no final do OnPlayerCommandText. Tenha em mente que sempre que vocк abrir uma chave, vocк terб que fechб-la depois.
Exemplo:
Certo:
PHP код:
if(!strcmp(params, "/Eu", true))
{
if(IsPlayerInAnyVehicle(playerid))
{
//
}
return 1;
}
Errado:
PHP код:
if(!strcmp(params, "/Eu", true))
{
if(IsPlayerInAnyVehicle(playerid))
{
//
return 1;
}
Abri 5 chaves, devo fechar 5.
Espero que consiga entender com esse exemplo. Com prбtica tu se acostuma.
Re: strcmp erros e outros -
Hatiro - 30.03.2019
assim agora eu entendi

desculpa

obrigado ;3
erros restante:
http://prntscr.com/n528w3
Re: strcmp erros e outros -
NWDMadara - 30.03.2019
Manda toda a gm.
Recomendo que passe a usar ZCMD. Ele й bem mais otimizado e fбcil de usar.
Re: strcmp erros e outros -
Hatiro - 30.03.2019
essa й toda gm
https://pastebin.com/er2TttKL
sei que zcmd й bom porem nгo sei fazer nele '-' o codigo que ta em "strcmp"
Re: strcmp erros e outros -
NWDMadara - 30.03.2019
Vocк abriu uma chave ao invйs de fechar kkkkkkkkkkkkkkkk
{ = Aberto
} = Fechado
Seu cуdigo:
PHP код:
{ - ( Certo: '}' )
return 0;
}
Sobre o ZCMD. Quando eu vi os comandos em ZCMD pela primeira vez, tambйm os achei mais complicados que sscanf. Por estar acostumado com sscanf isso й normal. O segredo й comeзar pelo bбsico em ZCMD como se estivesse acabando de comeзar em sscanf.
* Vou fazer esse seu cmd em ZCMD pra tu ter uma ideia de como ficaria.
Re: strcmp erros e outros -
Hatiro - 30.03.2019
'-' blz agradeзo

kkk
Re: strcmp erros e outros -
NWDMadara - 30.03.2019
PHP код:
CMD:convidar(playerid, params[])
{
new id;
if(sscanf(params, "d", id)) return SendClientMessage(playerid, Branco, "Uso correto: /convidar [id]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, Branco, "Este jogador nгo estб conectado");
if(PlayerInfo[playerid][PMilitar] >= 6)
{
PlayerInfo[id][PMilitar] = 1;
SendClientMessage(id, Branco, "Vocк entrou а Polнcia Militar");
SetPlayerColor(id, Cor_PMilitar);
}
else if(PlayerInfo[playerid][Groove] >= 6)
{
PlayerInfo[id][Groove] = 1;
SendClientMessage(id, Branco, "Vocк entrou а Groove");
SetPlayerColor(id, Cor_Groove);
}
else if(PlayerInfo[playerid][Ballas] >= 6)
{
PlayerInfo[id][Ballas] = 1;
SendClientMessage(id, Branco, "Vocк entrou aos Ballas");
SetPlayerColor(id, Cor_Ballas);
}
return 1;
}
Dependendo da sua GM ou de como tu ta fazendo esse sistema, daria atй pra deixar mais otimizado. Isso com o tempo tu vai pegando o jeito, nгo adianta eu te falar as formas, atй porque sгo muitas.
* Caso queira ajuda em algo ou dicas, pode me mandar algum meio de contato por aqui ou PM.
Re: strcmp erros e outros -
Hatiro - 30.03.2019
Discord: Hash
#2873