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;
}
|
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?
|
...
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);
}
...