Der Befehl sieht momentan so aus:
COMMAND:carlock(playerid,params[])
{
new Float:CarPos[3],string[144];
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
{
for(new i;i<MAX_VEHICLES;i++)
{
for(new x;x<sizeof CarInfo;x++)
{
GetVehiclePos(i,CarPos[0],CarPos[1],CarPos[2]);
if(IsPlayerInRangeOfPoint(playerid,3,CarPos[0],CarPos[1],CarPos[2]))
{
if(CarInfo[x][c_ID] == i)
{
if(!strcmp(PlayerName[playerid],CarInfo[x][c_Owner],true))
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(!doors)
{
SetVehicleParamsEx(i,engine,lights,alarm,1,bonnet,boot,objective);
format(string,sizeof(string),"~w~%s ~r~abgeschlossen",GetVehicleName(i));
GameTextForPlayer(playerid,string,2000,4);
CarInfo[x][Locked]=1;
return 1;
}
else
{
SetVehicleParamsEx(i,engine,lights,alarm,0,bonnet,boot,objective);
format(string,sizeof(string),"~w~%s ~g~aufgeschlossen",GetVehicleName(i));
GameTextForPlayer(playerid,string,2000,4);
CarInfo[x][Locked]=0;
return 1;
}
}
}
}
}
}
}
else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
for(new i;i<MAX_VEHICLES;i++)
{
for(new x;x<sizeof CarInfo;x++)
{
if(CarInfo[x][c_ID] == i)
{
if(!strcmp(PlayerName[playerid],CarInfo[vehicleid][c_Owner],true))
{
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
if(!doors)
{
SetVehicleParamsEx(i,engine,lights,alarm,1,bonnet,boot,objective);
format(string,sizeof(string),"~w~%s ~r~abgeschlossen",GetVehicleName(vehicleid));
GameTextForPlayer(playerid,string,2000,4);
CarInfo[x][Locked]=1;
return 1;
}
else
{
SetVehicleParamsEx(i,engine,lights,alarm,0,bonnet,boot,objective);
format(string,sizeof(string),"~w~%s ~g~aufgeschlossen",GetVehicleName(vehicleid));
GameTextForPlayer(playerid,string,2000,4);
CarInfo[x][Locked]=0;
return 1;
}
}
}
}
}
}
return 1;
}
Die Abfrage habe ich geändert.