07.10.2012, 08:04
I was trying to make a car hood and trunk command that make you be at the front of the car if its the hood and for the trunk the player has to be at the back. I also encounted a problem where when you do the command the hood and trunk does not pop up the client message comes but the cars hood and trunk stay closed.
]
Sorry I didn't know how to put the code t0 pawn
PHP код:
command(car, playerid, params[])
{
if(isnull(params))
{
SendClientMessage(playerid, WHITE, "SYTNAX: /car [usage]");
SendClientMessage(playerid, WHITE, "USAGES: hood, lights, trunk.");
}
else
{
new closestid = GetClosestCar(playerid, 5);
new vehicleid = GetPlayerVehicleID(playerid);
new Float:x, Float:y, Float:z;
new engine, lights, alarm, doors, bonnet, boot, objective;
new e, l, a, d, b, be, o;
new string[256];
GetVehicleParamsEx(closestid, e, l, a, d, b, be, o);
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
GetVehiclePos(vehicleid, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z-3))
{
if(strcmp(params, "hood", true) == 0)
{
if(Vehicles[closestid][Hood] == 0)
{
Vehicles[closestid][Hood] = 1;
format(string, 256, "* %s opens the hood of their vehicle.", GetName(playerid));
NearByMessage(playerid, PURPLE, string);
SetVehicleParamsEx(closestid, e, l, a, d, 1, be, o);
}
else if(Vehicles[closestid][Hood] == 1)
{
Vehicles[closestid][Hood] = 0;
format(string, 256, "* %s closes the hood of their vehicle.", GetName(playerid));
NearByMessage(playerid, PURPLE, string);
SetVehicleParamsEx(closestid, e, l, a, d, 0, be, o);
}
}
}
if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z+3))
{
if(strcmp(params, "trunk", true) == 0)
{
if(Vehicles[closestid][Trunk] == 0)
{
Vehicles[closestid][Trunk] = 1;
format(string, 256, "* %s extends his right arm towards the trunk, opening the trunk of their vehicle.", GetName(playerid));
NearByMessage(playerid, PURPLE, string);
SetVehicleParamsEx(closestid, e, l, a, d, b, 1, o);
}
else if(Vehicles[closestid][Trunk] == 1)
{
Vehicles[closestid][Trunk] = 0;
format(string, 256, "* %s closes the hood of their vehicle.", GetName(playerid));
NearByMessage(playerid, PURPLE, string);
SetVehicleParamsEx(closestid, e, l, a, d, b, 0, o);
}
}
}
}
Sorry I didn't know how to put the code t0 pawn