Cars don't lock when you do /lock
#1

When you do /lock, it says the vehicle is locked but you can still get in it..

pawn Код:
command(lock, playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You must be in a vehicle to use this command!");

    new
        VehicleID = GetPlayerVehicleID(playerid);
       
    if(OwnedCar(VehicleID) != 0)
    {
        if(strmatch(Vehicles[OwnedCar(VehicleID)][VehicleOwner], pName(playerid)))
        {
            Vehicles[OwnedCar(VehicleID)][vLocked] = 1;
           
            SendClientMessage(playerid, -1, "You've successfully locked your vehicle!");
           
            SaveOwnedCar(OwnedCar(VehicleID));
            return 1;
        }
        else return SendClientMessage(playerid, RED, "This vehicle does not belong to you!");
    }
    else return SendClientMessage(playerid, RED, "This is not a private vehicle!");
}
Reply
#2

You are forgetting to set them locked with SetVehicleParams
Reply
#3

pawn Код:
command(lock, playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You must be in a vehicle to use this command!");

    new
        VehicleID = GetPlayerVehicleID(playerid);
       
    if(OwnedCar(VehicleID) != 0)
    {
        if(strmatch(Vehicles[OwnedCar(VehicleID)][VehicleOwner], pName(playerid)))
        {
            Vehicles[OwnedCar(VehicleID)][vLocked] = 1;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
            SendClientMessage(playerid, -1, "You've successfully locked your vehicle!");
            SaveOwnedCar(OwnedCar(VehicleID));
            return 1;
        }
        else return SendClientMessage(playerid, RED, "This vehicle does not belong to you!");
    }
    else return SendClientMessage(playerid, RED, "This is not a private vehicle!");
}
Like this?

EDIT: On compiling it says gives the following errors;
Quote:

error 017: undefined symbol "vehicleid"
error 017: undefined symbol "vehicleid"

Reply
#4

You see, PAWN is case sensitive, so work it out yourself, of course you'd notice whats wrong if you use common sense..
Reply
#5

Actually, "vehicleid" is used elsewhere in my script, and it's lowercase.
Reply
#6

you should add this at the top of your script !!!!
pawn Код:
new vehicleid [ MAX_PLAYERS ];
pawn Код:
new vehicleid [ MAX_PLAYERS ];

command:(lock, playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You must be in a vehicle to use this command!");

    new
        VehicleID = GetPlayerVehicleID(playerid);
       
    if(OwnedCar(VehicleID) != 0)
    {
        if(strmatch(Vehicles[OwnedCar(VehicleID)][VehicleOwner], pName(playerid)))
        {
            Vehicles[OwnedCar(VehicleID)][vLocked] = 1;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
            SendClientMessage(playerid, -1, "You've successfully locked your vehicle!");
            SaveOwnedCar(OwnedCar(VehicleID));
            return 1;
        }
        else return SendClientMessage(playerid, RED, "This vehicle does not belong to you!");
    }
    else return SendClientMessage(playerid, RED, "This is not a private vehicle!");
}
TRy now with this !!!
Reply
#7

Quote:
Originally Posted by мυ∂υℓ_вacнα
Посмотреть сообщение
you should add this at the top of your script !!!!
pawn Код:
new vehicleid [ MAX_PLAYERS ];
pawn Код:
new vehicleid [ MAX_PLAYERS ];

command:(lock, playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You must be in a vehicle to use this command!");

    new
        VehicleID = GetPlayerVehicleID(playerid);
       
    if(OwnedCar(VehicleID) != 0)
    {
        if(strmatch(Vehicles[OwnedCar(VehicleID)][VehicleOwner], pName(playerid)))
        {
            Vehicles[OwnedCar(VehicleID)][vLocked] = 1;
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
            SendClientMessage(playerid, -1, "You've successfully locked your vehicle!");
            SaveOwnedCar(OwnedCar(VehicleID));
            return 1;
        }
        else return SendClientMessage(playerid, RED, "This vehicle does not belong to you!");
    }
    else return SendClientMessage(playerid, RED, "This is not a private vehicle!");
}
TRy now with this !!!
Oh my god,, so much fail. Don't ever try to fix your code like the way above, it will never work.

Luke: use the force! Seriously though, every variable is used differently. If you still can't tell global variables from local variables, then please refresh your coding course (also, PAWN is case sensitive as being told, that shouldve been enough of a hint).
Reply
#8

You have a spelling mistake.
Reply
#9

pawn Код:
command(lock, playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You must be in a vehicle to use this command!");
    new VehicleID = GetPlayerVehicleID(playerid);
    if(OwnedCar(VehicleID) != 0)
    {
        if(strmatch(Vehicles[OwnedCar(VehicleID)][VehicleOwner], pName(playerid)))
        {
            Vehicles[OwnedCar(VehicleID)][vLocked] = 1;
            GetVehicleParamsEx(VehicleID, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors == 0) return SendClientMessage(playerid, RED, "This Vehicle Is Already Locked.");
            SetVehicleParamsEx(VehicleID, engine, lights, alarm, 0, bonnet, boot, objective);
            SendClientMessage(playerid, -1, "You've successfully locked your vehicle!");
            SaveOwnedCar(OwnedCar(VehicleID));
        }
        else return SendClientMessage(playerid, RED, "This vehicle does not belong to you!");
    }
    else return SendClientMessage(playerid, RED, "This is not a private vehicle!");
    return 1;
}
Reply
#10

C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\0.3.1.pwn(5592) : error 017: undefined symbol "engine"
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\0.3.1.pwn(5593) : error 017: undefined symbol "doors"
C:\Users\owner\Desktop\SCRP\Server Files\gamemodes\0.3.1.pwn(5594) : error 017: undefined symbol "engine"

Again, this is used in the script in other things
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)