SA-MP Forums Archive
[Ajuda] Comando /Abastecer Bugado - 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] Comando /Abastecer Bugado (/showthread.php?tid=545794)



Comando /Abastecer Bugado - DwarD - 10.11.2014

Galera Estava Codando Meu Gm E Quando Fiz Um Comando /abastecer Prestei atenзгo que estava Bugado tipo: Eu Vou Com O Meu Character(Player) No Posto Sem Carro E digito / abastecer Eu Consigo abastecer mas sem estar com nenhum veiculo o meu Pawn Code й Esse

Pawn Code
Quote:

if(strcmp(cmd, "/abastecer", true) == 0) {
new tmp[256];
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(file, sizeof(file), PASTA_CONTAS, aname);
new quantidade;
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, Vermelho, "** Uso: /abastecer [litros]");
return 1;
}
quantidade = strval(tmp);
if(quantidade <= 0 || GetPlayerGrana(playerid) < quantidade){
SendClientMessage(playerid, Vermelho, "** Vocк nгo tem dinheiro suficiente para pagar o frentista.");
return 1;
}
if(AreaPosto[playerid] == 1){
if(quantidade + dini_Int(file, "Combustivel") < 100){
dini_IntSet(file, "Combustivel", dini_Int(file, "Combustivel") + quantidade);
format(string, sizeof(string), "* Vocк completou seu tanque com %d litros de combustнvel.", quantidade);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerGrana(playerid, - quantidade);
return 1;
}
if(quantidade + dini_Int(file, "Combustivel")){
new quantia;
quantia = 100 - dini_Int(file, "Combustivel");
dini_IntSet(file, "Combustivel", 100);
format(string, sizeof(string), "* Pronto, tanque cheio foram colocados %d litros.", quantia);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerGrana(playerid, - quantia);
return 1;
}
}else{
SendClientMessage(playerid, Vermelho, "** Vocк nгo estб no posto.");
return 1;
}
}

Se Alguem Poder me Ajudar . Grato Desde Jб


Re: Comando /Abastecer Bugado - Alwe - 10.11.2014

pawn Код:
if(strcmp(cmd, "/abastecer", true) == 0) {
new tmp[256];
new aname[MAX_PLAYER_NAME];
GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
format(file, sizeof(file), PASTA_CONTAS, aname);
new quantidade;
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
if(IsPlayerInAnyVehicle(playerid) == 0){ // Este й o cуdigo que estava faltando
SendClientMessage(playerid, Vermelho, " | ERRO | Vocк nгo esta em um veiculo.! ");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)){
SendClientMessage(playerid, Vermelho, "** Uso: /abastecer [litros]");
return 1;
}
quantidade = strval(tmp);
if(quantidade <= 0 || GetPlayerGrana(playerid) < quantidade){
SendClientMessage(playerid, Vermelho, "** Vocк nгo tem dinheiro suficiente para pagar o frentista.");
return 1;
}
if(AreaPosto[playerid] == 1){
if(quantidade + dini_Int(file, "Combustivel") < 100){
dini_IntSet(file, "Combustivel", dini_Int(file, "Combustivel") + quantidade);
format(string, sizeof(string), "* Vocк completou seu tanque com %d litros de combustнvel.", quantidade);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerGrana(playerid, - quantidade);
return 1;
}
if(quantidade + dini_Int(file, "Combustivel")){
new quantia;
quantia = 100 - dini_Int(file, "Combustivel");
dini_IntSet(file, "Combustivel", 100);
format(string, sizeof(string), "* Pronto, tanque cheio foram colocados %d litros.", quantia);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerGrana(playerid, - quantia);
return 1;
}
}else{
SendClientMessage(playerid, Vermelho, "** Vocк nгo estб no posto.");
return 1;
}
}
Para tirar alguma duvida sobre o cуdigo adicionado olhe aqui > https://sampwiki.blast.hk/wiki/IsPlayerInAnyVehicle_PT


Re: Comando /Abastecer Bugado - DwarD - 10.11.2014

deu um monte de erro totais 26 erros acho q pode ser string


Re: Comando /Abastecer Bugado - ReyMysterio - 10.11.2014

Dei uma organizada no seu cуdigo e coloquei uma verificaзгo para se o player estiver dirigindo o comando funcionar ( Se ele tiver de carona nгo funciona )

pawn Код:
if(strcmp(cmd, "/abastecer", true) == 0)
{
    new tmp[256];
    new aname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
    format(file, sizeof(file), PASTA_CONTAS, aname);
    new quantidade;
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, Vermelho, "** Uso: /abastecer [litros]");
        return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) //Verifca se estб a dirigir um veнculo
    {
        quantidade = strval(tmp);
        if(quantidade <= 0 || GetPlayerGrana(playerid) < quantidade)
        {
            SendClientMessage(playerid, Vermelho, "** Vocк nгo tem dinheiro suficiente para pagar o frentista.");
            return 1;
        }
        if(AreaPosto[playerid] == 1)
        {
            if(quantidade + dini_Int(file, "Combustivel") < 100)
            {
                dini_IntSet(file, "Combustivel", dini_Int(file, "Combustivel") + quantidade);
                format(string, sizeof(string), "* Vocк completou seu tanque com %d litros de combustнvel.", quantidade);
                SendClientMessage(playerid, COLOR_GREEN, string);
                GivePlayerGrana(playerid, - quantidade);
                return 1;
            }
            if(quantidade + dini_Int(file, "Combustivel"))
            {
                new quantia;
                quantia = 100 - dini_Int(file, "Combustivel");
                dini_IntSet(file, "Combustivel", 100);
                format(string, sizeof(string), "* Pronto, tanque cheio foram colocados %d litros.", quantia);
                SendClientMessage(playerid, COLOR_GREEN, string);
                GivePlayerGrana(playerid, - quantia);
                return 1;
            }
        }  
        else SendClientMessage(playerid, Vermelho, "** Vocк nгo estб no posto.");
        return 1;
    }
    else SendClientMessage(playerid, Vermelho, "Vocк nгo estб dirigindo um veнculo!");
    return 1;  
}



Re: Comando /Abastecer Bugado - Alwe - 10.11.2014

Quote:
Originally Posted by ReyMysterio
Посмотреть сообщение
Dei uma organizada no seu cуdigo e coloquei uma verificaзгo para se o player estiver dirigindo o comando funcionar ( Se ele tiver de carona nгo funciona )

pawn Код:
if(strcmp(cmd, "/abastecer", true) == 0)
{
    new tmp[256];
    new aname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, aname, MAX_PLAYER_NAME);
    format(file, sizeof(file), PASTA_CONTAS, aname);
    new quantidade;
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,sizeof(pName));
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, Vermelho, "** Uso: /abastecer [litros]");
        return 1;
    }
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        quantidade = strval(tmp);
        if(quantidade <= 0 || GetPlayerGrana(playerid) < quantidade)
        {
            SendClientMessage(playerid, Vermelho, "** Vocк nгo tem dinheiro suficiente para pagar o frentista.");
            return 1;
        }
        if(AreaPosto[playerid] == 1)
        {
            if(quantidade + dini_Int(file, "Combustivel") < 100)
            {
                dini_IntSet(file, "Combustivel", dini_Int(file, "Combustivel") + quantidade);
                format(string, sizeof(string), "* Vocк completou seu tanque com %d litros de combustнvel.", quantidade);
                SendClientMessage(playerid, COLOR_GREEN, string);
                GivePlayerGrana(playerid, - quantidade);
                return 1;
            }
            if(quantidade + dini_Int(file, "Combustivel"))
            {
                new quantia;
                quantia = 100 - dini_Int(file, "Combustivel");
                dini_IntSet(file, "Combustivel", 100);
                format(string, sizeof(string), "* Pronto, tanque cheio foram colocados %d litros.", quantia);
                SendClientMessage(playerid, COLOR_GREEN, string);
                GivePlayerGrana(playerid, - quantia);
                return 1;
            }
        }  
        else SendClientMessage(playerid, Vermelho, "** Vocк nгo estб no posto.");
        return 1;
    }
    else SendClientMessage(playerid, Vermelho, "Vocк nгo estб dirigindo um veнculo!");
    return 1;  
}
Rey, sua intensгo foi boa em endentar o cуdigo, mais creio que a GM dele nгo й endentada e nгo deve dar Warnings ! E de repente colocar um cуdigo tabulado pode dar Warnings, * Eu acho *


Re: Comando /Abastecer Bugado - DwarD - 10.11.2014

Mano Como Copio Pawn Code Meu Deus! Aqui Sai tudo Em Uma Sу Linha


Re: Comando /Abastecer Bugado - Alwe - 10.11.2014

Nгo se acostuma que nem todo mundo vai hospedar cуdigo pra vocк.. ¬¬
http://pastebin.com/is9KNinK


Re: Comando /Abastecer Bugado - ReyMysterio - 10.11.2014

Quote:
Originally Posted by Alwe
Посмотреть сообщение
Rey, sua intensгo foi boa em endentar o cуdigo, mais creio que a GM dele nгo й endentada e nгo deve dar Warnings ! E de repente colocar um cуdigo tabulado pode dar Warnings, * Eu acho *
Isso sу acontecerнa se o primeiro if nгo estiver endentado porque os outros if's vocк coloca como quiser.


Re: Comando /Abastecer Bugado - DwarD - 10.11.2014

26 erros Que Deu Aqui Fiz Tudo Certin E Refiz E Deu A Mesma Coisa


Re: Comando /Abastecer Bugado - ReyMysterio - 10.11.2014

Quote:
Originally Posted by DwarD
Посмотреть сообщение
26 erros Que Deu Aqui Fiz Tudo Certin E Refiz E Deu A Mesma Coisa
Jб tentou colocar o meu cуdigo ?