24.12.2010, 14:06
So i have this stock thing in my script
and then i have this for the onplayerstatechange:
how could i make a command like /lock that will get nearest vehicle and using the onplayerstatechange info
lock the car if it is close enough to the player wit a rados of 5.0?
and to lock the car use this:
SetVehicleParamsEx(the_id,engine,lights,alarm,VEHI CLE_PARAMS_OFF,bonnet,boot,objective);
and if they not close enough, it will send a message saying they is not
thank and sorry for my bad english
Код:
stock GetNearestVehicle(playerid, Float:Distance = 1000.0) { if(!Distance) Distance = 1000.0; new Float:X[2], Float:Y[2], Float:Z[2], Float:NearestPos = floatabs(Distance), NearestVehicle = INVALID_VEHICLE_ID; GetPlayerPos(playerid, X[0], Y[0], Z[0]); for(new i; i<MAX_VEHICLES; i++) { if(!IsVehicleStreamedIn(i, playerid) || IsPlayerInVehicle(playerid, i)) continue; GetVehiclePos(i, X[1], Y[1], Z[1]); if(NearestPos > GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1])) NearestPos = GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]), NearestVehicle = i; } return NearestVehicle; }
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
for(new i = 0; i < MAX_VEHS; i++)
{
if(GetPlayerVehicleID(playerid) == Cars[i])
{
new veh[5], get_veh[128];
format(veh, sizeof(veh), "%d", i);
format(get_veh, sizeof(get_veh), "%s", dini_Get("vehicles.ini", veh));
new pos = strfind(get_veh, " ", true);
strdel(get_veh, pos, pos + strlen(get_veh));
if(strcmp(pname, get_veh, true) == 0)
{
SendClientMessage(playerid, yellow, "Welcome to your car");
}
else
{
SendClientMessage(playerid, red, "This is not your vehicle");
RemovePlayerFromVehicle(playerid);
}
}
}
}
lock the car if it is close enough to the player wit a rados of 5.0?
and to lock the car use this:
SetVehicleParamsEx(the_id,engine,lights,alarm,VEHI CLE_PARAMS_OFF,bonnet,boot,objective);
and if they not close enough, it will send a message saying they is not
thank and sorry for my bad english