CMD:towcar(playerid, params[])
{
new vehicleid;
if (sscanf(params, "d", vehicleid))
return SendSyntaxMessage(playerid, "/towcar [id]");
if (!Car_IsOwner(playerid, vehicleid))
return SendErrorMessage(playerid, "You cannot respawn a car that you do not own.");
RespawnVehicle(vehicleid);
SendServerMessage(playerid, "You have respawned your vehicle [ID: %d].", vehicleid);
GiveMoney(playerid, -500);
return 1;
}
Car_IsOwner(playerid, carid)
{
if (!PlayerData[playerid][pLogged] || PlayerData[playerid][pID] == -1)
return 0;
if ((CarData[carid][carExists] && CarData[carid][carOwner] != 0) && CarData[carid][carOwner] == PlayerData[playerid][pID])
return 1;
return 0;
}
CMD:uselock(playerid, params[])
{
new id = Car_GetID(GetPlayerVehicleID(playerid));
if (!IsEngineVehicle(id))
return SendErrorMessage(playerid, "You cannot use an Advanced Lock on this vehicle.");
if (!Car_IsOwner(playerid, id))
return SendErrorMessage(playerid, "You do not own this vehicle.");
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
return SendErrorMessage(playerid, "You can't do this as you're not the driver.");
if (CarData[id][carLockType] == 1)
return SendErrorMessage(playerid, "This vehicle is already fitted with an Advanced Lock.");
if (!Inventory_HasItem(playerid, "Advanced Lock"))
return SendErrorMessage(playerid, "You do not have an Advanced Lock.");
SendServerMessage(playerid, "You have used an Advanced Lock on your %s.", ReturnVehicleModelName(CarData[id][carModel]));
Inventory_Remove(playerid, "Advanced Lock");
CarData[id][carLockType] = 1;
Car_Save(id);
return 1;
}
SetVehicleToRespawn(vehicleid);
CMD:towcar(playerid, params[])
{
new vehicleid;
if (sscanf(params, "d", vehicleid))
return SendSyntaxMessage(playerid, "/towcar [veh]");
if (vehicleid < 1 || vehicleid > MAX_VEHICLES || !IsValidVehicle(vehicleid))
return SendErrorMessage(playerid, "You have specified an invalid vehicle ID.");
if (Car_IsOwner(playerid, vehicleid)) {
RespawnVehicle(vehicleid);
Car_Save(vehicleid);
SendServerMessage(playerid, "You have respawned vehicle ID: %d.", vehicleid);
GiveMoney(playerid, -500);
} else {
SendErrorMessage(playerid, "You cannot respawn a car that you do not own.");
}
return 1;
}
new id = Car_GetID(GetPlayerVehicleID(playerid)); |
You are not getting the vehicle's ID dude you just defined it.
Look at /uselock you'll see on top new id= and so on. |
CMD:towcar(playerid, params[])
{
new vehicleid;
if (sscanf(params, "d", vehicleid))
return SendSyntaxMessage(playerid, "/towcar [veh]");
if (vehicleid < 1 || vehicleid > MAX_VEHICLES || !IsValidVehicle(vehicleid))
return SendErrorMessage(playerid, "You have specified an invalid vehicle ID.");
id = Car_GetID(vehicleid);
if (Car_IsOwner(playerid, id)) {
RespawnVehicle(id);
Car_Save(id);
SendServerMessage(playerid, "You have respawned vehicle ID: %d.", id);
GiveMoney(playerid, -500);
} else {
SendErrorMessage(playerid, "You cannot respawn a car that you do not own.");
}
return 1;
}
You are not getting the vehicle's ID dude you just defined it.
Look at /uselock you'll see on top new id= and so on. EDIT* Chnage id to vehicleid and add it on top of your tow command and make sure to read the full command, I am on tablet sorry. |
And what about sscanf?
Like cmd gives the vehicle's id. /towcar [VEHICLEID], so, command works with id that's given. And you probably right. ------- Probably cmd won't work, because you have static vehicles too, like police n shit, well, I guess when you enter car's id, you entered the id of mysql cars list. Try: PHP код:
|