Car Timer Troubles
#1

I've been scripting a Car Thief class, and I cannot seem to make the timer (for when the thief enters a player owned car) work.

What should happen is that the Thief enters the owned car, and then a 30 second timer initiates (for hotwiring)

But instead it tends to skip this step altogether and allow the Theif to just drive away.

The code is below (under onPlayerStateChange):

pawn Код:
new string[256];
  new name[256];
    new playerName[24];
    GetPlayerName(playerid, playerName, 24);
    GetPlayerName(BoughtCarsOwner[GetPlayerVehicleID(playerid)], name, 256);
  if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER && BoughtCars[GetPlayerVehicleID(playerid)] == 999 && playerName[playerid] != name[playerid] && gTeam[playerid] != TEAM_CARTHIEF) {
        if(gTeam[playerid] == TEAM_CARTHIEF){
        hotwiring[playerid] =30;
        IsPlayerHotwiring[playerid] =1;
        GetPlayerName(BoughtCarsOwner[GetPlayerVehicleID(playerid)], name,sizeof(name));
        format(string, sizeof(string), "You have begun to hotwire %s's car.",name);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        TogglePlayerControllable(playerid, 0);
 return 1;
 }


    SendClientMessage(playerid,COLOR_YELLOW,"This car has been purchased from AutoBahn. You are not the owner.");
    GetPlayerName(BoughtCarsOwner[GetPlayerVehicleID(playerid)], name,sizeof(name));
    format(string, sizeof(string), "This vehicle is registered to: %s",name);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    RemovePlayerFromVehicle(playerid);
    return 1; }






  if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
    if(hotwiring[playerid] >= 1)
  {
    SendClientMessage(playerid,COLOR_ERROR,"Hotwiring Failed, You Left the Vehicle!");
    IsPlayerHotwiring[playerid] =0;
    hotwiring[playerid] =0;
    TogglePlayerControllable(playerid, 1);
    }
    }
And here is the timer it is linked to:

pawn Код:
public hotwiretimer()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
       
        if(IsPlayerHotwiring[i] == 1)
            {
       
            if(hotwiring[i] >= 1)
            {
                hotwiring[i] --;
                new htime;
            new string[256];
                htime = (hotwiring[i]);
        format(string, sizeof(string), "~n~%d~w~ seconds until hotwiring is complete.",htime);
        GameTextForPlayer(i, string, 3000,6);
        }
            }
        if(hotwiring[i] == 0 && IsPlayerHotwiring[i] == 1)
        {
            TogglePlayerControllable(i,1);
            SendClientMessage(i, 0xA9A9A9AA, "You managed to hotwire the car, put the pedal to the metal!");
            TogglePlayerControllable(i, 1);
           

     }
    }
 }
}
Please let me know if you need to see any more code, and thank you in advance.
Reply
#2

Does it freeze you when you enter the car?
Reply
#3

It is supposed to, but it just lets me drive off immediately if i choose the Car Thief class.
Reply
#4

Change this

pawn Код:
gTeam[playerid] != TEAM_CARTHIEF
to this

pawn Код:
gTeam[playerid] == TEAM_CARTHIEF
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)