22.08.2015, 18:22
I just don't see why this command does not work, as far as I can see it is completely correct and I see no reason why it should not work. When the player types /towcar and an ID of a vehicle he owns, it returns the error message "You cannot respawn a car you do not own." It does the same when you type in the ID of a vehicle you do not own.
Here is the command...
And here is the Car_IsOwner function...
Car_IsOwner is used in other commands without issue, for example...
It works fine in that command, you can only /uselock on a vehicle you own... so why not for the /towcar command?
I have also tried replacing "Car_IsOwner" with "CarData[carid][carOwner] != PlayerData[playerid][pID]" to no avail.
Here is the command...
PHP код:
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;
}
PHP код:
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;
}
PHP код:
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;
}
I have also tried replacing "Car_IsOwner" with "CarData[carid][carOwner] != PlayerData[playerid][pID]" to no avail.