#include <a_samp>
public OnFilterScriptInit() {
return 1;
}
public OnFilterScriptExit() {
return 1;
}
main() { }
public OnPlayerCommandText(playerid, cmdtext[])
{
new idx, cmd[3][32];
cmd[0] = strtok(cmdtext, idx);
if(!strcmp(cmd[0], \"/szerel\", true))
{
cmd[1] = strtok(cmdtext, idx);
if(!strlen(cmd[1]))
{
SendClientMessage(playerid, -1, \"Használat: /szerel [motor/karosszéria]\");
return 1;
}
if(!strcmp(cmd[1], \"motor\", true)) {
SetVehicleHealth(GetClosestVehicle(playerid),1000.0);
SendClientMessage(playerid, -1, \"Megszerelted a motort!\");
}
if(!strcmp(cmd[1], \"karosszéria\", true)) {
RepairVehicle(GetClosestVehicle(playerid));
SendClientMessage(playerid, -1, \"Megszerelted a karosszériát!\");
}
return 1;
}
return 0;
}
stock GetClosestVehicle(playerid) // készítő: Gamestar
{
new iMax = INVALID_VEHICLE_ID, Float:dis, Float:dMax = float(10000), Float:PlayerPos[3], Float:VehiclePos[3];
GetPlayerPos(playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
for(new x = 0; x < MAX_VEHICLES; x++)
{
GetVehiclePos(x, VehiclePos[0], VehiclePos[1], VehiclePos[2]);
for(new j = 0; j < 3; j++) PlayerPos[j] -= VehiclePos[j];
dis = floatsqroot(((PlayerPos[0]*PlayerPos[0])+(PlayerPos[1]*PlayerPos[1])+(PlayerPos[2]*PlayerPos[2])));
if(dis < dMax)
{
dMax = dis,
iMax = x;
}
}
return iMax;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= \' \')) {
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > \' \') && ((index - offset) < (sizeof(result) - 1))) {
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}