carro[playerid] = CreateVehicle(carid[playerid], carpos[playerid][0], carpos[playerid][1], carpos[playerid][2], carpos[playerid][3], 0, 1, 0);
// DP LS CreateVehicle(523,1586.3691,-1671.4324,5.6137,272.5536,0,1,300); // moto 1 [41]
CMD:rcar(playerid) { if(admin[playerid] < 6) return 0; new string[128]; new counter = 0; new result; new plyName[MAX_PLAYER_NAME]; GetPlayerName(playerid, plyName, MAX_PLAYER_NAME); for(new i; i != MAX_VEHICLES; i++) { new dist = Checarveiculoportamala(5, playerid, i); if(dist) { result = i; counter++; } } switch(counter) { case 0: { SendClientMessage(playerid, COLOR_GREY, " Nгo hб nenhum carro nesse raio!"); } case 1: { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "Vocк reparou o carro ID:[%d]", result); SendClientMessage(playerid, COLOR_GREY, string); format(string, sizeof(string), "AdmAviso: Carro ID:[%d] foi reparado Por: %s", result, name); ABroadCast(COLOR_YELLOW,string,1); RepairVehicle(result); } default: { SendClientMessage(playerid, COLOR_GREY, " Foram encontrados mais de um carro nesse raio"); } } return 1; }
entгo esse comando sу estб funcionando com os carros que sгo criados ao iniciar o server....
os que criam dps que inicia nгo estб funcionando!? |
Qual o objetivo deste comando? Reparar veнculos prуximos ou um determinado veнculo?
|
CMD:rcar(playerid) {
if(admin[playerid] < 6) return 0;
new string[68], counter, result, plyName[MAX_PLAYER_NAME];
GetPlayerName(playerid, plyName, MAX_PLAYER_NAME);
for(new i; i != MAX_VEHICLES; i++) {
if(Checarveiculoportamala(5, playerid, i)) result = i, counter++;
//DEBUG - printf("%i", Checarveiculoportamala(5, playerid, i));
}
switch(counter)
{
case 0: SendClientMessage(playerid, COLOR_GREY, " Nгo hб nenhum carro nesse raio!");
case 1:
{
format(string, 68, "Vocк reparou o carro ID:[%d]", result);
SendClientMessage(playerid, COLOR_GREY, string);
format(string, 68, "AdmAviso: Carro ID:[%d] foi reparado Por: %s", result, plyName);
ABroadCast(COLOR_YELLOW,string,1);
RepairVehicle(result);
}
default: SendClientMessage(playerid, COLOR_GREY, " Foram encontrados mais de um carro nesse raio");
}
return 1;
}
stock Checarveiculoportamala(Float:radi, playerid, vehicleid) { if(IsPlayerConnected(playerid)) { new Float:PX,Float:PY,Float:PZ,Float:X,Float:Y,Float:Z; GetPlayerPos(playerid,PX,PY,PZ); GetVehiclePos(vehicleid, X,Y,Z); new Float:Distance = (X-PX)*(X-PX)+(Y-PY)*(Y-PY)+(Z-PZ)*(Z-PZ); if(Distance <= radi*radi) { return 1; } } return 0; }
stock Checarveiculoportamala(Float:radi, playerid, vehicleid)
{
if(IsPlayerConnected(playerid)) {
new Float: X, Float: Y, Float: Z;
GetVehiclePos(vehicleid, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, radi, X, Y, Z)) return 1;
}
return 0;
}
Tenta dessa forma:
PHP код:
Testei aqui e funcionou perfeitamente. |