30.10.2014, 21:56
Hey all,
I'm trying to make a command that will allow the user to lock/unlock their vehicle within a small radius of the car they own but i'm having trouble getting the radius to work, the player can lock/unlock their vehicle when they are sat inside it, but not outside, here's the code I have right now:
Any help with this would be greatly appreciated!
I'm trying to make a command that will allow the user to lock/unlock their vehicle within a small radius of the car they own but i'm having trouble getting the radius to work, the player can lock/unlock their vehicle when they are sat inside it, but not outside, here's the code I have right now:
Код:
command(lock, playerid, params[])
{
new Float:cX, Float:cY, Float:cZ;
new vehicleid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehicleid, cX, cY, cZ);
new string[128];
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
if(IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
{
if(doors == 1)
{
doors = 1;
SetVehicleParamsEx(vehicleid,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
format(string, sizeof(string), "{9d21ad}* %s unlocks the vehicle.", GetName(playerid));
NearByMessage(playerid, NICESKY, string);
return 1;
}
else
{
doors = 0;
SetVehicleParamsEx(vehicleid,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
format(string, sizeof(string), "{9d21ad}* %s locks the vehicle.", GetName(playerid));
NearByMessage(playerid, NICESKY, string);
return 1;
}
}
else if(!IsPlayerInRangeOfPoint(playerid, 4, cX, cY, cZ))
{
SendClientMessage(playerid, WHITE, "You are not near a vehicle!");
return 1;
}
return doors;
}


