18.04.2017, 01:13
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. "
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;
}


