09.12.2012, 14:14
(
Последний раз редактировалось ben1; 09.12.2012 в 15:02.
)
Hi,
Below is the code i am using to impound vehicles (Just simply change the spawn location of the vehicle to inside the impound lot once it has been towed)
The problem i am having is that when i use the /impound command from inside the impound and when i am near to the vehicle i receive the 'not near vehicle' error followed by 'SERVER: Unknown command.'
I have put some comments into the code to help indicate what a couple of bits are (although should be easy to understand anyway)
Any ideas?
Thank you in advance!
Below is the code i am using to impound vehicles (Just simply change the spawn location of the vehicle to inside the impound lot once it has been towed)
The problem i am having is that when i use the /impound command from inside the impound and when i am near to the vehicle i receive the 'not near vehicle' error followed by 'SERVER: Unknown command.'
I have put some comments into the code to help indicate what a couple of bits are (although should be easy to understand anyway)
Any ideas?
Thank you in advance!
pawn Код:
if(strcmp(cmd, "/impound", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /impound VehicleID");
SendClientMessage(playerid, COLOR_WHITE, "HINT: use /dl to see the vehicle ID");
return 1;
}
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] == 1) //Is a cop
{
new car = strval(tmp);
// if(IsPlayerInArea(1672.6168, -1720.5670,1643.3774, -1691.1042)) // More accurate inside impound (Why doesn't it work?)
if(PlayerToPoint(20, playerid, 1657.9971,-1705.8356)) // Is Inside Impound
{
if(PlayerToPoint(10, playerid, GetVehiclePos(car))) //Is near to vehicle
{
new Float:x,Float:y,Float:z;
new Float:a;
GetVehiclePos(car, x, y, z);
GetVehicleZAngle(car, a);
DynamicCars[car][CarX] = x;
DynamicCars[car][CarY] = y;
DynamicCars[car][CarZ] = z;
DynamicCars[car][CarAngle] = a;
DestroyVehicle(car);
CreateVehicle(DynamicCars[car][CarModel],DynamicCars[car][CarX],DynamicCars[car][CarY],DynamicCars[car][CarZ],DynamicCars[car][CarAngle],DynamicCars[car][CarColor1],DynamicCars[car][CarColor2], -1);
SaveDynamicCars();
SendClientMessage(playerid, COLOR_WHITE, "Vehicle Impounded.");
}
else //Not near car
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are too far from this vehicle to impound it!.");
}
}
else //Not in impound
{
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not in the impound lot!.");
}
}
else //Not a cop
{
SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not a cop!");
}
}
return 1;
}