0.3c car lock system help
#1

I scripted this :
pawn Код:
//===cmd shit up here===
            else if(strcmp(x_job,"lock",true) == 0)
            {
                new key;
                if(ForwardOwnCar(1,playerid)) { key = PlayerInfo[playerid][pCarkey]; }
                else if(ForwardOwnCar(2,playerid)) { key = PlayerInfo[playerid][pCarkey2]; }
                else if(ForwardOwnCar(3,playerid)) { key = PlayerInfo[playerid][pCarkey3]; }
                else { return 1; }
                if(CarInfo[key][cLock] == 1)
                {
                    CarInfo[key][cLock] = 0;
                    GameTextForPlayer(playerid, "~w~Vehicle~n~~g~Unlocked", 4000, 3);
                    GetVehicleParamsEx(key,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(key,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
                }
                else if(CarInfo[key][cLock] == 0)
                {
                    CarInfo[key][cLock] = 1;
                    GetVehicleParamsEx(key,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(key,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
                    GameTextForPlayer(playerid, "~w~Vehicle~n~~b~Locked", 4000, 3);
                }
                PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            }
Compiles fine and all that. But doesn't lock the doors, but still sets [cLock] to 1. :S
Reply
#2

It will not compile if theres no #include <n_samp> or what ever its called up there.
Reply
#3

Quote:
Originally Posted by lowrida018
Посмотреть сообщение
It will not compile if theres no #include <n_samp> or what ever its called up there.
Quote:
Originally Posted by anant
Compiles fine and all that.
Try to find out if the variable "key" is storing the right vehicle ID.
Reply
#4

Or that. xD
Reply
#5

How to find out if it is getting the right vehicle id or not?
Because not the whole code is scripted by me. I got the gm from a place and I'm converting it to 0.3c. Everything is done while door lock isnt working :/
Oh, here is the ForwardOwnCar function used in the cmd.
pawn Код:
forward ForwardOwnCar(type,playerid);
public ForwardOwnCar(type,playerid)
{
    for(new i=0; i<MAX_VEHICLES; i++)
    {
        if(type == 1 && VehicleOwned[i] != SCRIPT_CARS)
        {
            if(VehicleOwned[i] == PlayerInfo[playerid][pCarkey])
            {
                return 1;
            }
        }
        else if(type == 2 && VehicleOwned[i] != SCRIPT_CARS)
        {
            if(VehicleOwned[i] == PlayerInfo[playerid][pCarkey2])
            {
                return 1;
            }
        }
        else if(type == 3 && VehicleOwned[i] != SCRIPT_CARS)
        {
            if(VehicleOwned[i] == PlayerInfo[playerid][pCarkey3])
            {
                return 1;
            }
        }
    }
    return 0;
}
Reply
#6

pawn Код:
//===cmd shit up here===
            else if(strcmp(x_job,"lock",true) == 0)
            {
                new key;
                if(ForwardOwnCar(1,playerid)) { key = PlayerInfo[playerid][pCarkey]; }
                else if(ForwardOwnCar(2,playerid)) { key = PlayerInfo[playerid][pCarkey2]; }
                else if(ForwardOwnCar(3,playerid)) { key = PlayerInfo[playerid][pCarkey3]; }
                else { return 1; }
                if(CarInfo[key][cLock] == 1)
                {
                    CarInfo[key][cLock] = 0;
                    GameTextForPlayer(playerid, "~w~Vehicle~n~~g~Unlocked", 4000, 3);
                    GetVehicleParamsEx(key,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(key,engine,lights,alarm,VEHICLE_PARAMS_OFF,bonnet,boot,objective);
                }
                else
                {
                    CarInfo[key][cLock] = 1;
                    GetVehicleParamsEx(key,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(key,engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
                    GameTextForPlayer(playerid, "~w~Vehicle~n~~b~Locked", 4000, 3);
                }
                PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
            }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)