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; }
return doors -> return 1;
enum pInfo
{
pVehModel,
pVehicle
};
new PlayerData[MAX_PLAYERS][pInfo];
// under on player connect
if(PlayerData[playerid][pVehModel])
pVehicle = CreateVehicle(...);
// and in your command
GetVehiclePos(PlayeData[playerid][pVeh], x, y, z);
If(IsPlayerInRangeOfPoint(playerid, 4, x, y, z))
...
You need to finish your command with returning 1 if I'm right.
Код:
return doors -> return 1; |
EDIT:
Also, function GetPlayerVehicleID only work if player is in any vehicle. That's why your command is working only when the player is in the car. You need to create a vehicle when the player joins the server and then save vehicleid to your variable. For example: pawn Код:
|