[Ajuda] OnPlayerStateChange
#1

Boa tarde. Estou com um problema em um sistema de Veнculos. Bom o problema й q qualquer um pode pegar o carro, q identifica como dono de todos os carros, eu quero q quando alguem player entra em um carro q n й seu, aparece a mensagem, este veнculo estб trancado, e voce n consiguira dirigir, e aparecer para o dono do carro, q o veнculo estб sendo roubado
sу q n estб indo a mensagem, e identifica como " Bem vindo ao seu veнculo. "



Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
    {


    	if(IsPlayerNPC(playerid)) return 1;

     	CarSpam[playerid]++;
     	SetTimerEx("SairCarSpam",1000,0,"i",playerid);

    	new vehicleid,
    	    string[256],
      tmp[256],
    		tmpx[256];

    	vehicleid = GetPlayerVehicleID(playerid);

    	if(newstate == PLAYER_STATE_ONFOOT) RemovePlayerSET(playerid);

    	if(oldstate == PLAYER_STATE_ONFOOT)
    	{
    	    if(PortaArmas[playerid] == 2)
    	    {
    			RemovePlayerAttachedObject(playerid, 1);
    			OldWeapon[playerid] = 0;
    			HoldingWeapon[playerid] = 0;
    		}
    	}



    	if(newstate == PLAYER_STATE_PASSENGER)
    	{
    		for(new V = 0; V < TOTALSETS; V ++)
    		{
    		    if(vehicleid == VeiculoSET[V])
    		    {
    		        tmp = dini_Get(VeiculosFile(V), "Dono");

    		        if(strcmp(tmpx, tmp, true) == 0)
    				{
    				    format(string, sizeof(string), "[INFO] Bem vindo(a) ao seu veнculo '%s', %s", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    		        	SendClientMessage(playerid, COR_ORKUT, string);
    				}
    				else
    				{
    		        	format(string, sizeof(string), "[INFO] Bem vindo(a) ao veнculo '%s' de %s!", dini_Get(VeiculosFile(V), "NomeVeiculo"), dini_Get(VeiculosFile(V),"Dono"));
    		        	SendClientMessage(playerid, COR_ORKUT, string);
    				}
    		    }
    		}
    	}

    	if(newstate == PLAYER_STATE_DRIVER)
    	{

    			for(new V = 0; V < TOTALSETS; V ++)
    			{
    			    if(vehicleid == VeiculoSET[V])
    			    {

                        tmp = dini_Get(VeiculosFile(V), "Dono");


            			new APr = dini_Int(VeiculosFile(V), "Apreendido");
    	 		    	new engine, lights, alarm, doors, bonnet, boot, objective;
    				    GetVehicleParamsEx(VeiculoSET[V], engine, lights, alarm, doors, bonnet, boot, objective);
    				    SetVehicleParamsEx(VeiculoSET[V], engine, lights, alarm, doors, bonnet, boot, 0);
    		        	if(APr != -1)
    		        	{
    	    		    	format(string, sizeof(string), "[ERRO] Esse SET '%s' estб apreendido e nгo pode ser usado!", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    			        	SendClientMessage(playerid, CORX1, string);
    			        	RemovePlayerFromVehicleEx(playerid);
    			        	SetVehicleToRespawn(VeiculoSET[V]);
    			        	return 1;
    		        	}
    			        if(strcmp(tmpx, tmp, true) == 0)
    					{
    					    format(string, sizeof(string), "[INFO] Bem vindo(a) ao seu veнculo prуprio '%s', %s", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    			        	SendClientMessage(playerid, COR_ORKUT, string);
        	}
    					else
    					{
          if(dini_Int(VeiculosFile(V),"Alarme") == 1)
    						{
    		    				foreach (Player, P)
    							{
    			    				if(IsPlayerConnected(P))
    								{
    				    				if(GetDistanceBetweenPlayers(playerid,P) <= 30)
    								    {
    								    	PlayerPlaySound(P, 1147, 0 , 0 , 0);
    									}
                tmp = dini_Get(VeiculosFile(V), "Dono");
                                        tmpx = dini_Get(VeiculosFile(V), "Dono");


    									if(strcmp(tmpx, tmp, true) == 0)
    									{
    				    					format(string, sizeof(string), "[INFO] Seu veнculo prуprio '%s' estб sendo roubado por '%s' !", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    			        					SendClientMessage(P, COR_ORKUT, string);
    			        					if(dini_Int(VeiculosFile(V),"VeiculoTrancado") == 1)
    			        					{
    				        					format(string, sizeof(string), "[INFO] Mas seu veнculo prуprio '%s' estб trancado, '%s' nгo poderб dirigн-lo!", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    				        					SendClientMessage(P, COR_ORKUT, string);
    			        					}
    									}
    								}
    							}
    						}
    		    		    format(string, sizeof(string), "[ERRO] Esse veнculo prуprio '%s' й de %s, vocк nгo pode dirigн-lo!", dini_Get(VeiculosFile(V), "NomeVeiculo"), dini_Get(VeiculosFile(V),"Dono"));
    			        	SendClientMessage(playerid, CORX1, string);
    			        	if(dini_Int(VeiculosFile(V),"VeiculoTrancado") == 0)
    	  					{
    	  					    new stringx[128];
    	  					    format(stringx, sizeof(stringx), "[INFO] Mas %s deixou seu veнculo prуprio '%s' aberto!", dini_Get(VeiculosFile(V),"Dono"), dini_Get(VeiculosFile(V), "NomeVeiculo"));
    	  					    SendClientMessage(playerid, COR_ORKUT, stringx);
    	  					}
    	 					else
    	  					{
    	  					    RemovePlayerFromVehicleEx(playerid);
    	  					    /*new Float:X, Float:Y, Float:Z;
    	  					    SetPlayerPos(playerid, X + 0.5, Y + 0.5, Z);*/
    	  					}
    					}
    			    }
    			}
    		}
    	  					    /*new Float:X, Float:Y, Float:Z;
    	  					    SetPlayerPos(playerid, X + 0.5, Y + 0.5, Z);*/



    	return 0;
    }
Reply
#2

e qualquer um consegue pegar o veнculo dai
Reply
#3

Faz um debug, verificando os valores usados no if, pra ver se tб tudo certo: nome do dono, id do veiculo, etc
Reply
#4

debug n adiantarб sу com um comando? O problema aqui, й q quando eu entro no carro, ele n identifica quem й o dono
Reply
#5

Quote:
Originally Posted by ViniBorn
Посмотреть сообщение
Faz um debug, verificando os valores usados no if, pra ver se tб tudo certo: nome do dono, id do veiculo, etc
olб, sei q n tem haver com o tуpico oque eu vou perguntar, mas pra mim nгo criar outro tуpico, tb sei q n sou o autor desse tуpico mas vou perguntar, como se cria uma debug?
Reply
#6

Quote:
Originally Posted by Scorpion659
Посмотреть сообщение
olб, sei q n tem haver com o tуpico oque eu vou perguntar, mas pra mim nгo criar outro tуpico, tb sei q n sou o autor desse tуpico mas vou perguntar, como se cria uma debug?
Pergunto o msm.
Reply
#7

Pra fazer um debug simples que vocк sу vai usar pra encontrar o bug que estб dando naquele momento, vocк pode usar print/printf em certos trechos do cуdigo pra ver se chega atй aquele printf e se os valores das variбveis estгo certos.
Reply
#8

pode montar esse cуdigo meu, com debug? pra eu fazer
Reply
#9

obs, n sou o freegells, ele me emprestou a conta pra arrumar esse erro.
Reply
#10

Sу um exemplo
Код:
...
printf("vehid: %d", vehicleid"); //mostrando o vehicleid
if(newstate == PLAYER_STATE_DRIVER)
    	{

    			for(new V = 0; V < TOTALSETS; V ++)
    			{
    			    if(vehicleid == VeiculoSET[V])
    			    {

                        tmp = dini_Get(VeiculosFile(V), "Dono");
                        printf("VeiculoSET[%d]: %d | dono: %s", V, VeiculoSET[V], tmp); //mostrar os dados do veiculo

            			new APr = dini_Int(VeiculosFile(V), "Apreendido");
    	 		    	new engine, lights, alarm, doors, bonnet, boot, objective;
    				    GetVehicleParamsEx(VeiculoSET[V], engine, lights, alarm, doors, bonnet, boot, objective);
    				    SetVehicleParamsEx(VeiculoSET[V], engine, lights, alarm, doors, bonnet, boot, 0);
    		        	if(APr != -1)
    		        	{
    	    		    	format(string, sizeof(string), "[ERRO] Esse SET '%s' estб apreendido e nгo pode ser usado!", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    			        	SendClientMessage(playerid, CORX1, string);
    			        	RemovePlayerFromVehicleEx(playerid);
    			        	SetVehicleToRespawn(VeiculoSET[V]);
    			        	return 1;
    		        	}
    			        if(strcmp(tmpx, tmp, true) == 0)
    					{
    					    format(string, sizeof(string), "[INFO] Bem vindo(a) ao seu veнculo prуprio '%s', %s", dini_Get(VeiculosFile(V), "NomeVeiculo"));
    			        	SendClientMessage(playerid, COR_ORKUT, string);
        	}
...
Percebi que vocк compara as strings de dono do veнculo com uma string "tmpx", mas vocк nгo atribuiu nenhuma valor a ela...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)