Help with code for DMV
#1

I need help with this code for my DMV, the problem is it doesn't work... It's supposed to Fail someone if they are speeding or if they damage their car too much during the license test, but it doesn't seem to work (either of them). What is wrong with it, and how can I fix?

Code (located under: public OnPlayerUpdateEx ):
pawn Код:
}
        if (TakingLesson[playerid] == 1)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new Float:health;
                new veh;
                veh = GetPlayerVehicleID(playerid);
                GetVehicleHealth(veh, health);
                if (health < 350)
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: Your car broke down!");
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: You failed the test, please try again!");
                    DisablePlayerCheckpoint(playerid);
                    RemovePlayerFromVehicle(playerid);
                    SetPlayerVirtualWorld(playerid, 0);
                    SetVehicleToRespawn(GetPlayerVehicleID(playerid));
                    TakingLesson[playerid] = 0;
                    return 1;
                }

                new speed = GetPlayerSpeed(playerid, true);
                if(speed > 50)
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: You are speeding!");
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: You failed the test, please try again!");
                    DisablePlayerCheckpoint(playerid);
                    RemovePlayerFromVehicle(playerid);
                    SetPlayerVirtualWorld(playerid, 0);
                    SetVehicleToRespawn(GetPlayerVehicleID(playerid));
                    TakingLesson[playerid] = 0;
                    return 1;
                }
            }
        }
    }
    return 1;
}
Reply
#2

Anyone know?
Reply
#3

If I might make a suggestion.

Instead of using this in OnPlayerUpdate, why not make it so when they enter the checkpoint it checks for these things?

I have something similar in my script, and have it do the check when the player enters the checkpoint.

Also, another suggestion, make it so the car health is more than 350. I mean if they get to the point where their car is broken down, its fairly obvious they should fail. So let's say make it like 600-700hp? The point of a DMV Driving test is to prove you're a good enough driver to gain a license.

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
        if (TakingLesson[playerid] == 1)
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new
                      Float:health,
                      speed = GetPlayerSpeed(playerid, true)
                ;
                GetVehicleHealth(GetPlayerVehicleID(playerid), health);
                if (health < 700)
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: Your car has taken too much damage!");
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: You failed the test, please try again!");
                    DisablePlayerCheckpoint(playerid);
                    RemovePlayerFromVehicle(playerid);
                    SetPlayerVirtualWorld(playerid, 0);
                    SetVehicleToRespawn(GetPlayerVehicleID(playerid));
                    TakingLesson[playerid] = 0;
                    return 1;
                }
                if(speed > 50)
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: You are speeding!");
                    SendClientMessage(playerid, COLOR_LIGHTBLUE,"DMV: You failed the test, please try again!");
                    DisablePlayerCheckpoint(playerid);
                    RemovePlayerFromVehicle(playerid);
                    SetPlayerVirtualWorld(playerid, 0);
                    SetVehicleToRespawn(GetPlayerVehicleID(playerid));
                    TakingLesson[playerid] = 0;
                    return 1;
                }
                else
                {
                     // CODE TO CONTINUE THE TEST
                }
            }
        }
        return 1;
}
Anyway, just a suggestion.
Reply
#4

GREAT IDEA! I actually just tried the health one before I read this on the onplayerentercheckpoint part and it worked nicely... I will now try the speed part there. Thanks for writing it out for me +1 Rep.

-jakejohnsonusa
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)