Engine Command
#1

Hey all, need someone to look over this command.

pawn Код:
command(engine, playerid, params[]) {
    new Float:Pos[3];
    if(IsPlayerInAnyVehicle(playerid) && PlayerData[playerid][AvailableEngine] == true) {
        if(GetPVarInt(playerid, "TakingTest") == 1) {
            SetPVarInt(playerid, "TakingTest", 2);
            SendNPCMessage(playerid, "Instructor", "Excellent, lets begin! Don't destroy or exit your vehicle, if you do, you'll fail!");
            SetPlayerCheckpoint(playerid, 1294.5081,-1560.3416,13.2596, 10.0);
        }
        if(!IsVehicleEngineOn(GetPlayerVehicleID(playerid)) && GetPVarInt(playerid, "TakingTest") == -1) {
            if (!strcmp(GetUserName(playerid), CarData[GetPlayerVehicleID(playerid)][Owner],true)) {
                if(IsPlayerMale(playerid)) {
                    format(string, sizeof(string), "* %s starts the engine of his vehicle.", GetUserName(playerid), sscanfinput);

                }
                else {
                    format(string, sizeof(string), "* %s starts the engine of her vehicle.", GetUserName(playerid), sscanfinput);
                }
                SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
                print(string);
                CarData[GetPlayerVehicleID(playerid)][Engine] = true;
                TogglePlayerControllable(playerid, 1);
                return 1;
            }
            if(PlayerData[playerid][RentedVehicle] == GetPlayerVehicleID(playerid)) {
                if(IsPlayerMale(playerid)) {
                    format(string, sizeof(string), "* %s starts the engine of his vehicle.", GetUserName(playerid), sscanfinput);

                }
                else {
                    format(string, sizeof(string), "* %s starts the engine of her vehicle.", GetUserName(playerid), sscanfinput);
                }
                SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
                print(string);
                CarData[GetPlayerVehicleID(playerid)][Engine] = true;
                TogglePlayerControllable(playerid, 1);
                return 1;
            }
            else {
                if(LockPick[playerid] == true) {
                    switch(CarData[NearestV[playerid]][Immobiliser]) {
                        case 0: {
                            format(string, sizeof(string), "* %s takes out a lockpick and easily breaks through the Immobiliser, the engine starts...", GetUserName(playerid));
                            SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
                            print(string);
                            CarData[GetPlayerVehicleID(playerid)][Engine] = true;
                            CarData[NearestV[playerid]][Immobiliser] = 0;
                            LockPicking[playerid] = true;
                            if(CarData[NearestV[playerid]][Alarm] == 1) {
                                format(string, sizeof(string), "* Vehicle Alarm: BEEP BEEP BEEP BEEP BEEP", GetUserName(playerid));
                                SendLocalMessage(playerid, string, 70.0, COLOR_ME, COLOR_ME);
                                VehicleLights(NearestV[playerid], true);
                                GetVehiclePos(NearestV[playerid], Pos[0], Pos[1], Pos[2]);
                                PlayerPlaySound(playerid, 1147, Pos[0], Pos[1], Pos[2]);
                                SetTimerEx("StopVAlarm", 180000 , 0, "i", NearestV[playerid]);
                            }
                            TogglePlayerControllable(playerid, true);
                        }
                        case 1: {
                            format(string, sizeof(string), "* %s takes out a lockpick and tries to break through the Immobiliser.", GetUserName(playerid));
                            SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
                            print(string);
                            LockPicking[playerid] = true;
                            CurrentTime[playerid] = 60;
                            SetTimerEx("UnlockVehicleLock", 60000, 0, "i", playerid);
                            if(CarData[NearestV[playerid]][Alarm] == 1) {
                                format(string, sizeof(string), "* Vehicle Alarm: BEEP BEEP BEEP BEEP BEEP", GetUserName(playerid));
                                SendLocalMessage(playerid, string, 70.0, COLOR_ME, COLOR_ME);
                                VehicleLights(NearestV[playerid], true);
                                GetVehiclePos(NearestV[playerid], Pos[0], Pos[1], Pos[2]);
                                PlayerPlaySound(playerid, 1147, Pos[0], Pos[1], Pos[2]);
                                SetTimerEx("StopVAlarm", 180000 , 0, "i", NearestV[playerid]);
                            }
                            TogglePlayerControllable(playerid, false);
                        }
                        case 2: {
                            format(string, sizeof(string),"* %s takes out a lockpick and tries to break through the Immobiliser.", GetUserName(playerid));
                            SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
                            print(string);
                            LockPicking[playerid] = true;
                            CurrentTime[playerid] = 120;
                            SetTimerEx("UnlockVehicleLock", 120000, 0, "i", playerid);
                            if(CarData[NearestV[playerid]][Alarm] == 1) {
                                format(string, sizeof(string), "* Vehicle Alarm: BEEP BEEP BEEP BEEP BEEP", GetUserName(playerid));
                                SendLocalMessage(playerid, string, 70.0, COLOR_ME, COLOR_ME);
                                VehicleLights(NearestV[playerid], true);
                                GetVehiclePos(NearestV[playerid], Pos[0], Pos[1], Pos[2]);
                                PlayerPlaySound(playerid, 1147, Pos[0], Pos[1], Pos[2]);
                                SetTimerEx("StopVAlarm", 180000 , 0, "i", NearestV[playerid]);
                            }
                            TogglePlayerControllable(playerid, false);
                        }
                        case 3: {
                            format(string, sizeof(string), "* %s takes out a lockpick and tries to break through the Immobiliser.", GetUserName(playerid));
                            SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
                            print(string);
                            LockPicking[playerid] = true;
                            CurrentTime[playerid] = 160;
                            SetTimerEx("UnlockVehicleLock", 160000, 0, "i", playerid);
                            if(CarData[NearestV[playerid]][Alarm] == 1) {
                                format(string, sizeof(string), "* Vehicle Alarm: BEEP BEEP BEEP BEEP BEEP", GetUserName(playerid));
                                SendLocalMessage(playerid, string, 70.0, COLOR_ME, COLOR_ME);
                                VehicleLights(NearestV[playerid], true);
                                GetVehiclePos(NearestV[playerid], Pos[0], Pos[1], Pos[2]);
                                PlayerPlaySound(playerid, 1147, Pos[0], Pos[1], Pos[2]);
                                SetTimerEx("StopVAlarm", 180000 , 0, "i", NearestV[playerid]);
                            }
                            TogglePlayerControllable(playerid, false);
                        }
                    }
                }
            }
        }
        else {
            if(IsPlayerMale(playerid)) {
                format(string, sizeof(string), "* %s turns off the engine of his vehicle.", GetUserName(playerid), sscanfinput);

            }
            else {
                format(string, sizeof(string), "* %s turns off the engine of her vehicle.", GetUserName(playerid), sscanfinput);
            }
            SendLocalMessage(playerid, string, 20.0, COLOR_ME, COLOR_ME);
            print(string);
            CarData[GetPlayerVehicleID(playerid)][Engine] = false;
            TogglePlayerControllable(playerid, 0);
        }
    }
    else {
        SendClientMessage(playerid, COLOR_SYSTEM, "[Error]: You're not in a vehicle, or you're not allowed to start the engine.");
    }
    return 1;
}
Returns 'SERVER: Unknown command.' in-game. Could anybody tell me what's wrong?

It's from the QRP script FYI.

Cheers.
Reply
#2

Bump, still require help.

Thanks.
Reply
#3

Sorry to keep bumping, but still haven't solved the problem.
Reply
#4

Try to change it from command to CMD
Reply
#5

What does it will change, lol?
Reply
#6

I had the same prob. I just changed a command tio cmd and it worked soo.. idk what was wrong..
Reply
#7

Didn't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)