30/09/2020 00:22
Comando de destranca e tranca o veiculo mesmo não estando dentro dele apenas do lado!
Código:
CMD:trancar(playerid, params[])
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
new testcar;
if(sscanf(params, "d", testcar))
{
new counter = 0;
new result;
for(new i; i != MAX_VEHICLES; i++)
{
new dist = ChecarveiculoSamp(5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, vermelho, "[Samp]{FFFFFF}Nao ha nenhum carro perto de voce!");
}
case 1:
{
GetVehicleParamsEx(result, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(result, engine, lights, alarm, VEHICLE_PARAMS_ON, bonnet, boot, objective);
SendClientMessage(playerid, -1, "[Veiculo]{33CC33}Trancado");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
}
default:
{
SendClientMessage(playerid, vermelho, "[Samp]{FFFFFF}Foram encontrados mais de um carro nesse local");
}
}
return true;
}
return 1;
}
CMD:destrancar(playerid, params[])
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
new testcar;
if(sscanf(params, "d", testcar))
{
new counter = 0;
new result;
for(new i; i != MAX_VEHICLES; i++)
{
new dist = ChecarveiculoSamp(5, playerid, i);
if(dist)
{
result = i;
counter++;
}
}
switch(counter)
{
case 0:
{
SendClientMessage(playerid, vermelho, "[Samp]{FFFFFF}Nao ha nenhum carro perto de voce!");
}
case 1:
{
GetVehicleParamsEx(result, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(result, engine, lights, alarm, VEHICLE_PARAMS_OFF, bonnet, boot, objective);
SendClientMessage(playerid, -1, "[Veiculo]{FF0000}Destrancado");
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
PlayerPlaySound(playerid,1056,pX,pY,pZ);
}
default:
{
SendClientMessage(playerid, vermelho, "[Samp]{FFFFFF}Foram encontrados mais de um carro nesse local");
}
}
return true;
}
return 1;
}
stock ChecarveiculoSamp(Float:radi, playerid, vehicleid)
{
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, radi, x, y, z))
return 1;
return 0;
}
[url=https://portalsamp.com/search.php?action=finduser&uid=37][/url]
Peguei o codigo da gm do meu servidor.