31.12.2011, 19:12
I have created a command to unlock a vehicle. Here is what I got so far:
I am using y_iteratek (newest version) and the iterators are getting filled up properly. But after I use this command the server freezes. That means I can not use any commands, or restart the server (over the console). I guess that's because it has to loop through all vehicles (MAX_VEHICLES), but I don't really know how to do it, so that it works.
(And I am pretty sure that this command causes the error, since the server only freezes when using it)
pawn Код:
CMD:unlock(playerid,params[])
{
new Float:vx,Float:vy,Float:vz;
foreach(SpawnedVehicle,i)
{
GetVehiclePos(VehicleInfo[i][vID],vx,vy,vz);
if(IsPlayerInRangeOfPoint(playerid,4.0,vx,vy,vz))
{
if(VehicleInfo[i][vHasOwner] == true && strcmp(VehicleInfo[i][vOwner],PName(playerid),false) == 0)
{
if(VehicleInfo[i][vLocked] == 1)
{
VehicleInfo[i][vLocked] = 0;
SetVehicleParamsEx(VehicleInfo[i][vID],MotorOn[i],0,0,VehicleInfo[i][vLocked],0,0,0);
GameTextForPlayer(playerid,"~w~Vehicle: ~g~Unlocked",2500,3);
}else{
SendError(playerid,"This vehicle is already unlocked.");
}
}
}
}
return 1;
}
(And I am pretty sure that this command causes the error, since the server only freezes when using it)


