Can't get this to work for the life of me
#1

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...
PHP код:
CMD:towcar(playeridparams[])
{
    new 
vehicleid;
    if (
sscanf(params"d"vehicleid))
        return 
SendSyntaxMessage(playerid"/towcar [id]");
    if (!
Car_IsOwner(playeridvehicleid))
        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;

And here is the Car_IsOwner function...
PHP код:
Car_IsOwner(playeridcarid)
{
    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;

Car_IsOwner is used in other commands without issue, for example...
PHP код:
CMD:uselock(playeridparams[])
{
    new 
id Car_GetID(GetPlayerVehicleID(playerid));
    if (!
IsEngineVehicle(id))
        return 
SendErrorMessage(playerid"You cannot use an Advanced Lock on this vehicle.");
    if (!
Car_IsOwner(playeridid))
        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;

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.
Reply


Messages In This Thread
Can't get this to work for the life of me - by Luke_James - 22.08.2015, 18:22
Re: Can't get this to work for the life of me - by thaKing - 22.08.2015, 18:28
Re: Can't get this to work for the life of me - by Luke_James - 22.08.2015, 18:32
Re: Can't get this to work for the life of me - by thaKing - 22.08.2015, 18:50
Re: Can't get this to work for the life of me - by Bingo - 22.08.2015, 18:56
Re: Can't get this to work for the life of me - by thaKing - 22.08.2015, 19:04
Re: Can't get this to work for the life of me - by Luke_James - 22.08.2015, 19:51
Re: Can't get this to work for the life of me - by Luke_James - 22.08.2015, 19:53

Forum Jump:


Users browsing this thread: 1 Guest(s)