SA-MP Forums Archive
[Ajuda] Algo de 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] Algo de errado ? (/showthread.php?tid=606033)



Algo de errado ? - Lucas_Rocha - 28.04.2016

Galera tem algo errado com esse codigo ? quando eu digito o gta crasha nгo acontece apenas comigo mais com geral q tenta abastecer

Codigo :
pawn Код:
if(strcmp(cmd, "/abastecer", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
        if(!IsPlayerInAnyVehicle(playerid))
                return SendClientMessage(playerid,COLOR_RED,"   Vocк nгo estб em um veнculo!");

        new vid = GetPlayerVehicleID(playerid);
        if(Gas[vid] >= 100)
                return SendClientMessage(playerid,COLOR_RED,"POSTO: O tanque jб estб cheio.");

            if(IsAtGasStation(playerid))
            {
                GameTextForPlayer(playerid,"~g~B~y~S~b~G~n~~w~Reabastecendo, Aguarde...~",3000,3);
                SetTimer("Fillup",RefuelWait,0);
                Controle(playerid, 0);
                Refueling[playerid] = 1;
            }
            else
            {
                SendClientMessage(playerid,COLOR_GREY,"   Vocк nгo estб em um Posto de Gasolina");
            }
        }
        return true;
    }
Sу crasha quando aperta H :

pawn Код:
if((newkeys == KEY_HORN) && (IsPlayerInAnyVehicle(playerid)))
    {
        if(IsAtGasStation(playerid))
        {
            OnPlayerCommandText(playerid,"/abastecer");
        }
    }

vlw




Re: Algo de errado ? - F1N4L - 28.04.2016

Код:
if(newkeys == KEY_HORN && IsPlayerInAnyVehicle(playerid))
	{
	    if(IsAtGasStation(playerid))
	    {
            OnPlayerCommandText(playerid,"/abastecer");
		}
	}
@EDIT

MANDA A STOCK IsAtGasStation


Re: Algo de errado ? - zPain - 28.04.2016

Quote:
Originally Posted by Lucas_Rocha
Посмотреть сообщение
quando eu digito o gta crasha
Quote:
Originally Posted by Lucas_Rocha
Посмотреть сообщение
Sу crasha quando aperta H
Afinal, em que caso o crash ocorre?

Se ocorre apenas quando vocк aperta a tecla H, o problema estб em OnPlayerKeyStateChange.
Se ocorre apenas quando vocк digita o comando, entгo o problema estб no comando.

De qualquer forma, o ideal й que vocк poste todo o conteъdo de OnPlayerKeyStateChange.


Respuesta: Re: Algo de errado ? - Lucas_Rocha - 28.04.2016

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Код:
if(newkeys == KEY_HORN && IsPlayerInAnyVehicle(playerid))
	{
	    if(IsAtGasStation(playerid))
	    {
            OnPlayerCommandText(playerid,"/abastecer");
		}
	}
@EDIT

MANDA A STOCK IsAtGasStation
olha ela ai

pawn Код:
public IsAtGasStation(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerToPoint(15.0,playerid,1941.9850,-1774.6639,19.7006))
        {
            if(IsAPlane(GetPlayerVehicleID(playerid)))
            {
                return true;
            }
        }
        if(PlayerToPoint(6.0,playerid,1004.0070,-939.3102,42.1797) || PlayerToPoint(6.0,playerid,1944.3260,-1772.9254,13.3906) || PlayerToPoint(6.0,playerid,1400.6882,-1680.5344,42.4339) || PlayerToPoint(6.0,playerid,1496.5316,-1544.0677,23.5481) || PlayerToPoint(6.0,playerid,2737.3364,-1774.2123,43.7973))
        {//LS
            return true;
        }
        else if(PlayerToPoint(6.0,playerid,-90.5515,-1169.4578,2.4079) || PlayerToPoint(6.0,playerid,-1609.7958,-2718.2048,48.5391))
        {//LS
            return true;
        }
        else if(PlayerToPoint(6.0,playerid,-2029.4968,156.4366,28.9498) || PlayerToPoint(8.0,playerid,-2408.7590,976.0934,45.4175))
        {//SF
            return true;
        }
        else if(PlayerToPoint(6.0,playerid,1380.4712,462.7467,20.1107) || PlayerToPoint(8.0,playerid,1385.0475,460.5417,20.1068))
        {//PC
            return true;
        }
        else if(PlayerToPoint(6.0,playerid,1383.5532,457.1286,19.9561) || PlayerToPoint(8.0,playerid,1379.1952,459.1295,19.9587))
        {//PC
            return true;
        }
        else if(PlayerToPoint(5.0,playerid,-2243.9629,-2560.6477,31.8841) || PlayerToPoint(8.0,playerid,-1676.6323,414.0262,6.9484))
        {//Between LS and SF
            return true;
        }
        else if(PlayerToPoint(6.0,playerid,2202.2349,2474.3494,10.5258) || PlayerToPoint(10.0,playerid,614.9333,1689.7418,6.6968))
        {//LV
            return true;
        }
        else if(PlayerToPoint(8.0,playerid,-1328.8250,2677.2173,49.7665) || PlayerToPoint(6.0,playerid,70.3882,1218.6783,18.5165))
        {//LV
            return true;
        }
        else if(PlayerToPoint(8.0,playerid,677.1299,-2866.3892,13.0944) || PlayerToPoint(6.0,playerid,-1327.7218,2678.8723,50.0625))
        {//LV
            return true;
        }
    }
    return 0;
}



Re: Algo de errado ? - F1N4L - 28.04.2016

Faz um teste sem a callback IsAtGasStation. Se nгo crashar deve ser uma funзгo da callback dando algum conflito.

Код:
if(strcmp(cmd, "/abastecer", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
     	if(!IsPlayerInAnyVehicle(playerid))
	            return SendClientMessage(playerid,COLOR_RED,"   Vocк nгo estб em um veнculo!");

     	new vid = GetPlayerVehicleID(playerid);
      	if(Gas[vid] >= 100)
        		return SendClientMessage(playerid,COLOR_RED,"POSTO: O tanque jб estб cheio.");

			/*if(IsAtGasStation(playerid))
			{
			    GameTextForPlayer(playerid,"~g~B~y~S~b~G~n~~w~Reabastecendo, Aguarde...~",3000,3);
				SetTimer("Fillup",RefuelWait,0);
				Controle(playerid, 0);
				Refueling[playerid] = 1;
			}
			else
			{
				SendClientMessage(playerid,COLOR_GREY,"   Vocк nгo estб em um Posto de Gasolina");
			}*/
		}
    	return true;
	}



Re: Algo de errado ? - zPain - 28.04.2016

A seguinte linha estб causando o crash:

PHP код:
GameTextForPlayer(playerid,"~g~B~y~S~b~G~n~~w~Reabastecendo, Aguarde...~",3000,3); 
Remova o til (~) no fim da mensagem para solucionar o problema.

PHP код:
GameTextForPlayer(playerid,"~g~B~y~S~b~G~n~~w~Reabastecendo, Aguarde...",3000,3); 



Respuesta: Re: Algo de errado ? - Lucas_Rocha - 29.04.2016

Quote:
Originally Posted by zPain
Посмотреть сообщение
A seguinte linha estб causando o crash:

PHP код:
GameTextForPlayer(playerid,"~g~B~y~S~b~G~n~~w~Reabastecendo, Aguarde...~",3000,3); 
Remova o til (~) no fim da mensagem para solucionar o problema.

PHP код:
GameTextForPlayer(playerid,"~g~B~y~S~b~G~n~~w~Reabastecendo, Aguarde...",3000,3); 
Obrigado Mano й isso mesmo